aboutsummaryrefslogtreecommitdiff
path: root/modules/webapps/diaspora.nix
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 /modules/webapps/diaspora.nix
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 'modules/webapps/diaspora.nix')
-rw-r--r--modules/webapps/diaspora.nix28
1 files changed, 24 insertions, 4 deletions
diff --git a/modules/webapps/diaspora.nix b/modules/webapps/diaspora.nix
index 8451c6d..2266332 100644
--- a/modules/webapps/diaspora.nix
+++ b/modules/webapps/diaspora.nix
@@ -52,6 +52,26 @@ in
52 ''; 52 '';
53 }; 53 };
54 # Output variables 54 # Output variables
55 systemdStateDirectory = lib.mkOption {
56 type = lib.types.str;
57 # Use ReadWritePaths= instead if varDir is outside of /var/lib
58 default = assert lib.strings.hasPrefix "/var/lib/" cfg.dataDir;
59 lib.strings.removePrefix "/var/lib/" cfg.dataDir;
60 description = ''
61 Adjusted Diaspora data directory for systemd
62 '';
63 readOnly = true;
64 };
65 systemdRuntimeDirectory = lib.mkOption {
66 type = lib.types.str;
67 # Use ReadWritePaths= instead if socketsDir is outside of /run
68 default = assert lib.strings.hasPrefix "/run/" cfg.socketsDir;
69 lib.strings.removePrefix "/run/" cfg.socketsDir;
70 description = ''
71 Adjusted Diaspora sockets directory for systemd
72 '';
73 readOnly = true;
74 };
55 workdir = lib.mkOption { 75 workdir = lib.mkOption {
56 type = lib.types.package; 76 type = lib.types.package;
57 default = cfg.package.override { 77 default = cfg.package.override {
@@ -134,6 +154,8 @@ in
134 Restart = "always"; 154 Restart = "always";
135 Type = "simple"; 155 Type = "simple";
136 WorkingDirectory = cfg.workdir; 156 WorkingDirectory = cfg.workdir;
157 StateDirectory = cfg.systemdStateDirectory;
158 RuntimeDirectory = cfg.systemdRuntimeDirectory;
137 StandardInput = "null"; 159 StandardInput = "null";
138 KillMode = "control-group"; 160 KillMode = "control-group";
139 }; 161 };
@@ -144,10 +166,8 @@ in
144 system.activationScripts.diaspora = { 166 system.activationScripts.diaspora = {
145 deps = [ "users" ]; 167 deps = [ "users" ];
146 text = '' 168 text = ''
147 install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.socketsDir} 169 install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}/uploads \
148 install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir} \ 170 ${cfg.dataDir}/tmp ${cfg.dataDir}/log
149 ${cfg.dataDir}/uploads ${cfg.dataDir}/tmp \
150 ${cfg.dataDir}/log
151 install -m 0700 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}/tmp/pids 171 install -m 0700 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}/tmp/pids
152 if [ ! -f ${cfg.dataDir}/schedule.yml ]; then 172 if [ ! -f ${cfg.dataDir}/schedule.yml ]; then
153 echo "{}" | $wrapperDir/sudo -u ${cfg.user} tee ${cfg.dataDir}/schedule.yml 173 echo "{}" | $wrapperDir/sudo -u ${cfg.user} tee ${cfg.dataDir}/schedule.yml