diff options
Diffstat (limited to 'modules/webapps/mastodon.nix')
-rw-r--r-- | modules/webapps/mastodon.nix | 32 |
1 files changed, 30 insertions, 2 deletions
diff --git a/modules/webapps/mastodon.nix b/modules/webapps/mastodon.nix index ad6d0c3..f8fbcba 100644 --- a/modules/webapps/mastodon.nix +++ b/modules/webapps/mastodon.nix | |||
@@ -62,6 +62,26 @@ in | |||
62 | ''; | 62 | ''; |
63 | readOnly = true; | 63 | readOnly = true; |
64 | }; | 64 | }; |
65 | systemdStateDirectory = lib.mkOption { | ||
66 | type = lib.types.str; | ||
67 | # Use ReadWritePaths= instead if varDir is outside of /var/lib | ||
68 | default = assert lib.strings.hasPrefix "/var/lib/" cfg.dataDir; | ||
69 | lib.strings.removePrefix "/var/lib/" cfg.dataDir; | ||
70 | description = '' | ||
71 | Adjusted Mastodon data directory for systemd | ||
72 | ''; | ||
73 | readOnly = true; | ||
74 | }; | ||
75 | systemdRuntimeDirectory = lib.mkOption { | ||
76 | type = lib.types.str; | ||
77 | # Use ReadWritePaths= instead if socketsDir is outside of /run | ||
78 | default = assert lib.strings.hasPrefix "/run/" cfg.socketsDir; | ||
79 | lib.strings.removePrefix "/run/" cfg.socketsDir; | ||
80 | description = '' | ||
81 | Adjusted Mastodon sockets directory for systemd | ||
82 | ''; | ||
83 | readOnly = true; | ||
84 | }; | ||
65 | sockets = lib.mkOption { | 85 | sockets = lib.mkOption { |
66 | type = lib.types.attrsOf lib.types.path; | 86 | type = lib.types.attrsOf lib.types.path; |
67 | default = { | 87 | default = { |
@@ -122,6 +142,9 @@ in | |||
122 | TimeoutSec = 15; | 142 | TimeoutSec = 15; |
123 | Type = "simple"; | 143 | Type = "simple"; |
124 | WorkingDirectory = cfg.workdir; | 144 | WorkingDirectory = cfg.workdir; |
145 | StateDirectory = cfg.systemdStateDirectory; | ||
146 | RuntimeDirectory = cfg.systemdRuntimeDirectory; | ||
147 | RuntimeDirectoryPreserve = "yes"; | ||
125 | }; | 148 | }; |
126 | 149 | ||
127 | unitConfig.RequiresMountsFor = cfg.dataDir; | 150 | unitConfig.RequiresMountsFor = cfg.dataDir; |
@@ -155,6 +178,9 @@ in | |||
155 | TimeoutSec = 60; | 178 | TimeoutSec = 60; |
156 | Type = "simple"; | 179 | Type = "simple"; |
157 | WorkingDirectory = cfg.workdir; | 180 | WorkingDirectory = cfg.workdir; |
181 | StateDirectory = cfg.systemdStateDirectory; | ||
182 | RuntimeDirectory = cfg.systemdRuntimeDirectory; | ||
183 | RuntimeDirectoryPreserve = "yes"; | ||
158 | }; | 184 | }; |
159 | 185 | ||
160 | unitConfig.RequiresMountsFor = cfg.dataDir; | 186 | unitConfig.RequiresMountsFor = cfg.dataDir; |
@@ -184,6 +210,9 @@ in | |||
184 | TimeoutSec = 15; | 210 | TimeoutSec = 15; |
185 | Type = "simple"; | 211 | Type = "simple"; |
186 | WorkingDirectory = cfg.workdir; | 212 | WorkingDirectory = cfg.workdir; |
213 | StateDirectory = cfg.systemdStateDirectory; | ||
214 | RuntimeDirectory = cfg.systemdRuntimeDirectory; | ||
215 | RuntimeDirectoryPreserve = "yes"; | ||
187 | }; | 216 | }; |
188 | 217 | ||
189 | unitConfig.RequiresMountsFor = cfg.dataDir; | 218 | unitConfig.RequiresMountsFor = cfg.dataDir; |
@@ -192,8 +221,7 @@ in | |||
192 | system.activationScripts.mastodon = { | 221 | system.activationScripts.mastodon = { |
193 | deps = [ "users" ]; | 222 | deps = [ "users" ]; |
194 | text = '' | 223 | text = '' |
195 | install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.socketsDir} | 224 | install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir}/tmp/cache |
196 | install -m 0755 -o ${cfg.user} -g ${cfg.group} -d ${cfg.dataDir} ${cfg.dataDir}/tmp/cache | ||
197 | ''; | 225 | ''; |
198 | }; | 226 | }; |
199 | 227 | ||