{ pkgs, lib, config, ... }:
let
  cfg = config.mods.server.vault;
  port = config.mods.server.nginx.ports.vault;
in with lib; {
  options.mods.server = {
    vault = {
      enable = mkEnableOption {
        default = false;
        description = "enables vaultwarden server";
      };
    };
  };

  config = mkIf cfg.enable {
    services.vaultwarden = {
      enable = true;
      config = {
        ROCKET_ADDRESS = "0.0.0.0";
        ROCKET_PORT = port;
      };
    };
  };
}
