massicot: add vaultwarden server

This commit is contained in:
xinyangli 2023-12-17 14:55:53 +08:00
parent 0b772880b5
commit 079ece082a
4 changed files with 56 additions and 2 deletions

View file

@ -85,11 +85,12 @@
};
massicot = { name, nodes, pkgs, ... }: with inputs; {
deployment.targetHost = "***REMOVED***";
deployment.targetUser = "root";
deployment.targetHost = "49.13.13.122";
deployment.targetUser = "xin";
imports = [
{ nixpkgs.system = "aarch64-linux"; }
self.nixosModules.default
machines/massicot
];
};

View file

@ -6,6 +6,11 @@ in
networking.firewall.allowedTCPPorts = [ 80 443 2222 8448 ];
networking.firewall.allowedUDPPorts = [ 80 443 8448 ];
custom.vaultwarden = {
enable = true;
domain = "vaultwarden.xinyang.life";
};
fileSystems = builtins.listToAttrs (map (share: {
name = "/mnt/storage/${share}";
value = {

View file

@ -2,5 +2,6 @@
{
imports = [
./restic.nix
./vaultwarden.nix
];
}

View file

@ -0,0 +1,47 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.custom.vaultwarden;
in
{
options = {
custom.vaultwarden = {
enable = mkEnableOption "vaultwarden server";
domain = mkOption {
type = types.str;
default = "bitwarden.example.com";
description = "Domain name of the vaultwarden server";
};
caddy = mkOption {
type = types.bool;
default = true;
description = "Enable Caddy as reverse proxy";
};
# TODO: mailserver support
};
};
config = {
services.vaultwarden = mkIf cfg.enable {
enable = true;
dbBackend = "sqlite";
config = {
DOMAIN = "https://${cfg.domain}";
SIGNUPS_ALLOWED = false;
ROCKET_ADDRESS = "127.0.0.1";
ROCKET_PORT = 8222;
ROCKET_LOG = "critical";
};
};
services.caddy = mkIf cfg.caddy {
enable = true;
virtualHosts."https://${cfg.domain}".extraConfig = ''
reverse_proxy ${config.services.vaultwarden.config.ROCKET_ADDRESS}:${toString config.services.vaultwarden.config.ROCKET_PORT}
'';
};
};
}