From c9433ae62fbb4bd09609e242569edc3b551e21a9 Mon Sep 17 00:00:00 2001 From: "Benedikt M. Rips" Date: Tue, 22 Apr 2025 18:42:04 +0200 Subject: [PATCH] keepassxc: register as native messaging host (#6879) Register KeepassXC as a native messaging host in supported browsers to integrate with KeepassXC's browser extension. See https://discourse.nixos.org/t/keepassxc-browser-extension-integration/39553 for more information. --- modules/programs/keepassxc.nix | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/modules/programs/keepassxc.nix b/modules/programs/keepassxc.nix index 21f9c0a7..64a46aff 100644 --- a/modules/programs/keepassxc.nix +++ b/modules/programs/keepassxc.nix @@ -45,12 +45,26 @@ in }; }; - config = lib.mkIf cfg.enable { - home.packages = lib.mkIf (cfg.package != null) [ cfg.package ]; - xdg.configFile = { - "keepassxc/keepassxc.ini" = lib.mkIf (cfg.settings != { }) { - source = iniFormat.generate "keepassxc-settings" cfg.settings; - }; - }; - }; + config = lib.mkIf cfg.enable ( + lib.mkMerge [ + + { + xdg.configFile = { + "keepassxc/keepassxc.ini" = lib.mkIf (cfg.settings != { }) { + source = iniFormat.generate "keepassxc-settings" cfg.settings; + }; + }; + } + + (lib.mkIf (cfg.package != null) { + home.packages = [ cfg.package ]; + programs.brave.nativeMessagingHosts = [ cfg.package ]; + programs.chromium.nativeMessagingHosts = [ cfg.package ]; + programs.firefox.nativeMessagingHosts = [ cfg.package ]; + programs.floorp.nativeMessagingHosts = [ cfg.package ]; + programs.vivaldi.nativeMessagingHosts = [ cfg.package ]; + }) + + ] + ); }