forked from Fediversity/Fediversity
Share options between resource and config
This commit is contained in:
parent
8cfc943297
commit
54194cd494
3 changed files with 29 additions and 15 deletions
21
infra/common/options.nix
Normal file
21
infra/common/options.nix
Normal file
|
@ -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.
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
|
@ -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.<name>.file`.
|
|
@ -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;
|
||||
|
|
Loading…
Add table
Reference in a new issue