'';
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 Mastodon 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 Mastodon sockets directory for systemd
+ '';
+ readOnly = true;
+ };
sockets = lib.mkOption {
type = lib.types.attrsOf lib.types.path;
default = {
TimeoutSec = 15;
Type = "simple";
WorkingDirectory = cfg.workdir;
+ StateDirectory = cfg.systemdStateDirectory;
+ RuntimeDirectory = cfg.systemdRuntimeDirectory;
+ RuntimeDirectoryPreserve = "yes";
};
unitConfig.RequiresMountsFor = cfg.dataDir;
TimeoutSec = 60;
Type = "simple";
WorkingDirectory = cfg.workdir;
+ StateDirectory = cfg.systemdStateDirectory;
+ RuntimeDirectory = cfg.systemdRuntimeDirectory;
+ RuntimeDirectoryPreserve = "yes";
};
unitConfig.RequiresMountsFor = cfg.dataDir;
TimeoutSec = 15;
Type = "simple";
WorkingDirectory = cfg.workdir;
+ StateDirectory = cfg.systemdStateDirectory;
+ RuntimeDirectory = cfg.systemdRuntimeDirectory;
+ RuntimeDirectoryPreserve = "yes";
};
unitConfig.RequiresMountsFor = cfg.dataDir;
system.activationScripts.mastodon = {
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}/tmp/cache
+ install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}/tmp/cache
'';
};