2024-09-18 21:21:48 +02:00
|
|
|
{
|
2024-09-22 03:11:14 +02:00
|
|
|
lib,
|
2024-09-20 23:08:38 +02:00
|
|
|
namespace,
|
|
|
|
config,
|
2024-09-22 03:11:14 +02:00
|
|
|
host,
|
2024-09-18 21:21:48 +02:00
|
|
|
...
|
2024-09-20 23:08:38 +02:00
|
|
|
}: with lib; with lib.${namespace};
|
|
|
|
let
|
|
|
|
cfg = config.${namespace}.services.vaultwarden;
|
|
|
|
in {
|
2024-09-24 00:44:19 +02:00
|
|
|
options.${namespace}.services.vaultwarden = { enable = mkEnableOption "Enable Vaultwarden, a self-hostable password manager."; };
|
2024-09-20 23:08:38 +02:00
|
|
|
|
|
|
|
config = mkIf cfg.enable {
|
2024-09-24 00:44:19 +02:00
|
|
|
sops.secrets.vaultwarden = {
|
|
|
|
sopsFile = lib.snowfall.fs.get-file "secrets/vaultwarden.service.env";
|
2024-09-24 00:55:09 +02:00
|
|
|
format = "dotenv";
|
2024-09-24 00:44:19 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
# Ensure directories exists before OCI container is launched.
|
|
|
|
systemd.tmpfiles.rules = [
|
|
|
|
"d /var/lib/containers/vaultwarden/data 0700 root root -"
|
|
|
|
];
|
|
|
|
|
|
|
|
# "Inspired" by BreakingTV @ github.com
|
2024-09-20 23:08:38 +02:00
|
|
|
virtualisation.oci-containers.containers.vaultwarden = {
|
|
|
|
image = "vaultwarden/server";
|
|
|
|
autoStart = true;
|
2024-09-22 03:11:14 +02:00
|
|
|
hostname = host;
|
2024-09-24 00:44:19 +02:00
|
|
|
labels = {
|
2024-09-24 00:50:19 +02:00
|
|
|
"traefik.enable" = "true";
|
2024-09-24 00:44:19 +02:00
|
|
|
"traefik.http.routers.vaultwarden.entrypoints" = "websecure";
|
|
|
|
"traefik.http.routers.vaultwarden.rule" = "Host(`vault.thevoid.cafe`)";
|
|
|
|
};
|
|
|
|
volumes = [
|
|
|
|
"/var/lib/containers/vaultwarden/data:/data:rw"
|
|
|
|
];
|
|
|
|
environmentFiles = [
|
|
|
|
config.sops.secrets.vaultwarden.path
|
|
|
|
];
|
|
|
|
extraOptions = ["--network=proxy"];
|
2024-09-20 23:08:38 +02:00
|
|
|
};
|
|
|
|
};
|
2024-09-22 03:11:14 +02:00
|
|
|
}
|