From 76fe6d9465e9f1d5b6f38db0c6b85b09dc1bf128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Mon, 9 Oct 2023 09:31:44 +0300 Subject: [PATCH] syncthingtray: add extraOptions The test currently fails, because the nix path in the generated unit does not get rewritten to `@syncthingtray@`. Pointers would be appreciated. --- modules/services/syncthing.nix | 13 ++++++++++++- tests/modules/services/syncthing/linux/tray.nix | 8 +++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/modules/services/syncthing.nix b/modules/services/syncthing.nix index b6cebfa5f..a17c54ed2 100644 --- a/modules/services/syncthing.nix +++ b/modules/services/syncthing.nix @@ -49,6 +49,15 @@ in { description = "Syncthing tray command to use."; }; + extraOptions = mkOption { + type = types.listOf types.str; + default = [ ]; + example = [ "--wait" ]; + description = '' + Extra command-line arguments to pass to {command}`syncthingtray`. + ''; + }; + package = mkOption { type = types.package; default = pkgs.syncthingtray-minimal; @@ -126,7 +135,9 @@ in { }; Service = { - ExecStart = "${cfg.tray.package}/bin/${cfg.tray.command}"; + ExecStart = escapeShellArgs + ([ "${cfg.tray.package}/bin/${cfg.tray.command}" ] + ++ cfg.tray.extraOptions); }; Install = { WantedBy = [ "graphical-session.target" ]; }; diff --git a/tests/modules/services/syncthing/linux/tray.nix b/tests/modules/services/syncthing/linux/tray.nix index 5ff3c2841..934de5b84 100644 --- a/tests/modules/services/syncthing/linux/tray.nix +++ b/tests/modules/services/syncthing/linux/tray.nix @@ -4,7 +4,12 @@ with lib; { config = { - services.syncthing.tray.enable = true; + services.syncthing.tray = { + enable = true; + extraOptions = [ "--wait" ]; + }; + + test.stubs.syncthingtray = { }; nixpkgs.overlays = [ (self: super: { @@ -16,6 +21,7 @@ with lib; nmt.script = '' assertFileExists home-files/.config/systemd/user/syncthingtray.service + assertFileContains home-files/.config/systemd/user/syncthingtray.service "ExecStart='@syncthingtray@/bin/syncthingtray' '--wait'" ''; }; }