]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/webapps/mediagoblin.nix
Use systemd RuntimeDirectory and StateDirectory entries to ensure runtime directory...
[perso/Immae/Config/Nix.git] / modules / webapps / mediagoblin.nix
index 0232aab2efa0e510ecc3c8b71ae9e5845cf979ea..575345758e1e090934d595cf14a5e2578fe45da3 100644 (file)
@@ -107,6 +107,26 @@ in
       '';
       readOnly = true;
     };
+    systemdStateDirectory = lib.mkOption {
+      type = lib.types.str;
+      # Use ReadWritePaths= instead if varDir is outside of /var/lib
+      default = assert lib.strings.hasPrefix "/var/lib/" cfg.dataDir;
+        lib.strings.removePrefix "/var/lib/" cfg.dataDir;
+      description = ''
+      Adjusted Mediagoblin data directory for systemd
+      '';
+      readOnly = true;
+    };
+    systemdRuntimeDirectory = lib.mkOption {
+      type = lib.types.str;
+      # Use ReadWritePaths= instead if socketsDir is outside of /run
+      default = assert lib.strings.hasPrefix "/run/" cfg.socketsDir;
+        lib.strings.removePrefix "/run/" cfg.socketsDir;
+      description = ''
+      Adjusted Mediagoblin sockets directory for systemd
+      '';
+      readOnly = true;
+    };
     sockets = lib.mkOption {
       type = lib.types.attrsOf lib.types.path;
       default = {
@@ -173,6 +193,8 @@ in
         TimeoutSec = 15;
         Type = "simple";
         WorkingDirectory = cfg.workdir;
+        RuntimeDirectory = cfg.systemdRuntimeDirectory;
+        StateDirectory= cfg.systemdStateDirectory;
         PIDFile = cfg.pids.paster;
       };
 
@@ -200,6 +222,8 @@ in
         TimeoutSec = 60;
         Type = "simple";
         WorkingDirectory = cfg.workdir;
+        RuntimeDirectory = cfg.systemdRuntimeDirectory;
+        StateDirectory= cfg.systemdStateDirectory;
         PIDFile = cfg.pids.celery;
       };
 
@@ -209,8 +233,6 @@ in
     system.activationScripts.mediagoblin = {
       deps = [ "users" ];
       text = ''
-      install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.socketsDir}
-      install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}
       if [ -d ${cfg.dataDir}/plugin_static/ ]; then
         rm ${cfg.dataDir}/plugin_static/coreplugin_basic_auth
         ln -sf ${cfg.workdir}/mediagoblin/plugins/basic_auth/static ${cfg.dataDir}/plugin_static/coreplugin_basic_auth