1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-27 05:29:46 +01:00

syncthing: add option extraOptions

Fixes #2598
This commit is contained in:
Robert Helgesson 2022-01-27 00:29:00 +01:00
parent cbc176010b
commit 86248a2d5c
No known key found for this signature in database
GPG key ID: 36BDAA14C2797E89
3 changed files with 29 additions and 1 deletions

View file

@ -9,6 +9,15 @@ with lib;
services.syncthing = {
enable = mkEnableOption "Syncthing continuous file synchronization";
extraOptions = mkOption {
type = types.listOf types.str;
default = [ ];
example = [ "--gui-apikey=apiKey" ];
description = ''
Extra command-line arguments to pass to <command>syncthing</command>.
'';
};
tray = mkOption {
type = with types;
either bool (submodule {
@ -57,7 +66,9 @@ with lib;
Service = {
ExecStart =
"${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0";
"${pkgs.syncthing}/bin/syncthing -no-browser -no-restart -logflags=0"
+ optionalString (config.services.syncthing.extraOptions != [ ])
(" " + escapeShellArgs config.services.syncthing.extraOptions);
Restart = "on-failure";
SuccessExitStatus = [ 3 4 ];
RestartForceExitStatus = [ 3 4 ];

View file

@ -1,4 +1,5 @@
{
syncthing-extra-options = ./extra-options.nix;
syncthing-tray = ./tray.nix;
syncthing-tray-as-bool-triggers-warning = ./tray-as-bool-triggers-warning.nix;
}

View file

@ -0,0 +1,16 @@
{ config, ... }:
{
services.syncthing = {
enable = true;
extraOptions = [ "-foo" ''-bar "baz"'' ];
};
test.stubs.syncthing = { };
nmt.script = ''
assertFileExists home-files/.config/systemd/user/syncthing.service
assertFileContains home-files/.config/systemd/user/syncthing.service \
"ExecStart=@syncthing@/bin/syncthing -no-browser -no-restart -logflags=0 '-foo' '-bar \"baz\"'"
'';
}