172 lines
5.3 KiB
Nix
172 lines
5.3 KiB
Nix
{pkgs, ...}: {
|
|
services.secrets = {
|
|
enable = true;
|
|
|
|
vaultLogin = {
|
|
enable = true;
|
|
loginUsername = "hetzner-vm";
|
|
};
|
|
|
|
autoSecrets = {
|
|
enable = true;
|
|
affectedSystemdServices = [
|
|
"wg-quick-wg0"
|
|
"container@music"
|
|
"container@social"
|
|
"container@quassel"
|
|
"container@piped-fi"
|
|
];
|
|
};
|
|
|
|
packages = with pkgs; [
|
|
# for music & mail passwd files
|
|
apacheHttpd
|
|
];
|
|
|
|
requiredVaultPaths = [
|
|
"api-keys/data/mpd"
|
|
"api-keys/data/music-stream"
|
|
|
|
"api-keys/data/gitlab/gitlab_pages_serve"
|
|
|
|
"api-keys/data/storage/restic/Mail"
|
|
"api-keys/data/storage/restic/Social"
|
|
"api-keys/data/storage/restic/Quassel"
|
|
|
|
"api-keys/data/chaos_mail/system"
|
|
"api-keys/data/chaos_mail/gotosocial"
|
|
|
|
"passwords/data/soulseek"
|
|
"passwords/data/slskd"
|
|
"passwords/data/mail"
|
|
|
|
"private-public-keys/data/restic/Mail"
|
|
"private-public-keys/data/restic/Social"
|
|
"private-public-keys/data/restic/Quassel"
|
|
|
|
"infra/data/private-mail-aliases"
|
|
];
|
|
|
|
secrets = {
|
|
vault_password = {
|
|
manual = true;
|
|
};
|
|
|
|
# Used directly by server
|
|
# for fetching gitlab static sites
|
|
gitlab_env = {
|
|
user = "gitlab_artifacts_sync";
|
|
group = "gitlab_artifacts_sync";
|
|
fetchScript = ''
|
|
token=$(simple_get "/api-keys/gitlab/gitlab_pages_serve" .token)
|
|
echo "GITLAB_TOKEN=$token" > "$secretFile"
|
|
'';
|
|
};
|
|
|
|
# Container: music
|
|
mpd_control_password = {
|
|
user = "mpd";
|
|
group = "mpd";
|
|
fetchScript = ''
|
|
simple_get "/api-keys/mpd" .password > "$secretFile"
|
|
'';
|
|
};
|
|
music_stream_passwd = {
|
|
user = "nginx";
|
|
group = "nginx";
|
|
fetchScript = ''
|
|
username=$(simple_get "/api-keys/music-stream" .username)
|
|
password=$(simple_get "/api-keys/music-stream" .password)
|
|
htpasswd -bc "$secretFile" "$username" "$password" 2>/dev/null
|
|
'';
|
|
};
|
|
slskd_env = {
|
|
fetchScript = ''
|
|
soulseek_password=$(simple_get "/passwords/soulseek" .password)
|
|
slskd_password=$(simple_get "/passwords/slskd" .password)
|
|
echo > "$secretFile"
|
|
echo "SLSKD_SLSK_PASSWORD=$soulseek_password" >> "$secretFile"
|
|
echo "SLSKD_PASSWORD=$slskd_password" >> "$secretFile"
|
|
'';
|
|
};
|
|
|
|
# Container: mail
|
|
mail_restic_password = {
|
|
fetchScript = ''
|
|
simple_get "/private-public-keys/restic/Mail" .password > "$secretFile"
|
|
'';
|
|
};
|
|
mail_restic_env = {
|
|
fetchScript = ''
|
|
RESTIC_USERNAME=$(simple_get "/api-keys/storage/restic/Mail" .username)
|
|
RESTIC_PASSWORD=$(simple_get "/api-keys/storage/restic/Mail" .password)
|
|
echo "RESTIC_REPOSITORY=rest:https://$RESTIC_USERNAME:$RESTIC_PASSWORD@storage-restic.owo.monster/Mail" > "$secretFile"
|
|
'';
|
|
};
|
|
private_mail_aliases = {
|
|
fetchScript = ''
|
|
kv_get "/infra/private-mail-aliases" | jq .data.data | jq -r 'to_entries|map("\(.key) \(.value.to)")[]' > "$secretFile"
|
|
'';
|
|
};
|
|
chaos_mail_passwd = {
|
|
user = "dovecot2";
|
|
group = "dovecot2";
|
|
fetchScript = ''
|
|
password=$(simple_get "/passwords/mail" .password)
|
|
htpasswd -nbB "" "$password" 2>/dev/null | cut -d: -f2 > "$secretFile"
|
|
'';
|
|
};
|
|
system_mail_passwd = {
|
|
user = "dovecot2";
|
|
group = "dovecot2";
|
|
fetchScript = ''
|
|
password=$(simple_get "/api-keys/chaos_mail/system" .password)
|
|
htpasswd -nbB "" "$password" 2>/dev/null | cut -d: -f2 > "$secretFile"
|
|
'';
|
|
};
|
|
gotosocial_mail_passwd = {
|
|
user = "dovecot2";
|
|
group = "dovecot2";
|
|
fetchScript = ''
|
|
password=$(simple_get "/api-keys/chaos_mail/gotosocial" .password)
|
|
htpasswd -nbB "" "$password" 2>/dev/null | cut -d: -f2 > "$secretFile"
|
|
'';
|
|
};
|
|
|
|
# Container: social
|
|
social_restic_password = {
|
|
fetchScript = ''
|
|
simple_get "/private-public-keys/restic/Social" .password > "$secretFile"
|
|
'';
|
|
};
|
|
social_restic_env = {
|
|
fetchScript = ''
|
|
RESTIC_USERNAME=$(simple_get "/api-keys/storage/restic/Social" .username)
|
|
RESTIC_PASSWORD=$(simple_get "/api-keys/storage/restic/Social" .password)
|
|
echo "RESTIC_REPOSITORY=rest:https://$RESTIC_USERNAME:$RESTIC_PASSWORD@storage-restic.owo.monster/Social" > "$secretFile"
|
|
'';
|
|
};
|
|
social_env_secrets = {
|
|
fetchScript = ''
|
|
smtp_password=$(simple_get "/api-keys/chaos_mail/gotosocial" .password)
|
|
echo "GTS_SMTP_PASSWORD=$smtp_password" > "$secretFile"
|
|
'';
|
|
};
|
|
|
|
# Container: quassel
|
|
quassel_restic_password = {
|
|
fetchScript = ''
|
|
simple_get "/private-public-keys/restic/Quassel" .password > "$secretFile"
|
|
'';
|
|
};
|
|
quassel_restic_env = {
|
|
fetchScript = ''
|
|
RESTIC_USERNAME=$(simple_get "/api-keys/storage/restic/Quassel" .username)
|
|
RESTIC_PASSWORD=$(simple_get "/api-keys/storage/restic/Quassel" .password)
|
|
echo "RESTIC_REPOSITORY=rest:https://$RESTIC_USERNAME:$RESTIC_PASSWORD@storage-restic.owo.monster/Quassel" > "$secretFile"
|
|
'';
|
|
};
|
|
};
|
|
};
|
|
}
|