]> git.immae.eu Git - perso/Immae/Config/Nix.git/blobdiff - modules/webapps/diaspora.nix
Use systemd RuntimeDirectory and StateDirectory entries to ensure runtime directory...
[perso/Immae/Config/Nix.git] / modules / webapps / diaspora.nix
index 8451c6d341da11139e3a58857b507995305a2753..226633202792a24bb08345a1d07436754a223803 100644 (file)
@@ -52,6 +52,26 @@ in
         '';
     };
     # Output variables
+    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 Diaspora 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 Diaspora sockets directory for systemd
+      '';
+      readOnly = true;
+    };
     workdir = lib.mkOption {
       type = lib.types.package;
       default = cfg.package.override {
@@ -134,6 +154,8 @@ in
         Restart = "always";
         Type = "simple";
         WorkingDirectory = cfg.workdir;
+        StateDirectory = cfg.systemdStateDirectory;
+        RuntimeDirectory = cfg.systemdRuntimeDirectory;
         StandardInput = "null";
         KillMode = "control-group";
       };
@@ -144,10 +166,8 @@ in
     system.activationScripts.diaspora = {
       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} \
-        ${cfg.dataDir}/uploads ${cfg.dataDir}/tmp \
-        ${cfg.dataDir}/log
+      install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}/uploads \
+        ${cfg.dataDir}/tmp ${cfg.dataDir}/log
       install -m 0700 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}/tmp/pids
       if [ ! -f ${cfg.dataDir}/schedule.yml ]; then
         echo "{}" | $wrapperDir/sudo -u ${cfg.user} tee ${cfg.dataDir}/schedule.yml