|
8 | 8 | cfg = config.services.buildbot-nix.master; |
9 | 9 | inherit (lib) mkRemovedOptionModule mkRenamedOptionModule; |
10 | 10 |
|
11 | | - optionsCachix = options.services.buildbot-nix.master.cachix; |
12 | | - |
13 | 11 | interpolateType = |
14 | 12 | lib.mkOptionType { |
15 | 13 | name = "interpolate"; |
|
164 | 162 | description = "Cachix name"; |
165 | 163 | }; |
166 | 164 |
|
| 165 | + auth = lib.mkOption { |
| 166 | + type = lib.types.attrTag { |
| 167 | + signingKey = lib.mkOption { |
| 168 | + description = '' |
| 169 | + Use a signing key to authenticate with Cachix. |
| 170 | + ''; |
| 171 | + |
| 172 | + type = lib.types.submodule { |
| 173 | + options.file = lib.mkOption { |
| 174 | + type = lib.types.path; |
| 175 | + description = '' |
| 176 | + Path to a file containing the signing key. |
| 177 | + ''; |
| 178 | + }; |
| 179 | + }; |
| 180 | + }; |
| 181 | + |
| 182 | + authToken = lib.mkOption { |
| 183 | + description = '' |
| 184 | + Use an authentication token to authenticate with Cachix. |
| 185 | + ''; |
| 186 | + |
| 187 | + type = lib.types.submodule { |
| 188 | + options.file = lib.mkOption { |
| 189 | + type = lib.types.path; |
| 190 | + description = '' |
| 191 | + Path to a file containing the authentication token. |
| 192 | + ''; |
| 193 | + }; |
| 194 | + }; |
| 195 | + }; |
| 196 | + }; |
| 197 | + }; |
| 198 | + |
167 | 199 | signingKeyFile = lib.mkOption { |
168 | | - type = lib.types.path; |
| 200 | + type = lib.types.nullOr lib.types.path; |
| 201 | + default = null; |
| 202 | + visible = false; |
169 | 203 | description = "Cachix signing key"; |
170 | 204 | }; |
171 | 205 |
|
172 | 206 | authTokenFile = lib.mkOption { |
173 | | - type = lib.types.str; |
| 207 | + type = lib.types.nullOr lib.types.path; |
| 208 | + default = null; |
| 209 | + visible = false; |
174 | 210 | description = "Cachix auth token"; |
175 | 211 | }; |
176 | 212 | }; |
|
365 | 401 | isSystemUser = true; |
366 | 402 | }; |
367 | 403 |
|
| 404 | + services.buildbot-nix.master.cachix.auth = lib.mkIf (cfg.cachix.authTokenFile != null || cfg.cachix.signingKeyFile != null) |
| 405 | + (if (cfg.cachix.authTokenFile != null) then |
| 406 | + lib.warn |
| 407 | + "Obsolete option `services.buildbot-nix.master.cachix.authTokenFile' is used. It was renamed to `services.buildbot-nix.master.cachix.auth.authToken.file'." |
| 408 | + { authToken.file = cfg.cachix.authTokenFile; } |
| 409 | + else if (cfg.cachix.signingKeyFile != null) then |
| 410 | + lib.warn |
| 411 | + "Obsolete option `services.buildbot-nix.master.cachix.signingKeyFile' is used. It was renamed to `services.buildbot-nix.master.cachix.auth.signingKey.file'." |
| 412 | + { signingKey.file = cfg.cachix.signingKeyFile; } |
| 413 | + else |
| 414 | + throw "Impossible, guarded by mkIf."); |
| 415 | + |
368 | 416 | assertions = [ |
369 | 417 | { |
370 | 418 | assertion = |
371 | 419 | let |
372 | | - allIsNull = lib.all (x: x == null); |
| 420 | + isNull = x: x == null; |
373 | 421 | in |
374 | | - optionsCachix.enable.value || lib.foldr (a: b: a && b) true [ |
375 | | - (optionsCachix.name.isDefined -> allIsNull optionsCachix.name.definitions) |
376 | | - (optionsCachix.signingKeyFile.isDefined -> allIsNull optionsCachix.signingKeyFile.definitions) |
377 | | - (optionsCachix.authTokenFile.isDefined -> allIsNull optionsCachix.authTokenFile.definitions) |
378 | | - ]; |
| 422 | + isNull cfg.cachix.authTokenFile && isNull cfg.cachix.signingKeyFile || |
| 423 | + isNull cfg.cachix.authTokenFile && cfg.cachix.enable || |
| 424 | + isNull cfg.cachix.signingKeyFile && cfg.cachix.enable; |
379 | 425 | message = '' |
380 | | - The semantics of `options.services.buildbot-nix.master.cachix` recently changed slightly, the options |
381 | | - `name`, `signingKeyFile`, and `authTokenFile` are no longer null-able. To enable Cachix support use: |
382 | | - `options.services.buildbot-nix.master.cachix.enable = True`. |
| 426 | + The semantics of `options.services.buildbot-nix.master.cachix` recently changed |
| 427 | + slightly, the option `name` is no longer null-able. To enable Cachix support |
| 428 | + use `services.buildbot-nix.master.cachix.enable = true`. |
| 429 | +
|
| 430 | + Furthermore, the options `services.buildbot-nix.master.cachix.authTokenFile` and |
| 431 | + `services.buildbot-nix.master.cachix.signingKeyFile` were renamed to |
| 432 | + `services.buildbot-nix.master.cachix.auth.authToken.file` and |
| 433 | + `services.buildbot-nix.master.cachix.auth.signingKey.file` respectively. |
383 | 434 | ''; |
384 | 435 | } |
385 | 436 | { |
|
450 | 501 | else |
451 | 502 | { |
452 | 503 | name = cfg.cachix.name; |
453 | | - signing_key_file = if optionsCachix.signingKeyFile.isDefined then cfg.cachix.signingKeyFile else null; |
454 | | - auth_token_file = if optionsCachix.signingKeyFile.isDefined then cfg.cachix.authTokenFile else null; |
| 504 | + signing_key_file = |
| 505 | + if cfg.cachix.auth ? "signingKey" then |
| 506 | + cfg.cachix.auth.signingKey.file |
| 507 | + else |
| 508 | + null; |
| 509 | + auth_token_file = |
| 510 | + if cfg.cachix.auth ? "authToken" then |
| 511 | + cfg.cachix.authTokenFile |
| 512 | + else |
| 513 | + null; |
455 | 514 | }; |
456 | 515 | gitea = if !cfg.gitea.enable then |
457 | 516 | null |
|
560 | 619 | ) |
561 | 620 | ++ lib.optional (cfg.authBackend == "gitea") "gitea-oauth-secret:${cfg.gitea.oauthSecretFile}" |
562 | 621 | ++ lib.optional (cfg.authBackend == "github") "github-oauth-secret:${cfg.github.oauthSecretFile}" |
563 | | - ++ lib.optionals cfg.cachix.enable [ |
| 622 | + ++ lib.optional (cfg.cachix.enable && cfg.cachix ? "signingKey") |
564 | 623 | "cachix-signing-key:${builtins.toString cfg.cachix.signingKeyFile}" |
| 624 | + ++ lib.optional (cfg.cachix.enable && cfg.cachix ? "authToken") |
565 | 625 | "cachix-auth-token:${builtins.toString cfg.cachix.authTokenFile}" |
566 | | - ] |
567 | 626 | ++ lib.optionals cfg.gitea.enable [ |
568 | 627 | "gitea-token:${cfg.gitea.tokenFile}" |
569 | 628 | "gitea-webhook-secret:${cfg.gitea.webhookSecretFile}" |
|
0 commit comments