56 lines
1.4 KiB
Nix
56 lines
1.4 KiB
Nix
{...}: {
|
|
services.secrets = {
|
|
enable = true;
|
|
|
|
vaultURL = "http://127.0.0.1:8200";
|
|
|
|
vaultLogin = {
|
|
enable = true;
|
|
loginUsername = "vault";
|
|
};
|
|
|
|
autoSecrets = {
|
|
# won't work when sealed
|
|
enable = false;
|
|
};
|
|
|
|
requiredVaultPaths = [
|
|
"/private-public-keys/data/ssh/root@vault-decrypt"
|
|
|
|
"private-public-keys/data/restic/Vault"
|
|
|
|
"api-keys/data/storage/restic/Vault"
|
|
];
|
|
|
|
secrets = {
|
|
vault_password = {
|
|
manual = true;
|
|
};
|
|
|
|
# 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 = {
|
|
path = "/ssh_host_ed25519_key";
|
|
permissions = "600";
|
|
fetchScript = ''
|
|
simple_get "/private-public-keys/ssh/root@vault-decrypt" .private | base64 -d > "$secretFile"
|
|
'';
|
|
};
|
|
|
|
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"
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|