diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-12 14:33:46 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2019-05-12 14:33:46 +0200 |
commit | 81b9ff8980a9a235b8915b5779ebc1d2a738a9a3 (patch) | |
tree | cd9d52274331a37f58048c836f8cf015e1f78c83 /modules/webapps/mediagoblin.nix | |
parent | b92abb02739e04df9996f31dd4f30c793b190c7a (diff) | |
download | Nix-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/mediagoblin.nix')
-rw-r--r-- | modules/webapps/mediagoblin.nix | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/modules/webapps/mediagoblin.nix b/modules/webapps/mediagoblin.nix index 0232aab..5753457 100644 --- a/modules/webapps/mediagoblin.nix +++ b/modules/webapps/mediagoblin.nix | |||
@@ -107,6 +107,26 @@ in | |||
107 | ''; | 107 | ''; |
108 | readOnly = true; | 108 | readOnly = true; |
109 | }; | 109 | }; |
110 | systemdStateDirectory = lib.mkOption { | ||
111 | type = lib.types.str; | ||
112 | # Use ReadWritePaths= instead if varDir is outside of /var/lib | ||
113 | default = assert lib.strings.hasPrefix "/var/lib/" cfg.dataDir; | ||
114 | lib.strings.removePrefix "/var/lib/" cfg.dataDir; | ||
115 | description = '' | ||
116 | Adjusted Mediagoblin data directory for systemd | ||
117 | ''; | ||
118 | readOnly = true; | ||
119 | }; | ||
120 | systemdRuntimeDirectory = lib.mkOption { | ||
121 | type = lib.types.str; | ||
122 | # Use ReadWritePaths= instead if socketsDir is outside of /run | ||
123 | default = assert lib.strings.hasPrefix "/run/" cfg.socketsDir; | ||
124 | lib.strings.removePrefix "/run/" cfg.socketsDir; | ||
125 | description = '' | ||
126 | Adjusted Mediagoblin sockets directory for systemd | ||
127 | ''; | ||
128 | readOnly = true; | ||
129 | }; | ||
110 | sockets = lib.mkOption { | 130 | sockets = lib.mkOption { |
111 | type = lib.types.attrsOf lib.types.path; | 131 | type = lib.types.attrsOf lib.types.path; |
112 | default = { | 132 | default = { |
@@ -173,6 +193,8 @@ in | |||
173 | TimeoutSec = 15; | 193 | TimeoutSec = 15; |
174 | Type = "simple"; | 194 | Type = "simple"; |
175 | WorkingDirectory = cfg.workdir; | 195 | WorkingDirectory = cfg.workdir; |
196 | RuntimeDirectory = cfg.systemdRuntimeDirectory; | ||
197 | StateDirectory= cfg.systemdStateDirectory; | ||
176 | PIDFile = cfg.pids.paster; | 198 | PIDFile = cfg.pids.paster; |
177 | }; | 199 | }; |
178 | 200 | ||
@@ -200,6 +222,8 @@ in | |||
200 | TimeoutSec = 60; | 222 | TimeoutSec = 60; |
201 | Type = "simple"; | 223 | Type = "simple"; |
202 | WorkingDirectory = cfg.workdir; | 224 | WorkingDirectory = cfg.workdir; |
225 | RuntimeDirectory = cfg.systemdRuntimeDirectory; | ||
226 | StateDirectory= cfg.systemdStateDirectory; | ||
203 | PIDFile = cfg.pids.celery; | 227 | PIDFile = cfg.pids.celery; |
204 | }; | 228 | }; |
205 | 229 | ||
@@ -209,8 +233,6 @@ in | |||
209 | system.activationScripts.mediagoblin = { | 233 | system.activationScripts.mediagoblin = { |
210 | deps = [ "users" ]; | 234 | deps = [ "users" ]; |
211 | text = '' | 235 | text = '' |
212 | install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.socketsDir} | ||
213 | install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir} | ||
214 | if [ -d ${cfg.dataDir}/plugin_static/ ]; then | 236 | if [ -d ${cfg.dataDir}/plugin_static/ ]; then |
215 | rm ${cfg.dataDir}/plugin_static/coreplugin_basic_auth | 237 | rm ${cfg.dataDir}/plugin_static/coreplugin_basic_auth |
216 | ln -sf ${cfg.workdir}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth | 238 | ln -sf ${cfg.workdir}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth |