nixfiles/hosts/vault/secrets.nix

74 lines
2.1 KiB
Nix
Raw Normal View History

2022-12-04 16:10:00 +00:00
{...}: {
services.secrets = {
enable = true;
2023-09-20 18:04:33 +01:00
vaultURL = "http://127.0.0.1:8200";
2023-09-18 03:56:58 +01:00
vaultLogin = {
enable = true;
loginUsername = "vault";
};
autoSecrets = {
2023-09-20 18:08:00 +01:00
# won't work when sealed
enable = false;
2023-09-18 03:56:58 +01:00
};
requiredVaultPaths = [
"private-public-keys/data/ssh/root@vault"
"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;
};
ssh_host_ed25519_key = {
path = "/etc/ssh/ssh_host_ed25519_key";
permissions = "600";
fetchScript = ''
[ ! -d "$SYSROOT/etc/ssh" ] && mkdir -p "$SYSROOT/etc/ssh/"
simple_get "/private-public-keys/ssh/root@vault" .private | base64 -d > "$secretFile"
'';
};
ssh_host_ed25519_key_pub = {
path = "/etc/ssh/ssh_host_ed25519_key.pub";
permissions = "600";
fetchScript = ''
[ ! -d "$SYSROOT/etc/ssh" ] && mkdir -p "$SYSROOT/etc/ssh/"
simple_get "/private-public-keys/ssh/root@vault" .private | base64 -d > "$secretFile"
'';
};
2023-09-20 18:44:24 +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
initrd_ssh_host_ed25519_key = {
path = "/initrd_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
}