nixos/transmission: convert test to runTest and replace activationScript by systemd service (#484412)

This commit is contained in:
Ramses
2026-01-31 17:48:40 +00:00
committed by GitHub
3 changed files with 46 additions and 35 deletions
+23 -13
View File
@@ -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'
''
)
];
+1 -1
View File
@@ -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;
+22 -21
View File
@@ -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()
'';
}
)
}