|
141 | 141 | default = shell { ci = false; }; |
142 | 142 | ci = shell { ci = true; }; |
143 | 143 | }; |
144 | | - }) // { |
145 | | - nixosModules.default = { config, ... }: |
146 | | - with nixpkgs-matrix.lib; { |
147 | | - options = { |
148 | | - services.polykey = { |
149 | | - enable = mkEnableOption |
150 | | - "Enable the Polykey agent. Users with the `polykey` group or root permissions will be able to manage the agent."; |
151 | | - |
152 | | - passwordFilePath = mkOption { |
153 | | - type = with types; uniq str; |
154 | | - description = '' |
155 | | - The path to the Polykey password file. This is required to be set for the module to work, otherwise this module will fail. |
156 | | - ''; |
157 | | - }; |
158 | | - |
159 | | - recoveryCodeFilePath = mkOption { |
160 | | - type = with types; uniq str; |
161 | | - default = ""; |
162 | | - description = '' |
163 | | - The path to the Polykey recovery code file. This is not required, but if set will read a recovery code from the provided path to bootstrap a new state with. |
164 | | - ''; |
165 | | - }; |
166 | | - |
167 | | - recoveryCodeOutPath = mkOption { |
168 | | - type = with types; uniq str; |
169 | | - description = '' |
170 | | - The path to the Polykey recovery code file output location. |
171 | | - ''; |
172 | | - }; |
173 | | - |
174 | | - statePath = mkOption { |
175 | | - type = with types; uniq str; |
176 | | - default = "/var/lib/polykey"; |
177 | | - description = |
178 | | - "The path to the Polykey node state directory. Will default to `/var/lib/polykey`, but can be overwritten to a custom path."; |
179 | | - }; |
180 | | - }; |
181 | | - programs.polykey = { |
182 | | - enable = mkEnableOption "Enable the per-user Polykey agent."; |
183 | | - |
184 | | - passwordFilePath = mkOption { |
185 | | - type = with types; uniq str; |
186 | | - description = '' |
187 | | - The path to the Polykey password file. This is required to be set for the module to work, otherwise this module will fail. |
188 | | - ''; |
189 | | - }; |
190 | | - |
191 | | - recoveryCodeFilePath = mkOption { |
192 | | - type = with types; uniq str; |
193 | | - default = ""; |
194 | | - description = '' |
195 | | - The path to the Polykey recovery code file. This is not required, but if set will read a recovery code from the provided path to bootstrap a new state with. |
196 | | - ''; |
197 | | - }; |
198 | | - |
199 | | - recoveryCodeOutPath = mkOption { |
200 | | - type = with types; uniq str; |
201 | | - description = '' |
202 | | - The path to the Polykey recovery code file output location. |
203 | | - ''; |
204 | | - }; |
205 | | - |
206 | | - statePath = mkOption { |
207 | | - type = with types; uniq str; |
208 | | - default = "%h/.local/share/polykey"; |
209 | | - description = |
210 | | - "The path to the Polykey node state directory. Will default to `$HOME/.local/share/polykey`, but can be overwritten to a custom path."; |
211 | | - }; |
212 | | - }; |
213 | | - }; |
214 | | - config = mkMerge [ |
215 | | - (mkIf config.services.polykey.enable { |
216 | | - users.groups.polykey = { }; |
217 | | - |
218 | | - environment.systemPackages = |
219 | | - [ self.outputs.packages.${buildSystem}.default ]; |
220 | | - |
221 | | - system.activationScripts.makeAgentPaths = '' |
222 | | - mkdir -p ${config.services.polykey.statePath} |
223 | | - chgrp -R polykey ${config.services.polykey.statePath} |
224 | | - chmod 770 ${config.services.polykey.statePath} |
225 | | - ''; |
226 | | - |
227 | | - systemd.services.polykey = { |
228 | | - description = "Polykey Agent"; |
229 | | - wantedBy = [ "multi-user.target" ]; |
230 | | - after = [ "network.target" ]; |
231 | | - serviceConfig = { |
232 | | - User = "root"; |
233 | | - Group = "polykey"; |
234 | | - PermissionsStartOnly = true; |
235 | | - LoadCredential = [ |
236 | | - "password:${config.services.polykey.passwordFilePath}" |
237 | | - ]; |
238 | | - ExecStartPre = '' |
239 | | - -${ |
240 | | - self.outputs.packages.${buildSystem}.default |
241 | | - }/bin/polykey \ |
242 | | - --password-file ''${CREDENTIALS_DIRECTORY}/password \ |
243 | | - --node-path ${config.services.polykey.statePath} \ |
244 | | - bootstrap ${ |
245 | | - lib.optionalString |
246 | | - (config.services.polykey.recoveryCodeFilePath != "") |
247 | | - "-rcf ${config.services.polykey.recoveryCodeFilePath}" |
248 | | - }\ |
249 | | - --recovery-code-out-file ${config.services.polykey.recoveryCodeOutPath} |
250 | | - ''; |
251 | | - ExecStart = '' |
252 | | - ${ |
253 | | - self.outputs.packages.${buildSystem}.default |
254 | | - }/bin/polykey \ |
255 | | - --password-file ''${CREDENTIALS_DIRECTORY}/password \ |
256 | | - --node-path ${config.services.polykey.statePath} \ |
257 | | - agent start \ |
258 | | - --recovery-code-out-file ${config.services.polykey.recoveryCodeOutPath} |
259 | | - ''; |
260 | | - }; |
261 | | - }; |
262 | | - }) |
263 | | - (mkIf config.programs.polykey.enable { |
264 | | - environment.systemPackages = |
265 | | - [ self.outputs.packages.${buildSystem}.default ]; |
266 | | - |
267 | | - system.activationScripts.makeUserAgentPaths = '' |
268 | | - mkdir -p ${config.programs.polykey.statePath} |
269 | | - ''; |
270 | | - |
271 | | - systemd.user.services.polykey = { |
272 | | - description = "Polykey Agent"; |
273 | | - wantedBy = [ "default.target" ]; |
274 | | - after = [ "network.target" ]; |
275 | | - serviceConfig = { |
276 | | - ExecStartPre = '' |
277 | | - -${ |
278 | | - self.outputs.packages.${buildSystem}.default |
279 | | - }/bin/polykey \ |
280 | | - --password-file ${config.programs.polykey.passwordFilePath} \ |
281 | | - --node-path ${config.programs.polykey.statePath} \ |
282 | | - bootstrap ${ |
283 | | - lib.optionalString |
284 | | - (config.programs.polykey.recoveryCodeFilePath != "") |
285 | | - "-rcf ${config.programs.polykey.recoveryCodeFilePath}" |
286 | | - }\ |
287 | | - --recovery-code-out-file ${config.programs.polykey.recoveryCodeOutPath} |
288 | | - ''; |
289 | | - ExecStart = '' |
290 | | - ${ |
291 | | - self.outputs.packages.${buildSystem}.default |
292 | | - }/bin/polykey \ |
293 | | - --password-file ${config.programs.polykey.passwordFilePath} \ |
294 | | - --node-path ${config.programs.polykey.statePath} \ |
295 | | - agent start \ |
296 | | - --recovery-code-out-file ${config.programs.polykey.recoveryCodeOutPath} |
297 | | - ''; |
298 | | - }; |
299 | | - }; |
300 | | - }) |
301 | | - ]; |
302 | | - }; |
303 | | - }; |
| 144 | + }) // (let |
| 145 | + modules = import ./modules.nix { |
| 146 | + inherit nixpkgs-matrix; |
| 147 | + outputs = self.outputs; |
| 148 | + system = "x86_64-linux"; |
| 149 | + }; |
| 150 | + in { |
| 151 | + nixosModules.default = modules.polykey; |
| 152 | + homeModules.default = modules.polykey-home; |
| 153 | + }); |
304 | 154 | } |
0 commit comments