2022-03-26 14:20:30 +00:00
|
|
|
{
|
|
|
|
nixos.systems.vaultwarden = {
|
|
|
|
system = "x86_64-linux";
|
2022-05-29 03:30:40 +01:00
|
|
|
nixpkgs = "mine";
|
2022-03-26 14:20:30 +00:00
|
|
|
|
2022-05-29 03:30:40 +01:00
|
|
|
assignments = {
|
|
|
|
internal = {
|
|
|
|
name = "vaultwarden-ctr";
|
|
|
|
ipv4.address = "10.100.2.2";
|
|
|
|
ipv6 = rec {
|
|
|
|
iid = "::2";
|
|
|
|
address = "2a0e:97c0:4d0:bbb2${iid}";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
configuration = { lib, config, assignments, ... }:
|
2022-03-26 14:20:30 +00:00
|
|
|
let
|
|
|
|
inherit (lib) mkMerge mkIf mkForce;
|
2022-05-29 03:30:40 +01:00
|
|
|
inherit (lib.my) networkdAssignment;
|
2022-03-26 14:20:30 +00:00
|
|
|
|
|
|
|
vwData = "/var/lib/vaultwarden";
|
|
|
|
vwSecrets = "vaultwarden.env";
|
|
|
|
in
|
|
|
|
{
|
|
|
|
config = mkMerge [
|
|
|
|
{
|
|
|
|
my = {
|
|
|
|
server.enable = true;
|
|
|
|
|
|
|
|
secrets = {
|
2022-05-29 03:30:40 +01:00
|
|
|
key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAILakffcjRp6h6lxSOADOsTK5h2MCkt8hKDv0cvchM7iw";
|
2022-03-26 14:20:30 +00:00
|
|
|
files."${vwSecrets}" = {};
|
|
|
|
};
|
|
|
|
|
|
|
|
firewall = {
|
|
|
|
tcp.allowed = [ 80 3012 ];
|
|
|
|
};
|
2022-05-29 03:30:40 +01: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 = {
|
|
|
|
dataFolder = vwData;
|
|
|
|
webVaultEnabled = true;
|
|
|
|
|
|
|
|
rocketPort = 80;
|
|
|
|
websocketEnabled = true;
|
|
|
|
websocketPort = 3012;
|
|
|
|
};
|
|
|
|
environmentFile = config.age.secrets."${vwSecrets}".path;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
(mkIf config.my.build.isDevVM {
|
|
|
|
virtualisation = {
|
|
|
|
forwardPorts = [
|
|
|
|
{ from = "host"; host.port = 8080; guest.port = 80; }
|
|
|
|
];
|
|
|
|
};
|
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|