From 327b113a07e37b558172e960259d4024b56eae69 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Mon, 9 Aug 2021 11:18:25 -0400 Subject: [PATCH] refactor!: rename bitwarden -> vaultwarden Was renamed upstream, in NixOS 21.11. --- bin/rofi/bwmenu | 6 ++--- config/qutebrowser/config.py | 2 +- hosts/ao/default.nix | 2 +- hosts/ao/modules/backup.nix | 6 ++--- .../{bitwarden.nix => vaultwarden.nix} | 8 +++--- hosts/ao/secrets/secrets.nix | 2 +- ...-smtp-env.age => vaultwarden-smtp-env.age} | Bin hosts/home.nix | 4 +-- hosts/kuro/default.nix | 2 +- hosts/shiro/default.nix | 2 +- modules/services/bitwarden.nix | 23 ------------------ modules/services/fail2ban.nix | 4 +-- modules/services/vaultwarden.nix | 23 ++++++++++++++++++ .../shell/{bitwarden.nix => vaultwarden.nix} | 6 ++--- 14 files changed, 45 insertions(+), 45 deletions(-) rename hosts/ao/modules/{bitwarden.nix => vaultwarden.nix} (75%) rename hosts/ao/secrets/{bitwarden-smtp-env.age => vaultwarden-smtp-env.age} (100%) delete mode 100644 modules/services/bitwarden.nix create mode 100644 modules/services/vaultwarden.nix rename modules/shell/{bitwarden.nix => vaultwarden.nix} (79%) diff --git a/bin/rofi/bwmenu b/bin/rofi/bwmenu index c6198345..b43cb375 100755 --- a/bin/rofi/bwmenu +++ b/bin/rofi/bwmenu @@ -1,7 +1,7 @@ #!/usr/bin/env cached-nix-shell #! nix-shell -p ruby_2_7 -i "ruby -S" -# A rofi client for bitwarden. Similar to passmenu, but uses rofi. (Badly) +# A rofi client for vaultwarden. Similar to passmenu, but uses rofi. (Badly) # written in ruby because data persistence and frontend logic would be a pain to # write in bash or zsh. I'll refactor this later perhaps. Maybe. @@ -91,7 +91,7 @@ module BW end def self.notify message, title: nil, urgency: "normal" - sh 'notify-send', '-u', urgency, '-a', "Bitwarden", *[title, message].compact + sh 'notify-send', '-u', urgency, '-a', "Vaultwarden", *[title, message].compact end def self.error message @@ -209,7 +209,7 @@ module BW when true return data[0][1] end - rofi rofiData.merge(data.to_h), '-p', 'Bitwarden', '-filter', (query || "") + rofi rofiData.merge(data.to_h), '-p', 'Vaultwarden', '-filter', (query || "") end def show_item item, field: nil diff --git a/config/qutebrowser/config.py b/config/qutebrowser/config.py index 66a40621..f2547de4 100644 --- a/config/qutebrowser/config.py +++ b/config/qutebrowser/config.py @@ -70,7 +70,7 @@ config.bind('', 'edit-text', mode='insert') config.bind('', 'hint inputs --first ;; edit-text', mode='normal') config.bind('', 'fake-key ', mode='insert') -# Bitwarden integration +# Vaultwarden integration config.bind(";pp", 'spawn -u qute-bwmenu') config.bind(";pu", 'spawn -u qute-bwmenu --field username') config.bind(";ps", 'spawn -u qute-bwmenu --field password') diff --git a/hosts/ao/default.nix b/hosts/ao/default.nix index a28023cb..c4446748 100644 --- a/hosts/ao/default.nix +++ b/hosts/ao/default.nix @@ -11,7 +11,7 @@ with lib.my; ./modules/backup.nix ./modules/gitea.nix - ./modules/bitwarden.nix + ./modules/vaultwarden.nix ]; diff --git a/hosts/ao/modules/backup.nix b/hosts/ao/modules/backup.nix index de4d1359..1008bea8 100644 --- a/hosts/ao/modules/backup.nix +++ b/hosts/ao/modules/backup.nix @@ -1,13 +1,13 @@ { config, lib, pkgs, ... }: { - services.bitwarden_rs.backupDir = "/backups/bitwarden_rs"; + services.vaultwarden.backupDir = "/backups/vaultwarden"; services.gitea.dump.enable = true; services.gitea.dump.backupDir = "/backups/gitea"; system.activationScripts.createBackupDir = '' - mkdir -m 750 -p "${config.services.bitwarden_rs.backupDir}" || true + mkdir -m 750 -p "${config.services.vaultwarden.backupDir}" || true mkdir -m 750 -p "${config.services.gitea.dump.backupDir}" || true - chown bitwarden_rs:bitwarden_rs "${config.services.bitwarden_rs.backupDir}" + chown vaultwarden:vaultwarden "${config.services.vaultwarden.backupDir}" chown git:gitea "${config.services.gitea.dump.backupDir}" ''; diff --git a/hosts/ao/modules/bitwarden.nix b/hosts/ao/modules/vaultwarden.nix similarity index 75% rename from hosts/ao/modules/bitwarden.nix rename to hosts/ao/modules/vaultwarden.nix index dce5823b..97eea774 100644 --- a/hosts/ao/modules/bitwarden.nix +++ b/hosts/ao/modules/vaultwarden.nix @@ -1,9 +1,9 @@ { config, lib, ... }: { - modules.services.bitwarden.enable = true; + modules.services.vaultwarden.enable = true; - services.bitwarden_rs.config = { + services.vaultwarden.config = { signupsAllowed = false; invitationsAllowed = true; domain = "https://p.v0.io"; @@ -11,8 +11,8 @@ }; # Inject secrets at runtime - systemd.services.bitwarden_rs.serviceConfig = { - EnvironmentFile = [ config.age.secrets.bitwarden-smtp-env.path ]; + systemd.services.vaultwarden.serviceConfig = { + EnvironmentFile = [ config.age.secrets.vaultwarden-smtp-env.path ]; Restart = "on-failure"; RestartSec = "2s"; }; diff --git a/hosts/ao/secrets/secrets.nix b/hosts/ao/secrets/secrets.nix index 5b788a63..bac7d92e 100644 --- a/hosts/ao/secrets/secrets.nix +++ b/hosts/ao/secrets/secrets.nix @@ -1,5 +1,5 @@ let key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAINd+4ijlEHI98NLpgP/El73BmpBUfzka9ovdt8FoaVAG hlissner@home"; in { - "bitwarden-smtp-env.age".publicKeys = [key]; + "vaultwarden-smtp-env.age".publicKeys = [key]; "gitea-smtp.age".publicKeys = [key]; } diff --git a/hosts/ao/secrets/bitwarden-smtp-env.age b/hosts/ao/secrets/vaultwarden-smtp-env.age similarity index 100% rename from hosts/ao/secrets/bitwarden-smtp-env.age rename to hosts/ao/secrets/vaultwarden-smtp-env.age diff --git a/hosts/home.nix b/hosts/home.nix index fbd02ac2..0717c00f 100644 --- a/hosts/home.nix +++ b/hosts/home.nix @@ -26,8 +26,8 @@ with lib; longitude = 12.5; } else {}); - # So thw bitwarden CLI knows where to find my server. - modules.shell.bitwarden.config.server = "p.v0.io"; + # So the vaultwarden CLI knows where to find my server. + modules.shell.vaultwarden.config.server = "p.v0.io"; ## Not using syncthing atm diff --git a/hosts/kuro/default.nix b/hosts/kuro/default.nix index 8da8de01..db2abe2e 100644 --- a/hosts/kuro/default.nix +++ b/hosts/kuro/default.nix @@ -54,7 +54,7 @@ }; shell = { adl.enable = true; - bitwarden.enable = true; + vaultwarden.enable = true; direnv.enable = true; git.enable = true; gnupg.enable = true; diff --git a/hosts/shiro/default.nix b/hosts/shiro/default.nix index 03778be7..1e0ef52d 100644 --- a/hosts/shiro/default.nix +++ b/hosts/shiro/default.nix @@ -41,7 +41,7 @@ }; dev = {}; shell = { - bitwarden.enable = true; + vaultwarden.enable = true; direnv.enable = true; git.enable = true; gnupg.enable = true; diff --git a/modules/services/bitwarden.nix b/modules/services/bitwarden.nix deleted file mode 100644 index 33da4307..00000000 --- a/modules/services/bitwarden.nix +++ /dev/null @@ -1,23 +0,0 @@ -{ options, config, lib, pkgs, ... }: - -with lib; -with lib.my; -let cfg = config.modules.services.bitwarden; -in { - options.modules.services.bitwarden = { - enable = mkBoolOpt false; - }; - - config = mkIf cfg.enable { - services.bitwarden_rs.enable = true; - - user.extraGroups = [ "bitwarden_rs" ]; - - services.fail2ban.jails.bitwarden_rs = '' - enabled = true - filter = bitwarden_rs - port = 80,443,8002 - maxretry = 5 - ''; - }; -} diff --git a/modules/services/fail2ban.nix b/modules/services/fail2ban.nix index e4a5b423..bdc7b478 100644 --- a/modules/services/fail2ban.nix +++ b/modules/services/fail2ban.nix @@ -27,14 +27,14 @@ in { # Extra filters environment.etc = { - "fail2ban/filter.d/bitwarden_rs.conf".text = '' + "fail2ban/filter.d/vaultwarden.conf".text = '' [INCLUDES] before = common.conf [Definition] failregex = ^.*Username or password is incorrect\. Try again\. IP: \. Username:.*$ ignoreregex = - journalmatch = _SYSTEMD_UNIT=bitwarden_rs.service + journalmatch = _SYSTEMD_UNIT=vaultwarden.service ''; "fail2ban/filter.d/gitea.conf".text = '' [Definition] diff --git a/modules/services/vaultwarden.nix b/modules/services/vaultwarden.nix new file mode 100644 index 00000000..d325d7c6 --- /dev/null +++ b/modules/services/vaultwarden.nix @@ -0,0 +1,23 @@ +{ options, config, lib, pkgs, ... }: + +with lib; +with lib.my; +let cfg = config.modules.services.vaultwarden; +in { + options.modules.services.vaultwarden = { + enable = mkBoolOpt false; + }; + + config = mkIf cfg.enable { + services.vaultwarden.enable = true; + + user.extraGroups = [ "vaultwarden" ]; + + services.fail2ban.jails.vaultwarden = '' + enabled = true + filter = vaultwarden + port = 80,443,8002 + maxretry = 5 + ''; + }; +} diff --git a/modules/shell/bitwarden.nix b/modules/shell/vaultwarden.nix similarity index 79% rename from modules/shell/bitwarden.nix rename to modules/shell/vaultwarden.nix index dfbaba81..7fbb14ca 100644 --- a/modules/shell/bitwarden.nix +++ b/modules/shell/vaultwarden.nix @@ -2,9 +2,9 @@ with lib; with lib.my; -let cfg = config.modules.shell.bitwarden; +let cfg = config.modules.shell.vaultwarden; in { - options.modules.shell.bitwarden = with types; { + options.modules.shell.vaultwarden = with types; { enable = mkBoolOpt false; config = mkOpt attrs {}; }; @@ -17,7 +17,7 @@ in { modules.shell.zsh.rcInit = "_cache bw completion --shell zsh; compdef _bw bw;"; system.userActivationScripts = mkIf (cfg.config != {}) { - initBitwarden = '' + initVaultwarden = '' ${concatStringsSep "\n" (mapAttrsToList (n: v: "bw config ${n} ${v}") cfg.config)} ''; };