2022-12-04 16:10:00 +00:00
|
|
|
{...}: {
|
2022-11-17 22:25:41 +00:00
|
|
|
services.secrets = {
|
|
|
|
enable = true;
|
2023-09-14 13:54:56 +01:00
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2023-09-14 13:54:56 +01:00
|
|
|
requiredVaultPaths = [
|
2023-09-21 16:59:51 +01:00
|
|
|
"private-public-keys/data/ssh/root@vault"
|
|
|
|
"private-public-keys/data/ssh/root@vault-decrypt"
|
2023-09-20 15:46:20 +01:00
|
|
|
|
2023-09-14 13:54:56 +01:00
|
|
|
"private-public-keys/data/restic/Vault"
|
|
|
|
|
|
|
|
"api-keys/data/storage/restic/Vault"
|
|
|
|
];
|
|
|
|
|
2022-11-17 22:25:41 +00:00
|
|
|
secrets = {
|
2023-09-18 03:56:58 +01:00
|
|
|
vault_password = {
|
|
|
|
manual = true;
|
|
|
|
};
|
|
|
|
|
2023-09-21 05:06:27 +01:00
|
|
|
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
|
2023-09-21 05:06:27 +01:00
|
|
|
initrd_ssh_host_ed25519_key = {
|
|
|
|
path = "/initrd_ssh_host_ed25519_key";
|
2023-09-20 15:46:20 +01:00
|
|
|
permissions = "600";
|
|
|
|
fetchScript = ''
|
2023-09-20 17:31:36 +01:00
|
|
|
simple_get "/private-public-keys/ssh/root@vault-decrypt" .private | base64 -d > "$secretFile"
|
2023-09-20 15:46:20 +01:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2022-11-17 22:25:41 +00:00
|
|
|
restic_password = {
|
|
|
|
fetchScript = ''
|
2023-09-11 23:22:18 +01:00
|
|
|
simple_get "/private-public-keys/restic/Vault" .password > "$secretFile"
|
2022-11-17 22:25:41 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
restic_env = {
|
|
|
|
fetchScript = ''
|
|
|
|
RESTIC_USERNAME=$(simple_get "/api-keys/storage/restic/Vault" .username)
|
|
|
|
RESTIC_PASSWORD=$(simple_get "/api-keys/storage/restic/Vault" .password)
|
2023-09-11 23:22:18 +01:00
|
|
|
echo "RESTIC_REPOSITORY=rest:https://$RESTIC_USERNAME:$RESTIC_PASSWORD@storage-restic.owo.monster/Vault" > "$secretFile"
|
2022-11-17 22:25:41 +00:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2022-11-02 10:24:47 +00:00
|
|
|
}
|