Compare commits

...

5 commits

Author SHA1 Message Date
Sam
c31afa6e76
fix(modules): fixed typos in various modules (#1672)
Some checks failed
Test / test-stable (push) Has been cancelled
Test / install-against-stable (push) Has been cancelled
Test / install-flake (push) Has been cancelled
Update website / Build (push) Has been cancelled
Update website / Deploy (push) Has been cancelled
2025-12-29 17:10:40 +00:00
Nikita Lenyk
8cecf9c5c5 fix(modules): fixed typos in various modules 2025-12-29 18:31:13 +02:00
Michael Hoang
f0c8e1f6fe
feat(gnupg): add configurable package option and install it (#1667) 2025-12-26 21:26:36 +00:00
Angel J
d70b24c2a8
test(gnupg): add tests for gnupg agent configuration
Signed-off-by: Angel J <78835633+Iamanaws@users.noreply.github.com>
2025-12-26 07:44:43 -08:00
angel
0b53d57d3a
feat(gnupg): add configurable package option and install it
Signed-off-by: Angel J <78835633+Iamanaws@users.noreply.github.com>
2025-12-26 07:42:37 -08:00
8 changed files with 61 additions and 12 deletions

View file

@ -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.
'';
};

View file

@ -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)
'');
};
}

View file

@ -22,7 +22,7 @@ in {
];
options.services.jankyborders = {
enable = mkEnableOption "Enable the jankyborders service.";
enable = mkEnableOption "the jankyborders service.";
package = mkPackageOption pkgs "jankyborders" {};

View file

@ -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.";
};
};

View file

@ -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 {

View file

@ -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 {

View file

@ -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;

31
tests/programs-gnupg.nix Normal file
View file

@ -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}
'';
}