Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions modules/misc/news.nix
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,24 @@ in {
A new module is available: 'programs.joplin-desktop'.
'';
}

{
time = "2024-03-14T07:22:09+00:00";
condition = config.services.gpg-agent.enable;
message = ''
Comment thread
ambroisie marked this conversation as resolved.
'services.gpg-agent.pinentryFlavor' has been removed and replaced by
'services.gpg-agent.pinentryPackage'.
'';
}

{
time = "2024-03-14T07:22:59+00:00";
condition = config.programs.rbw.enable;
message = ''
Comment thread
ambroisie marked this conversation as resolved.
'programs.rbw.pinentry' has been simplified to only accept 'null' or
a package.
'';
}
];
};
}
16 changes: 5 additions & 11 deletions modules/programs/rbw.nix
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ let
};

pinentry = mkOption {
Comment thread
ambroisie marked this conversation as resolved.
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
Expand All @@ -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;
};
};
};
Expand All @@ -87,7 +81,7 @@ in {
{
email = "name@example.com";
lock_timeout = 300;
pinentry = "gnome3";
pinentry = pkgs.pinentry-gnome3;
}
'';
description = ''
Expand Down
16 changes: 10 additions & 6 deletions modules/services/gpg-agent.nix
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,11 @@ let
in {
meta.maintainers = [ maintainers.rycee ];

imports = [
(mkRemovedOptionModule [ "services" "gpg-agent" "pinentryFlavor" ]
"Use services.gpg-agent.pinentryPackage instead")
];

options = {
services.gpg-agent = {
enable = mkEnableOption "GnuPG private key agent";
Expand Down Expand Up @@ -192,10 +197,9 @@ in {
configuration file.
'';
};

pinentryFlavor = mkOption {
type = types.nullOr (types.enum pkgs.pinentry.flavors);
example = "gnome3";
pinentryPackage = mkOption {
type = types.nullOr types.package;
example = literalExpression "pkgs.pinentry-gnome3";
default = null;
description = ''
Which pinentry interface to use. If not
Expand Down Expand Up @@ -243,8 +247,8 @@ in {
"max-cache-ttl ${toString cfg.maxCacheTtl}"
++ optional (cfg.maxCacheTtlSsh != null)
"max-cache-ttl-ssh ${toString cfg.maxCacheTtlSsh}"
++ optional (cfg.pinentryFlavor != null)
"pinentry-program ${pkgs.pinentry.${cfg.pinentryFlavor}}/bin/pinentry"
++ optional (cfg.pinentryPackage != null)
"pinentry-program ${lib.getExe pinentryPackage}"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be cfg.pinentryPackage?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm late, but this should be:

- "pinentry-program ${lib.getExe pinentryPackage}"
+ - "pinentry-program ${lib.getExe cfg.pinentryPackage}"

Getting this error:

┃        error: undefined variable 'pinentryPackage'
┃
┃        at /nix/store/kww2vp5mhnvb0mczv2xll0m5qsrjrw9q-source/modules/services/gpg-agent.nix:251:42:
┃
┃           250|           ++ optional (cfg.pinentryPackage != null)
┃           251|           "pinentry-program ${lib.getExe pinentryPackage}"|                                          ^
┃           252|           ++ [ cfg.extraConfig ]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Woops, review sniped :)

++ [ cfg.extraConfig ]);

home.sessionVariablesExtra = optionalString cfg.enableSshSupport ''
Expand Down
8 changes: 2 additions & 6 deletions tests/modules/programs/rbw/rbw-stubs.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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@"; };
})
];
}
4 changes: 2 additions & 2 deletions tests/modules/programs/rbw/settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -27,7 +27,7 @@ in {
base_url = "bitwarden.example.com";
identity_url = "identity.example.com";
lock_timeout = 300;
pinentry = "gnome3";
pinentry = pkgs.pinentry-gnome3;
};
};

Expand Down
2 changes: 1 addition & 1 deletion tests/modules/programs/rbw/simple-settings.nix
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ let
"email": "name@example.com",
"identity_url": null,
"lock_timeout": 3600,
"pinentry": "@pinentry-gtk2@/bin/pinentry"
"pinentry": null
}
'';
in {
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/services/gpg-agent/default-homedir.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ with lib;
{
config = {
services.gpg-agent.enable = true;
services.gpg-agent.pinentryFlavor = null; # Don't build pinentry package.
services.gpg-agent.pinentryPackage = null; # Don't build pinentry package.
programs.gpg.enable = true;

test.stubs.gnupg = { };
Expand Down
2 changes: 1 addition & 1 deletion tests/modules/services/gpg-agent/override-homedir.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ with lib;
{
config = {
services.gpg-agent.enable = true;
services.gpg-agent.pinentryFlavor = null; # Don't build pinentry package.
services.gpg-agent.pinentryPackage = null; # Don't build pinentry package.
programs.gpg = {
enable = true;
homedir = "/path/to/hash";
Expand Down