From 1ab3cec3a1bbb065b2d52b913d1431366028d5b5 Mon Sep 17 00:00:00 2001 From: Bruno BELANYI Date: Sun, 10 Mar 2024 10:24:45 +0000 Subject: [PATCH] rbw: simplify 'pinentry' type Following some upstream changes [1], it's now possible to use a simplified package type for the option. [1]: https://github.com/NixOS/nixpkgs/pull/133542 --- modules/misc/news.nix | 9 +++++++++ modules/programs/rbw.nix | 16 +++++----------- tests/modules/programs/rbw/rbw-stubs.nix | 8 ++------ tests/modules/programs/rbw/settings.nix | 4 ++-- tests/modules/programs/rbw/simple-settings.nix | 2 +- 5 files changed, 19 insertions(+), 20 deletions(-) diff --git a/modules/misc/news.nix b/modules/misc/news.nix index 0b858861..c4a19177 100644 --- a/modules/misc/news.nix +++ b/modules/misc/news.nix @@ -1452,6 +1452,15 @@ in { 'services.gpg-agent.pinentryPackage'. ''; } + + { + time = "2024-03-14T07:22:59+00:00"; + condition = config.programs.rbw.enable; + message = '' + 'programs.rbw.pinentry' has been simplified to only accept 'null' or + a package. + ''; + } ]; }; } diff --git a/modules/programs/rbw.nix b/modules/programs/rbw.nix index b6369dbc..5dd751d0 100644 --- a/modules/programs/rbw.nix +++ b/modules/programs/rbw.nix @@ -41,9 +41,9 @@ let }; pinentry = mkOption { - type = with types; either package (enum pkgs.pinentry.flavors); - example = "gnome3"; - default = "gtk2"; + type = types.nullOr types.package; + example = literalExpression "pkgs.pinentry-gnome3"; + default = null; description = '' Which pinentry interface to use. Beware that `pinentry-gnome3` may not work on non-Gnome @@ -52,15 +52,9 @@ let ```nix services.dbus.packages = [ pkgs.gcr ]; ``` - For this reason, the default is `gtk2` for - now. ''; # we want the program in the config - apply = val: - if builtins.isString val then - "${pkgs.pinentry.${val}}/bin/pinentry" - else - "${val}/${val.binaryPath or "bin/pinentry"}"; + apply = val: if val == null then val else lib.getExe val; }; }; }; @@ -87,7 +81,7 @@ in { { email = "name@example.com"; lock_timeout = 300; - pinentry = "gnome3"; + pinentry = pkgs.pinentry-gnome3; } ''; description = '' diff --git a/tests/modules/programs/rbw/rbw-stubs.nix b/tests/modules/programs/rbw/rbw-stubs.nix index c48d88be..77436232 100644 --- a/tests/modules/programs/rbw/rbw-stubs.nix +++ b/tests/modules/programs/rbw/rbw-stubs.nix @@ -5,12 +5,8 @@ nixpkgs.overlays = [ (self: super: { - pinentry = { - gnome3 = - config.lib.test.mkStubPackage { outPath = "@pinentry-gnome3@"; }; - gtk2 = config.lib.test.mkStubPackage { outPath = "@pinentry-gtk2@"; }; - flavors = [ "gnome3" "gtk2" ]; - }; + pinentry-gnome3 = + config.lib.test.mkStubPackage { outPath = "@pinentry-gnome3@"; }; }) ]; } diff --git a/tests/modules/programs/rbw/settings.nix b/tests/modules/programs/rbw/settings.nix index 8cf9572b..ac582018 100644 --- a/tests/modules/programs/rbw/settings.nix +++ b/tests/modules/programs/rbw/settings.nix @@ -14,7 +14,7 @@ let "email": "name@example.com", "identity_url": "identity.example.com", "lock_timeout": 300, - "pinentry": "@pinentry-gnome3@/bin/pinentry" + "pinentry": "@pinentry-gnome3@/bin/dummy" } ''; in { @@ -27,7 +27,7 @@ in { base_url = "bitwarden.example.com"; identity_url = "identity.example.com"; lock_timeout = 300; - pinentry = "gnome3"; + pinentry = pkgs.pinentry-gnome3; }; }; diff --git a/tests/modules/programs/rbw/simple-settings.nix b/tests/modules/programs/rbw/simple-settings.nix index becf9fad..b690659a 100644 --- a/tests/modules/programs/rbw/simple-settings.nix +++ b/tests/modules/programs/rbw/simple-settings.nix @@ -14,7 +14,7 @@ let "email": "name@example.com", "identity_url": null, "lock_timeout": 3600, - "pinentry": "@pinentry-gtk2@/bin/pinentry" + "pinentry": null } ''; in {