diff --git a/nixos/modules/services/torrent/transmission.nix b/nixos/modules/services/torrent/transmission.nix index 87493ec6ba62..95d0f9e8a486 100644 --- a/nixos/modules/services/torrent/transmission.nix +++ b/nixos/modules/services/torrent/transmission.nix @@ -357,19 +357,29 @@ in # when /home/foo is not owned by cfg.user. # Note also that using an ExecStartPre= wouldn't work either # because BindPaths= needs these directories before. - system.activationScripts.transmission-daemon = '' - install -d -m 700 -o '${cfg.user}' -g '${cfg.group}' '${cfg.home}/${settingsDir}' - '' - + optionalString (cfg.downloadDirPermissions != null) '' - install -d -m '${cfg.downloadDirPermissions}' -o '${cfg.user}' -g '${cfg.group}' '${cfg.settings.download-dir}' + systemd.services.transmission-setup = { + before = [ "transmission.service" ]; + partOf = [ "transmission.service" ]; - ${optionalString cfg.settings.incomplete-dir-enabled '' - install -d -m '${cfg.downloadDirPermissions}' -o '${cfg.user}' -g '${cfg.group}' '${cfg.settings.incomplete-dir}' - ''} - ${optionalString cfg.settings.watch-dir-enabled '' - install -d -m '${cfg.downloadDirPermissions}' -o '${cfg.user}' -g '${cfg.group}' '${cfg.settings.watch-dir}' - ''} - ''; + serviceConfig = { + Type = "oneshot"; + RemainAfterExit = true; + }; + + script = '' + install -d -m 700 -o '${cfg.user}' -g '${cfg.group}' '${cfg.home}/${settingsDir}' + '' + + optionalString (cfg.downloadDirPermissions != null) '' + install -d -m '${cfg.downloadDirPermissions}' -o '${cfg.user}' -g '${cfg.group}' '${cfg.settings.download-dir}' + + ${optionalString cfg.settings.incomplete-dir-enabled '' + install -d -m '${cfg.downloadDirPermissions}' -o '${cfg.user}' -g '${cfg.group}' '${cfg.settings.incomplete-dir}' + ''} + ${optionalString cfg.settings.watch-dir-enabled '' + install -d -m '${cfg.downloadDirPermissions}' -o '${cfg.user}' -g '${cfg.group}' '${cfg.settings.watch-dir}' + ''} + ''; + }; systemd.services.transmission = { description = "Transmission BitTorrent Service"; @@ -392,7 +402,7 @@ in set -eu${lib.optionalString (cfg.settings.message-level >= 3) "x"} ${pkgs.jq}/bin/jq --slurp add ${settingsFile} '${cfg.credentialsFile}' | install -D -m 600 -o '${cfg.user}' -g '${cfg.group}' /dev/stdin \ - '${cfg.home}/${settingsDir}/settings.json' + '${cfg.home}/${settingsDir}/settings.json' '' ) ]; diff --git a/nixos/tests/all-tests.nix b/nixos/tests/all-tests.nix index 2b538a450c2f..282835431246 100644 --- a/nixos/tests/all-tests.nix +++ b/nixos/tests/all-tests.nix @@ -1630,7 +1630,7 @@ in traefik = runTestOn [ "aarch64-linux" "x86_64-linux" ] ./traefik.nix; trafficserver = runTest ./trafficserver.nix; transfer-sh = runTest ./transfer-sh.nix; - transmission_4 = handleTest ./transmission.nix { }; + transmission_4 = runTest ./transmission.nix; trezord = runTest ./trezord.nix; trickster = runTest ./trickster.nix; trilium-server = runTestOn [ "x86_64-linux" ] ./trilium-server.nix; diff --git a/nixos/tests/transmission.nix b/nixos/tests/transmission.nix index 5186098b40cc..406b0df8599d 100644 --- a/nixos/tests/transmission.nix +++ b/nixos/tests/transmission.nix @@ -1,27 +1,28 @@ -import ./make-test-python.nix ( - { pkgs, ... }: - { - name = "transmission"; - meta = with pkgs.lib.maintainers; { - maintainers = [ coconnor ]; +{ pkgs, ... }: +{ + name = "transmission"; + meta = with pkgs.lib.maintainers; { + maintainers = [ coconnor ]; + }; + + nodes.machine = + { ... }: + { + imports = [ ../modules/profiles/minimal.nix ]; + + networking.firewall.allowedTCPPorts = [ 9091 ]; + + security.apparmor.enable = true; + + services.transmission.enable = true; }; - nodes.machine = - { ... }: - { - imports = [ ../modules/profiles/minimal.nix ]; - - networking.firewall.allowedTCPPorts = [ 9091 ]; - - security.apparmor.enable = true; - - services.transmission.enable = true; - }; - - testScript = '' + testScript = + { nodes, ... }: + #python + '' start_all() machine.wait_for_unit("transmission") machine.shutdown() ''; - } -) +}