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
|
let
|
||||||
inherit (lib) attrValues elem mkOption;
|
inherit (lib) attrValues elem;
|
||||||
inherit (lib.attrsets) concatMapAttrs optionalAttrs;
|
inherit (lib.attrsets) concatMapAttrs optionalAttrs;
|
||||||
inherit (lib.strings) removeSuffix;
|
inherit (lib.strings) removeSuffix;
|
||||||
|
|
||||||
|
@ -16,19 +16,7 @@ let
|
||||||
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
imports = [ ./options.nix ];
|
||||||
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.
|
|
||||||
'';
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
config =
|
config =
|
||||||
let
|
let
|
||||||
|
@ -46,9 +34,14 @@ in
|
||||||
nixos.module = {
|
nixos.module = {
|
||||||
imports = [
|
imports = [
|
||||||
inputs.agenix.nixosModules.default
|
inputs.agenix.nixosModules.default
|
||||||
|
./options.nix
|
||||||
./nixosConfiguration
|
./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
|
## 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
|
## readable with this host's public key, and add them correctly to the
|
||||||
## configuration as `age.secrets.<name>.file`.
|
## configuration as `age.secrets.<name>.file`.
|
|
@ -21,7 +21,7 @@ let
|
||||||
type = providers.local.exec;
|
type = providers.local.exec;
|
||||||
imports = [
|
imports = [
|
||||||
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
inputs.nixops4-nixos.modules.nixops4Resource.nixos
|
||||||
./common/procolixResource.nix
|
./common/resource.nix
|
||||||
(./. + "/${vmName}")
|
(./. + "/${vmName}")
|
||||||
];
|
];
|
||||||
procolixVm.name = vmName;
|
procolixVm.name = vmName;
|
||||||
|
|
Loading…
Add table
Reference in a new issue