nixfiles/nixos/boxes/colony/vms/shill/containers/vaultwarden.nix

104 lines
2.7 KiB
Nix
Raw Normal View History

{ lib, ... }:
let
inherit (lib.my) net;
inherit (lib.my.colony) domain prefixes;
in
{
2022-03-26 14:20:30 +00:00
nixos.systems.vaultwarden = {
system = "x86_64-linux";
nixpkgs = "mine";
2022-03-26 14:20:30 +00:00
assignments = {
internal = {
name = "vaultwarden-ctr";
inherit domain;
ipv4.address = net.cidr.host 3 prefixes.ctrs.v4;
ipv6 = {
2022-05-31 21:25:51 +01:00
iid = "::3";
address = net.cidr.host 3 prefixes.ctrs.v6;
};
};
};
configuration = { lib, config, assignments, ... }:
2022-03-26 14:20:30 +00:00
let
inherit (lib) mkMerge mkIf mkForce;
inherit (lib.my) networkdAssignment;
2022-03-26 14:20:30 +00:00
vwData = "/var/lib/vaultwarden";
in
{
config = mkMerge [
{
my = {
deploy.enable = false;
2022-03-26 14:20:30 +00:00
server.enable = true;
secrets = {
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFP2mF50ENpnJnr+VTnG9P+JFPjgwvoIxCLyJPzXRpVy";
files."vaultwarden.env" = {};
2022-03-26 14:20:30 +00:00
};
firewall = {
tcp.allowed = with config.services.vaultwarden.config; [ ROCKET_PORT WEBSOCKET_PORT ];
2022-03-26 14:20:30 +00:00
};
tmproot.persistence.config.directories = [
{
directory = vwData;
user = config.users.users.vaultwarden.name;
group = config.users.groups.vaultwarden.name;
}
];
};
systemd = {
services.vaultwarden.serviceConfig.StateDirectory = mkForce "vaultwarden";
network.networks."80-container-host0" = networkdAssignment "host0" assignments.internal;
2022-03-26 14:20:30 +00:00
};
services = {
vaultwarden = {
enable = true;
config = {
DATA_FOLDER = vwData;
2022-03-26 14:20:30 +00:00
WEB_VAULT_ENABLED = true;
WEBSOCKET_ENABLED = true;
WEBSOCKET_ADDRESS = "::";
WEBSOCKET_PORT = 3012;
SIGNUPS_ALLOWED = false;
DOMAIN = "https://pass.${lib.my.pubDomain}";
ROCKET_ADDRESS = "::";
ROCKET_PORT = 80;
SMTP_HOST = "mail.nul.ie";
SMTP_FROM = "pass@nul.ie";
SMTP_FROM_NAME = "Vaultwarden";
SMTP_SECURITY = "starttls";
SMTP_PORT = 587;
SMTP_USERNAME = "pass@nul.ie";
SMTP_TIMEOUT = 15;
2023-08-06 15:09:57 +01:00
PUSH_ENABLED = true;
2022-03-26 14:20:30 +00:00
};
environmentFile = config.age.secrets."vaultwarden.env".path;
2022-03-26 14:20:30 +00:00
};
};
}
(mkIf config.my.build.isDevVM {
virtualisation = {
forwardPorts = [
{ from = "host"; host.port = 8080; guest.port = 80; }
];
};
})
];
};
};
}