diff --git a/modules/environment/default.nix b/modules/environment/default.nix index 632a914..5368306 100644 --- a/modules/environment/default.nix +++ b/modules/environment/default.nix @@ -88,7 +88,7 @@ in description = '' Shell script code called during global environment initialisation after all variables and profileVariables have been set. - This code is asumed to be shell-independent, which means you should + This code is assumed to be shell-independent, which means you should stick to pure sh without sh word split. ''; }; diff --git a/modules/programs/gnupg.nix b/modules/programs/gnupg.nix index 6a34e30..718bf05 100644 --- a/modules/programs/gnupg.nix +++ b/modules/programs/gnupg.nix @@ -1,8 +1,19 @@ -{ config, lib, pkgs, ... }: - -with lib; +{ + config, + lib, + pkgs, + ... +}: let + inherit (lib) + getExe' + mkIf + mkOption + mkPackageOption + optionalString + types + ; cfg = config.programs.gnupg; @@ -10,6 +21,8 @@ in { options.programs.gnupg = { + package = mkPackageOption pkgs "gnupg" { }; + agent.enable = mkOption { type = types.bool; default = false; @@ -29,9 +42,12 @@ in }; config = mkIf cfg.agent.enable { + environment.systemPackages = [ cfg.package ]; + launchd.user.agents.gnupg-agent.serviceConfig = { ProgramArguments = [ - "${pkgs.gnupg}/bin/gpg-connect-agent" "/bye" + (getExe' cfg.package "gpg-connect-agent") + "/bye" ]; RunAtLoad = cfg.agent.enableSSHSupport; KeepAlive.SuccessfulExit = false; @@ -40,12 +56,13 @@ in environment.extraInit = '' # Bind gpg-agent to this TTY if gpg commands are used. export GPG_TTY=$(tty) - '' + (optionalString cfg.agent.enableSSHSupport '' + '' + + (optionalString cfg.agent.enableSSHSupport '' # SSH agent protocol doesn't support changing TTYs, so bind the agent # 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) ''); }; } diff --git a/modules/services/jankyborders/default.nix b/modules/services/jankyborders/default.nix index 61b560c..c89f1dd 100644 --- a/modules/services/jankyborders/default.nix +++ b/modules/services/jankyborders/default.nix @@ -22,7 +22,7 @@ in { ]; options.services.jankyborders = { - enable = mkEnableOption "Enable the jankyborders service."; + enable = mkEnableOption "the jankyborders service."; package = mkPackageOption pkgs "jankyborders" {}; diff --git a/modules/services/khd/default.nix b/modules/services/khd/default.nix index a09abab..6089d0d 100644 --- a/modules/services/khd/default.nix +++ b/modules/services/khd/default.nix @@ -33,7 +33,7 @@ in services.khd.i3Keybindings = mkOption { type = types.bool; default = false; - description = "Wether to configure i3 style keybindings for kwm."; + description = "Whether to configure i3 style keybindings for kwm."; }; }; diff --git a/modules/services/spacebar/default.nix b/modules/services/spacebar/default.nix index 7aa3c09..02bd231 100644 --- a/modules/services/spacebar/default.nix +++ b/modules/services/spacebar/default.nix @@ -22,7 +22,7 @@ in services.spacebar.enable = mkOption { type = bool; default = false; - description = "Whether to enable the spacebar spacebar."; + description = "Whether to enable the spacebar."; }; services.spacebar.package = mkOption { diff --git a/modules/services/wg-quick.nix b/modules/services/wg-quick.nix index fab7a84..8137ac7 100644 --- a/modules/services/wg-quick.nix +++ b/modules/services/wg-quick.nix @@ -83,7 +83,7 @@ let preDown = mkOption { type = with types; coercedTo (listOf str) (concatStringsSep "\n") lines; default = ""; - description = "List of commadns to run before interface shutdown."; + description = "List of commands to run before interface shutdown."; }; preUp = mkOption { diff --git a/release.nix b/release.nix index 410b099..160c642 100644 --- a/release.nix +++ b/release.nix @@ -90,6 +90,7 @@ in { tests.networking-networkservices = makeTest ./tests/networking-networkservices.nix; tests.nix-enable = makeTest ./tests/nix-enable.nix; tests.nixpkgs-overlays = makeTest ./tests/nixpkgs-overlays.nix; + tests.programs-gnupg = makeTest ./tests/programs-gnupg.nix; tests.programs-ssh = makeTest ./tests/programs-ssh.nix; tests.programs-tmux = makeTest ./tests/programs-tmux.nix; tests.programs-zsh = makeTest ./tests/programs-zsh.nix; diff --git a/tests/programs-gnupg.nix b/tests/programs-gnupg.nix new file mode 100644 index 0000000..3a5c588 --- /dev/null +++ b/tests/programs-gnupg.nix @@ -0,0 +1,31 @@ +{ + config, + lib, + pkgs, + ... +}: + +let + gnupg = pkgs.runCommand "gnupg-0.0.0" { } "mkdir -p $out/bin"; +in + +{ + system.primaryUser = "test-gnupg-user"; + + programs.gnupg.package = gnupg; + programs.gnupg.agent.enable = true; + programs.gnupg.agent.enableSSHSupport = true; + + test = '' + echo >&2 "checking gnupg-agent service in ~/Library/LaunchAgents" + grep "org.nixos.gnupg-agent" ${config.out}/user/Library/LaunchAgents/org.nixos.gnupg-agent.plist + grep "${gnupg}/bin/gpg-connect-agent" ${config.out}/user/Library/LaunchAgents/org.nixos.gnupg-agent.plist + + echo >&2 "checking GPG_TTY in set-environment" + grep 'export GPG_TTY=\$(tty)' ${config.system.build.setEnvironment} + + echo >&2 "checking SSH support in set-environment" + grep "${gnupg}/bin/gpg-connect-agent --quiet updatestartuptty /bye" ${config.system.build.setEnvironment} + grep "${gnupg}/bin/gpgconf --list-dirs agent-ssh-socket" ${config.system.build.setEnvironment} + ''; +}