Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: 2024 Auxolotl Infrastructure Contributors |
| 2 | # SPDX-FileCopyrightText: 2024 Clicks Codes |
| 3 | # |
| 4 | # SPDX-License-Identifier: GPL-3.0-only |
| 5 | |
| 6 | { lib, inputs }: |
| 7 | let |
| 8 | inherit (inputs) deploy-rs; |
| 9 | in |
Skyler Grey | d083cf4 | 2024-06-08 23:10:24 +0000 | [diff] [blame^] | 10 | { |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 11 | ## Create deployment configuration for use with deploy-rs. |
| 12 | ## |
| 13 | ## ```nix |
| 14 | ## mkDeploy { |
| 15 | ## inherit self; |
| 16 | ## overrides = { |
| 17 | ## my-host.system.sudo = "doas -u"; |
| 18 | ## }; |
| 19 | ## } |
| 20 | ## ``` |
| 21 | ## |
| 22 | #@ { self: Flake, overrides: Attrs ? {} } -> Attrs |
Skyler Grey | d083cf4 | 2024-06-08 23:10:24 +0000 | [diff] [blame^] | 23 | deploy = { |
| 24 | mkDeploy = |
| 25 | { |
| 26 | self, |
| 27 | overrides ? { }, |
| 28 | }: |
| 29 | let |
| 30 | hosts = self.nixosConfigurations or { }; |
| 31 | names = builtins.attrNames hosts; |
| 32 | nodes = lib.foldl ( |
| 33 | result: name: |
| 34 | let |
| 35 | host = hosts.${name}; |
| 36 | user = host.config.users.infra or null; |
| 37 | inherit (host.pkgs) system; |
| 38 | in |
| 39 | result |
| 40 | // { |
| 41 | ${name} = (overrides.${name} or { }) // { |
| 42 | hostname = overrides.${name}.hostname or "${name}"; |
| 43 | profiles = (overrides.${name}.profiles or { }) // { |
| 44 | system = |
| 45 | (overrides.${name}.profiles.system or { }) |
| 46 | // { |
| 47 | path = deploy-rs.lib.${system}.activate.nixos host; |
| 48 | } |
| 49 | // { |
| 50 | user = "root"; |
| 51 | } |
| 52 | // lib.optionalAttrs host.config.clicks.security.doas.enable { sudo = "doas -u"; }; |
| 53 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 54 | }; |
Skyler Grey | d083cf4 | 2024-06-08 23:10:24 +0000 | [diff] [blame^] | 55 | } |
| 56 | ) { } names; |
| 57 | in |
| 58 | { |
| 59 | inherit nodes; |
| 60 | }; |
| 61 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 62 | } |