aboutsummaryrefslogtreecommitdiff
path: root/nixops
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-12 14:33:46 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2019-05-12 14:33:46 +0200
commit81b9ff8980a9a235b8915b5779ebc1d2a738a9a3 (patch)
treecd9d52274331a37f58048c836f8cf015e1f78c83 /nixops
parentb92abb02739e04df9996f31dd4f30c793b190c7a (diff)
downloadNix-81b9ff8980a9a235b8915b5779ebc1d2a738a9a3.tar.gz
Nix-81b9ff8980a9a235b8915b5779ebc1d2a738a9a3.tar.zst
Nix-81b9ff8980a9a235b8915b5779ebc1d2a738a9a3.zip
Use systemd RuntimeDirectory and StateDirectory entries to ensure runtime directory existence in apps
Diffstat (limited to 'nixops')
-rw-r--r--nixops/modules/buildbot/default.nix9
-rw-r--r--nixops/modules/databases/redis.nix8
-rw-r--r--nixops/modules/mpd.nix4
-rw-r--r--nixops/modules/task/default.nix12
4 files changed, 14 insertions, 19 deletions
diff --git a/nixops/modules/buildbot/default.nix b/nixops/modules/buildbot/default.nix
index d7dd479..c812af9 100644
--- a/nixops/modules/buildbot/default.nix
+++ b/nixops/modules/buildbot/default.nix
@@ -61,11 +61,7 @@ in
61 61
62 system.activationScripts = lib.attrsets.mapAttrs' (k: project: lib.attrsets.nameValuePair "buildbot-${project.name}" { 62 system.activationScripts = lib.attrsets.mapAttrs' (k: project: lib.attrsets.nameValuePair "buildbot-${project.name}" {
63 deps = [ "users" "wrappers" ]; 63 deps = [ "users" "wrappers" ];
64 text = '' 64 text = project.activationScript;
65 install -m 0755 -o buildbot -g buildbot -d /run/buildbot/
66 install -m 0755 -o buildbot -g buildbot -d ${varDir}
67 ${project.activationScript}
68 '';
69 }) myconfig.env.buildbot.projects; 65 }) myconfig.env.buildbot.projects;
70 66
71 secrets.keys = ( 67 secrets.keys = (
@@ -190,6 +186,9 @@ in
190 Type = "forking"; 186 Type = "forking";
191 User = "buildbot"; 187 User = "buildbot";
192 Group = "buildbot"; 188 Group = "buildbot";
189 RuntimeDirectory = "buildbot";
190 RuntimeDirectoryPreserve = "yes";
191 StateDirectory = "buildbot";
193 SupplementaryGroups = "keys"; 192 SupplementaryGroups = "keys";
194 WorkingDirectory = "${varDir}/${project.name}"; 193 WorkingDirectory = "${varDir}/${project.name}";
195 ExecStart = "${buildbot}/bin/buildbot start"; 194 ExecStart = "${buildbot}/bin/buildbot start";
diff --git a/nixops/modules/databases/redis.nix b/nixops/modules/databases/redis.nix
index a0917df..75c69a6 100644
--- a/nixops/modules/databases/redis.nix
+++ b/nixops/modules/databases/redis.nix
@@ -27,11 +27,9 @@ in {
27 maxclients 1024 27 maxclients 1024
28 ''; 28 '';
29 }; 29 };
30 system.activationScripts.redis = '' 30 systemd.services.redis.serviceConfig.RuntimeDirectory =
31 mkdir -p $(dirname ${myconfig.env.databases.redis.socket}) 31 assert myconfig.env.databases.redis.socket == "/run/redis/redis.sock";
32 chown redis $(dirname ${myconfig.env.databases.redis.socket}) 32 "redis";
33 '';
34
35 }; 33 };
36} 34}
37 35
diff --git a/nixops/modules/mpd.nix b/nixops/modules/mpd.nix
index bc8b8df..9903bdf 100644
--- a/nixops/modules/mpd.nix
+++ b/nixops/modules/mpd.nix
@@ -19,9 +19,7 @@
19 ]; 19 ];
20 networking.firewall.allowedTCPPorts = [ 6600 ]; 20 networking.firewall.allowedTCPPorts = [ 6600 ];
21 users.users.mpd.extraGroups = [ "wwwrun" "keys" ]; 21 users.users.mpd.extraGroups = [ "wwwrun" "keys" ];
22 system.activationScripts.mpd = '' 22 systemd.services.mpd.serviceConfig.RuntimeDirectory = "mpd";
23 install -d -m 0755 -o mpd -g mpd /run/mpd
24 '';
25 services.mpd = { 23 services.mpd = {
26 enable = true; 24 enable = true;
27 network.listenAddress = "any"; 25 network.listenAddress = "any";
diff --git a/nixops/modules/task/default.nix b/nixops/modules/task/default.nix
index 8454c4b..8370608 100644
--- a/nixops/modules/task/default.nix
+++ b/nixops/modules/task/default.nix
@@ -245,12 +245,6 @@ in {
245 system.activationScripts.taskwarrior-web = { 245 system.activationScripts.taskwarrior-web = {
246 deps = [ "users" ]; 246 deps = [ "users" ];
247 text = '' 247 text = ''
248 install -m 0755 -o ${user} -g ${group} -d ${socketsDir}
249 install -m 0750 -o ${user} -g ${group} -d ${varDir}
250 ${builtins.concatStringsSep "\n" (lib.attrsets.mapAttrsToList
251 (k: v: "install -m 0750 -o ${user} -g ${group} -d ${varDir}/${k}")
252 env.taskwarrior-web
253 )}
254 if [ ! -f ${server_vardir}/userkeys/taskwarrior-web.cert.pem ]; then 248 if [ ! -f ${server_vardir}/userkeys/taskwarrior-web.cert.pem ]; then
255 ${taskserver-user-certs}/bin/taskserver-user-certs taskwarrior-web 249 ${taskserver-user-certs}/bin/taskserver-user-certs taskwarrior-web
256 chown taskd:taskd ${server_vardir}/userkeys/taskwarrior-web.cert.pem ${server_vardir}/userkeys/taskwarrior-web.key.pem 250 chown taskd:taskd ${server_vardir}/userkeys/taskwarrior-web.cert.pem ${server_vardir}/userkeys/taskwarrior-web.key.pem
@@ -315,6 +309,12 @@ in {
315 TimeoutSec = 60; 309 TimeoutSec = 60;
316 Type = "simple"; 310 Type = "simple";
317 WorkingDirectory = taskwarrior-web; 311 WorkingDirectory = taskwarrior-web;
312 StateDirectoryMode = 0750;
313 StateDirectory = assert lib.strings.hasPrefix "/var/lib/" varDir;
314 (lib.strings.removePrefix "/var/lib/" varDir + "/${name}");
315 RuntimeDirectoryPreserve = "yes";
316 RuntimeDirectory = assert lib.strings.hasPrefix "/run/" socketsDir;
317 lib.strings.removePrefix "/run/" socketsDir;
318 }; 318 };
319 319
320 unitConfig.RequiresMountsFor = varDir; 320 unitConfig.RequiresMountsFor = varDir;