nixfiles/hosts/vault/secrets.nix

53 lines
1.4 KiB
Nix
Raw Normal View History

2022-12-04 16:10:00 +00:00
{...}: {
services.secrets = {
enable = true;
2023-09-18 03:56:58 +01:00
vaultLogin = {
enable = true;
loginUsername = "vault";
};
autoSecrets = {
enable = true;
};
requiredVaultPaths = [
2023-09-20 15:59:18 +01:00
"/private-public-keys/data/ssh/root@vault-decrypt"
2023-09-20 15:46:20 +01:00
"private-public-keys/data/restic/Vault"
"api-keys/data/storage/restic/Vault"
];
secrets = {
2023-09-18 03:56:58 +01:00
vault_password = {
manual = true;
};
2023-09-20 15:46:20 +01:00
# this doesn't need to be a secret and can be generated at install time
# but it makes it easier to install.
# it's stored in /nix store anyway
ssh_host_ed25519_key = {
2023-09-20 15:59:18 +01:00
path = "/ssh_host_ed25519_key";
2023-09-20 15:46:20 +01:00
permissions = "600";
fetchScript = ''
simple_get "/private-public-keys/ssh/root@vault-decrypt" .private | base64 -d > "$secretFile"
2023-09-20 15:46:20 +01:00
'';
};
restic_password = {
fetchScript = ''
simple_get "/private-public-keys/restic/Vault" .password > "$secretFile"
'';
};
restic_env = {
fetchScript = ''
RESTIC_USERNAME=$(simple_get "/api-keys/storage/restic/Vault" .username)
RESTIC_PASSWORD=$(simple_get "/api-keys/storage/restic/Vault" .password)
echo "RESTIC_REPOSITORY=rest:https://$RESTIC_USERNAME:$RESTIC_PASSWORD@storage-restic.owo.monster/Vault" > "$secretFile"
'';
};
};
};
2022-11-02 10:24:47 +00:00
}