From 18922904df6fb3661b42f7f1ecf67752dedfd908 Mon Sep 17 00:00:00 2001 From: Rouven Seifert Date: Tue, 4 Jul 2023 14:20:55 +0200 Subject: [PATCH] vaultwarden: init module --- flake.nix | 1 + modules/vaultwarden.nix | 38 ++++++++++++++++++++++++++++++++++++++ secrets/quitte.yaml | 5 +++-- 3 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 modules/vaultwarden.nix diff --git a/flake.nix b/flake.nix index 04919d3..a743db6 100755 --- a/flake.nix +++ b/flake.nix @@ -53,6 +53,7 @@ ./modules/matrix.nix ./modules/mautrix-telegram.nix ./modules/sogo.nix + ./modules/vaultwarden.nix { fsr.enable_office_bloat = false; fsr.domain = "staging.ifsr.de"; diff --git a/modules/vaultwarden.nix b/modules/vaultwarden.nix new file mode 100644 index 0000000..dec8141 --- /dev/null +++ b/modules/vaultwarden.nix @@ -0,0 +1,38 @@ +{ config, ... }: +let + domain = "vault.${config.fsr.domain}"; +in +{ + sops.secrets."vaultwarden_env".owner = "vaultwarden"; + services.vaultwarden = { + enable = true; + dbBackend = "postgresql"; + environmentFile = config.sops.secrets."vaultwarden_env".path; + config = { + domain = "https://${domain}"; + signupsAllowed = false; + # somehow this works + databaseUrl = "postgresql://vaultwarden@%2Frun%2Fpostgresql/vaultwarden"; + rocketPort = 8000; + }; + }; + services.postgresql = { + enable = true; + ensureUsers = [ + { + name = "vaultwarden"; + ensurePermissions = { + "DATABASE vaultwarden" = "ALL PRIVILEGES"; + }; + } + ]; + ensureDatabases = [ "vaultwarden" ]; + }; + services.nginx.virtualHosts."${domain}" = { + enableACME = true; + forceSSL = true; + locations."/" = { + proxyPass = "http://127.0.0.1:${toString config.services.vaultwarden.config.rocketPort}"; + }; + }; +} diff --git a/secrets/quitte.yaml b/secrets/quitte.yaml index 70daf77..c3f0478 100644 --- a/secrets/quitte.yaml +++ b/secrets/quitte.yaml @@ -17,6 +17,7 @@ mediawiki: ldapprovider: ENC[AES256_GCM,data:CPsrWmUviUpFIVVN/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Dw+bKbshHej4l3hvM/c2sHLbcPp/+vxLXqthPR+y8lf6J/QgZ8Yzw1JxFVDO8ypaWpWZZvA3HbAzRJXxk2zxg+lpmgFsyzTXLZGhvf7NdRHUmTP9OgDFt/efhxpUvDYpDinzVOuFrYJGL/4U0LLvxtGQQaQ==,iv:dUx+BsJWaiZ6MeNB+OhrSxQf+co2USjJM5rKt7OP5GI=,tag:nOVLxEyIRSNnxGa8eHMmFQ==,type:str] mautrix-telegram_env: ENC[AES256_GCM,data:2p5vYV+/vEDrrZItTcT1vxddv2tM7dLGBUmG+OXHccTzJ2UhyYpDGgUMr5KgObxvyssYBZTsvbV7QFN3sjcU/jVPx1qEUn6zyKO0HBQjrviVU3urx5zNOnCEHwDKyDrZ1Hu/CE6lpGNrtGlpewgOs/+84JZIZhC9qSuzDhN38sr4OGfMr29fMzafYC+TGHoZyA64GI9xz0KvXhwg6ci1hLtVWYEOFW2Nf8uLY8qkNLuDzA6bYx8rn3CEXoxiv0n4,iv:jmcWTyVkqu9nDc1ws2NxkMKrHPZ13i3jqDkk4Y0kejw=,tag:BjhmPc4lSbsZBmZ/q2CqGg==,type:str] +vaultwarden_env: ENC[AES256_GCM,data:X8wdQSieXfgNUqtoFRgz43jsWyrUQ1wxsM9L5iHoE8YFR5O6SzfAcjMsr4I0r2t5by/C4YorVsN5GQKyyVWS4SwelTT3UmFX89/pAUnAsUqeBZENOPEWiLNJnC3R3Xic6B1tu0OsX1X9RxR/X9EQJf/MIEdiNfhXKBxy7gZ0tDsDyze5/ZGVJX8=,iv:foByTYQw1KnB1MmwSQqmwza9PJJmdYdZbIHKrZ9vog4=,tag:8VTcOSefWmyd8ozGXHbklw==,type:str] sops: kms: [] gcp_kms: [] @@ -32,8 +33,8 @@ sops: NEJBTHE2end1RDlHRTNFYlZjTjhib2cKmQRHpBKZ2DbQ5CfOwcSPfZAm9fnnpxUk +LcR8haK//O3N2uNf9etDW3VsT5ipPucCdFU1m/v9L5tcN6ZP8WP+w== -----END AGE ENCRYPTED FILE----- - lastmodified: "2023-07-04T07:41:45Z" - mac: ENC[AES256_GCM,data:YLC02dhSSLl9C1B7wo/AJcY4a4zc1LIaA0PKH0H8uZ8I9Kh105yk4sc2cz15FVMLtkMeIdfnhmWxbnPyLbM0mA9bAYT9MQn65quEgDumr+XH0UW6m1e2S23/2fxTFH1xRWsu7/Kon/gdzLb5hf2m30eJAP7MrdpxDz28Q7ut1P4=,iv:9UC71WxpDt1bxWSu16Sc+OKpy6KmX0Ru+Q54LYuQCBU=,tag:CpNKSJem+XHimm+yzRpwaw==,type:str] + lastmodified: "2023-07-04T12:17:15Z" + mac: ENC[AES256_GCM,data:gP5HkzRPwCi4I41vOmhnRbBaBnMcZG8ao8o4MR2PkuU5jISi4Z0Mrvy04ioeRgmX3ESJ60UixbF1JJ4siB3oyZ651bLwbOhy3eaQFXHreTcZMy2TLMQRR+vWUGIooP/xCm3wFIo0qhqprzngBG319vzidxnEOJCaMzMTZyxk0dU=,iv:AlOg391SXo6H+NpS1XevJz90qMbXNS8kDVdZ4JPdzx0=,tag:53dxW47eipY7UCdjJ+hVPw==,type:str] pgp: - created_at: "2023-04-23T17:48:54Z" enc: |