feat(gnupg): add configurable package option and install it
Signed-off-by: Angel J <78835633+Iamanaws@users.noreply.github.com>
This commit is contained in:
parent
c2b36207f2
commit
0b53d57d3a
1 changed files with 24 additions and 7 deletions
|
|
@ -1,8 +1,19 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{
|
||||||
|
config,
|
||||||
with lib;
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
let
|
let
|
||||||
|
inherit (lib)
|
||||||
|
getExe'
|
||||||
|
mkIf
|
||||||
|
mkOption
|
||||||
|
mkPackageOption
|
||||||
|
optionalString
|
||||||
|
types
|
||||||
|
;
|
||||||
|
|
||||||
cfg = config.programs.gnupg;
|
cfg = config.programs.gnupg;
|
||||||
|
|
||||||
|
|
@ -10,6 +21,8 @@ in
|
||||||
|
|
||||||
{
|
{
|
||||||
options.programs.gnupg = {
|
options.programs.gnupg = {
|
||||||
|
package = mkPackageOption pkgs "gnupg" { };
|
||||||
|
|
||||||
agent.enable = mkOption {
|
agent.enable = mkOption {
|
||||||
type = types.bool;
|
type = types.bool;
|
||||||
default = false;
|
default = false;
|
||||||
|
|
@ -29,9 +42,12 @@ in
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.agent.enable {
|
config = mkIf cfg.agent.enable {
|
||||||
|
environment.systemPackages = [ cfg.package ];
|
||||||
|
|
||||||
launchd.user.agents.gnupg-agent.serviceConfig = {
|
launchd.user.agents.gnupg-agent.serviceConfig = {
|
||||||
ProgramArguments = [
|
ProgramArguments = [
|
||||||
"${pkgs.gnupg}/bin/gpg-connect-agent" "/bye"
|
(getExe' cfg.package "gpg-connect-agent")
|
||||||
|
"/bye"
|
||||||
];
|
];
|
||||||
RunAtLoad = cfg.agent.enableSSHSupport;
|
RunAtLoad = cfg.agent.enableSSHSupport;
|
||||||
KeepAlive.SuccessfulExit = false;
|
KeepAlive.SuccessfulExit = false;
|
||||||
|
|
@ -40,12 +56,13 @@ in
|
||||||
environment.extraInit = ''
|
environment.extraInit = ''
|
||||||
# Bind gpg-agent to this TTY if gpg commands are used.
|
# Bind gpg-agent to this TTY if gpg commands are used.
|
||||||
export GPG_TTY=$(tty)
|
export GPG_TTY=$(tty)
|
||||||
'' + (optionalString cfg.agent.enableSSHSupport ''
|
''
|
||||||
|
+ (optionalString cfg.agent.enableSSHSupport ''
|
||||||
# SSH agent protocol doesn't support changing TTYs, so bind the agent
|
# SSH agent protocol doesn't support changing TTYs, so bind the agent
|
||||||
# to every new TTY.
|
# to every new TTY.
|
||||||
${pkgs.gnupg}/bin/gpg-connect-agent --quiet updatestartuptty /bye > /dev/null 2>&1
|
${getExe' cfg.package "gpg-connect-agent"} --quiet updatestartuptty /bye > /dev/null 2>&1
|
||||||
|
|
||||||
export SSH_AUTH_SOCK=$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket)
|
export SSH_AUTH_SOCK=$(${getExe' cfg.package "gpgconf"} --list-dirs agent-ssh-socket)
|
||||||
'');
|
'');
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue