Skip to content

Commit 3d17b5a

Browse files
committed
misc
1 parent 7c83e3c commit 3d17b5a

3 files changed

Lines changed: 51 additions & 12 deletions

File tree

hosts/equinox/config.nix

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,13 @@ in {
2222
};
2323
};
2424
services = {
25-
vaultwarden.enable = true;
25+
vaultwarden = {
26+
enable = true;
27+
consulServerAddresses = [ "192.168.25.131" ];
28+
};
2629
vault = {
2730
enable = true;
28-
consulServerAddress = "192.168.25.131";
31+
consulServerAddresses = [ "192.168.25.131" ];
2932
};
3033
};
3134
apps.tools.git.enable = true;

modules/services/vault.nix

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{ lib, pkgs, secrets, ... }@args:
22
lib.mkModule args "ioga.services.vault" {
3-
options = with lib; { consulServerAddress = mkOpt' types.str ""; };
3+
options = with lib; {
4+
consulServerAddresses = mkOpt' (types.listOf types.str) [ ];
5+
};
46
config = { cfg }: {
57
systemd.services.vault.serviceConfig.EnvironmentFile =
68
"/run/secrets/vault/environment"; # only way to get the secret into the service
@@ -35,7 +37,7 @@ lib.mkModule args "ioga.services.vault" {
3537
enable = true;
3638
extraConfig = {
3739
server = false;
38-
retry_join = [ cfg.consulServerAddress ];
40+
retry_join = cfg.consulServerAddresses;
3941
bind_addr = ''{{ GetPrivateInterfaces | attr "address" }}'';
4042
services = [{
4143
name = "vault";

modules/services/vaultwarden.nix

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,47 @@
1-
{ lib, colors, pkgs, ... }@args:
1+
{ lib, colors, pkgs, secrets, ... }@args:
22
lib.mkModule args "ioga.services.vaultwarden" {
3+
options = with lib; {
4+
consulServerAddresses = mkOpt' (types.listOf types.str) [ ];
5+
};
36
config = { cfg }: {
4-
services.vaultwarden = {
5-
enable = true;
6-
# Use the full URL for the domain, including the protocol
7-
config = {
8-
DOMAIN = "http://192.168.25.145:8222";
9-
ROCKET_ADDRESS = "0.0.0.0"; # Listen on all network interfaces
10-
ROCKET_PORT = 8222; # Default NixOS port for Vaultwarden
7+
secrets.vaultwarden = { };
8+
services = {
9+
vaultwarden = {
10+
enable = true;
11+
config = {
12+
DOMAIN = "http://192.168.25.145:8222";
13+
ROCKET_ADDRESS = "0.0.0.0"; # Listen on all network interfaces
14+
ROCKET_PORT = 8222; # Default NixOS port for Vaultwarden
15+
};
16+
};
17+
18+
consul = {
19+
enable = true;
20+
extraConfig = {
21+
server = false;
22+
retry_join = cfg.consulServerAddresses;
23+
bind_addr = ''{{ GetPrivateInterfaces | attr "address" }}'';
24+
services = [{
25+
name = "vaultwarden";
26+
port = 8222;
27+
tags = [ "public" ];
28+
check = {
29+
http = "http://127.0.0.1:8222/alive";
30+
interval = "10s";
31+
timeout = "1s";
32+
};
33+
}];
34+
};
35+
};
36+
37+
restic.backups.vaultwarden = {
38+
initialize = true;
39+
environmentFile = "${secrets.vaultwarden}/environment";
40+
passwordFile = "${secrets.vaultwarden}/password";
41+
paths = [ "/var/lib/vaultwarden" ];
42+
43+
timerConfig.OnCalendar = "hourly";
44+
pruneOpts = [ "--keep-daily 7" "--keep-weekly 4" "--keep-monthly 6" ];
1145
};
1246
};
1347

0 commit comments

Comments
 (0)