2023-01-28 02:50:14 +01:00
|
|
|
{
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
stdenv,
|
|
|
|
options,
|
|
|
|
...
|
|
|
|
}: {
|
2023-01-28 18:41:31 +01:00
|
|
|
config = with lib; let
|
|
|
|
secretFiles = mapAttrsToList (_: x: x.file) config.rekey.secrets;
|
2023-01-28 20:10:55 +01:00
|
|
|
drv = import ./rekey-drv.nix pkgs config;
|
2023-01-28 02:50:14 +01:00
|
|
|
in
|
2023-01-28 18:41:31 +01:00
|
|
|
mkIf (config.rekey.secrets != {}) {
|
2023-01-28 02:50:14 +01:00
|
|
|
age = {
|
|
|
|
secrets = let
|
2023-01-28 20:10:55 +01:00
|
|
|
secretPath = "${drv}/";
|
2023-01-28 18:41:31 +01:00
|
|
|
newPath = x: "${secretPath}/${x}.age";
|
2023-01-28 02:50:14 +01:00
|
|
|
in
|
2023-01-28 18:41:31 +01:00
|
|
|
mapAttrs (name: value: value // {file = newPath name;}) config.rekey.secrets;
|
2023-01-28 02:50:14 +01:00
|
|
|
};
|
2023-02-04 21:23:43 +01:00
|
|
|
warnings = optional (! pathExists (removeSuffix ".drv" drv.drvPath)) ''
|
|
|
|
Rekeyed secrets not available.
|
|
|
|
Maybe you forgot to run "nix run '.#rekey'" to rekey them?
|
|
|
|
'';
|
2023-01-28 02:50:14 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
options = with lib; {
|
|
|
|
rekey.secrets = options.age.secrets;
|
|
|
|
rekey.pubKey = mkOption {
|
|
|
|
type = types.either types.path types.str;
|
|
|
|
description = ''
|
|
|
|
The age public key set as a recipient when rekeying.
|
|
|
|
either a path to a public key file or a string public key
|
|
|
|
**NEVER set this to a private key part**
|
|
|
|
~~This will end up in the nix store.~~
|
|
|
|
'';
|
|
|
|
example = /etc/ssh/ssh_host_ed25519_key.pub;
|
|
|
|
};
|
|
|
|
|
|
|
|
rekey.masterIdentityPaths = mkOption {
|
|
|
|
type = types.listOf types.path;
|
|
|
|
description = ''
|
|
|
|
A list of Identities used for decrypting your secrets before rekeying.
|
|
|
|
**WARING this will end up in the nix-store**
|
2023-01-28 18:41:31 +01:00
|
|
|
Only use yubikeys or password encrypted age keys
|
2023-01-28 02:50:14 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
rekey.plugins = mkOption {
|
|
|
|
type = types.listOf types.package;
|
|
|
|
default = [];
|
|
|
|
description = ''
|
|
|
|
A list of plugins that should be available in your path when rekeying.
|
|
|
|
'';
|
|
|
|
example = [pkgs.age-plugin-yubikey];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|