diff --git a/infra/common/options.nix b/infra/common/options.nix new file mode 100644 index 0000000..65bed82 --- /dev/null +++ b/infra/common/options.nix @@ -0,0 +1,21 @@ +{ lib, ... }: + +let + inherit (lib) mkOption; + +in +{ + options = { + procolixVm = { + name = mkOption { }; + host = mkOption { }; + + hostPublicKey = mkOption { + description = '' + The host public key of the machine. It is used in particular + to filter Age secrets and only keep the relevant ones. + ''; + }; + }; + }; +} diff --git a/infra/common/procolixResource.nix b/infra/common/resource.nix similarity index 78% rename from infra/common/procolixResource.nix rename to infra/common/resource.nix index e08edfc..fe7a5d3 100644 --- a/infra/common/procolixResource.nix +++ b/infra/common/resource.nix @@ -6,7 +6,7 @@ }: let - inherit (lib) attrValues elem mkOption; + inherit (lib) attrValues elem; inherit (lib.attrsets) concatMapAttrs optionalAttrs; inherit (lib.strings) removeSuffix; @@ -16,19 +16,7 @@ let in { - options = { - procolixVm = { - name = mkOption { }; - host = mkOption { }; - - hostPublicKey = mkOption { - description = '' - The host public key of the machine. It is used in particular - to filter Age secrets and only keep the relevant ones. - ''; - }; - }; - }; + imports = [ ./options.nix ]; config = let @@ -46,9 +34,14 @@ in nixos.module = { imports = [ inputs.agenix.nixosModules.default + ./options.nix ./nixosConfiguration ]; + ## Inject the shared options from the resource's `config` into the NixOS + ## configuration. + procolixVm = config.procolixVm; + ## Read all the secrets, filter the ones that are supposed to be ## readable with this host's public key, and add them correctly to the ## configuration as `age.secrets..file`. diff --git a/infra/flake-part.nix b/infra/flake-part.nix index 48bb26f..0896479 100644 --- a/infra/flake-part.nix +++ b/infra/flake-part.nix @@ -21,7 +21,7 @@ let type = providers.local.exec; imports = [ inputs.nixops4-nixos.modules.nixops4Resource.nixos - ./common/procolixResource.nix + ./common/resource.nix (./. + "/${vmName}") ]; procolixVm.name = vmName;