summaryrefslogtreecommitdiffstats
path: root/hosts/poweredge-pro/vaultwarden.nix
blob: d79c349fc635e7d885de580d9aca3db2de934319 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
{ config, ... }: {
	# Secrets
	sops.secrets.vaultwarden-env = { sopsFile = ./resources/secrets/vaultwarden.yaml; key = "environment"; };

	# Container
	containers.vaultwarden = {
		autoStart = true;
		privateNetwork = true;
		hostBridge = "br-lan0";
		localMacAddress = "02:00:00:00:77:17";
		ephemeral = true;

		# Persist db
		bindMounts."/var/lib/vaultwarden" = {
			hostPath = "/nix/persist/vaultwarden";
			isReadOnly = false;
		};

		# Bind secrets
		bindMounts."/run/secrets/vaultwarden.env" = {
			hostPath = config.sops.secrets.vaultwarden-env.path;
			isReadOnly = true;
		};

		config = { ... }: {
			networking.interfaces.eth0.useDHCP = true;
			networking.firewall.allowedTCPPorts = [ 8000 ];  # Vaultwarden

			# Vaultwarden
			services.vaultwarden = {
				enable = true;
				environmentFile = "/run/secrets/vaultwarden.env";
				config.ROCKET_ADDRESS = "0.0.0.0";
			};

			system.stateVersion = "26.05";
		};
	};
}