git.iko.soy/typeable/nixpkgs
on master help sign in
nixos/transmission: refactor preStart into script
commit9eec034d7596bc40a3c346db545d24747fa4e29e authorCorey O'Connor <coreyoconnor@gmail.com> dateSun 18 Mar 2018, 09:25 (9 years ago) parentf55a6ab
1 file changed+11−3
nixos/modules/services/torrent/transmission.nix+11−3
nixos/modules/services/torrent/transmission.nix+11−3
@@ -21,6 +21,16 @@ let
2121
2222 # for users in group "transmission" to have access to torrents
2323 fullSettings = { umask = 2; download-dir = downloadDir; incomplete-dir = incompleteDir; } // cfg.settings;
24+
25+ preStart = pkgs.writeScript "transmission-pre-start" ''
26+ #!${pkgs.runtimeShell}
27+ set -ex
28+ for DIR in ${homeDir} ${settingsDir} ${fullSettings.download-dir} ${fullSettings.incomplete-dir}; do
29+ mkdir -p "$DIR"
30+ chmod 770 "$DIR"
31+ done
32+ cp -f ${settingsFile} ${settingsDir}/settings.json
33+ '';
2434in
2535{
2636 options = {
@@ -89,9 +99,7 @@ in
8999
90100 # 1) Only the "transmission" user and group have access to torrents.
91101 # 2) Optionally update/force specific fields into the configuration file.
92− serviceConfig.ExecStartPre = ''
93− ${pkgs.runtimeShell} -c "mkdir -p ${homeDir} ${settingsDir} ${fullSettings.download-dir} ${fullSettings.incomplete-dir} && chmod 770 ${homeDir} ${settingsDir} ${fullSettings.download-dir} ${fullSettings.incomplete-dir} && rm -f ${settingsDir}/settings.json && cp -f ${settingsFile} ${settingsDir}/settings.json"
94− '';
102+ serviceConfig.ExecStartPre = preStart;
95103 serviceConfig.ExecStart = "${pkgs.transmission}/bin/transmission-daemon -f --port ${toString config.services.transmission.port}";
96104 serviceConfig.ExecReload = "${pkgs.coreutils}/bin/kill -HUP $MAINPID";
97105 serviceConfig.User = "transmission";