diff --git a/tests/modules/services/gpg-agent/default-homedir-expected-agent.plist b/tests/modules/services/gpg-agent/default-homedir-expected-agent.plist new file mode 100644 index 000000000..d71cb2d61 --- /dev/null +++ b/tests/modules/services/gpg-agent/default-homedir-expected-agent.plist @@ -0,0 +1,42 @@ + + + + + EnvironmentVariables + + GNUPGHOME + /home/hm-user/.gnupg + + KeepAlive + + Crashed + + SuccessfulExit + + + Label + org.nix-community.home.gpg-agent + ProcessType + Background + ProgramArguments + + @gpg@/bin/gpgconf + --launch + gpg-agent + + RunAtLoad + + Sockets + + Agent + + SockPathMode + 384 + SockPathName + /home/hm-user/.gnupg/S.gpg-agent + SockType + stream + + + + \ No newline at end of file diff --git a/tests/modules/services/gpg-agent/default-homedir.nix b/tests/modules/services/gpg-agent/default-homedir.nix index 9c13520ae..1b6404c29 100644 --- a/tests/modules/services/gpg-agent/default-homedir.nix +++ b/tests/modules/services/gpg-agent/default-homedir.nix @@ -2,19 +2,31 @@ with lib; -mkIf pkgs.stdenv.isLinux { +let inherit (pkgs.stdenv) isDarwin; +in { config = { services.gpg-agent.enable = true; - services.gpg-agent.pinentryPackage = pkgs.pinentry-gnome3; - programs.gpg.enable = true; + services.gpg-agent.pinentryPackage = + if isDarwin then pkgs.pinentry_mac else pkgs.pinentry-gnome3; + programs.gpg = { + enable = true; + package = config.lib.test.mkStubPackage { outPath = "@gpg@"; }; + }; test.stubs = { gnupg = { }; systemd = { }; # depends on gnupg.override pinentry-gnome3 = { }; + pinentry_mac = { }; }; - nmt.script = '' + nmt.script = if isDarwin then '' + serviceFile=LaunchAgents/org.nix-community.home.gpg-agent.plist + assertFileExists "$serviceFile" + assertFileContent "$serviceFile" ${./default-homedir-expected-agent.plist} + configFile=home-files/.gnupg/gpg-agent.conf + assertFileRegex $configFile "pinentry-program @pinentry_mac@/bin/dummy" + '' else '' in="${config.systemd.user.sockets.gpg-agent.Socket.ListenStream}" if [[ $in != "%t/gnupg/S.gpg-agent" ]] then diff --git a/tests/modules/services/gpg-agent/expected-agent.plist b/tests/modules/services/gpg-agent/override-homedir-expected-agent.plist similarity index 100% rename from tests/modules/services/gpg-agent/expected-agent.plist rename to tests/modules/services/gpg-agent/override-homedir-expected-agent.plist diff --git a/tests/modules/services/gpg-agent/override-homedir.nix b/tests/modules/services/gpg-agent/override-homedir.nix index 82dec0f95..a74e45dba 100644 --- a/tests/modules/services/gpg-agent/override-homedir.nix +++ b/tests/modules/services/gpg-agent/override-homedir.nix @@ -19,7 +19,9 @@ in { nmt.script = if isDarwin then '' serviceFile=LaunchAgents/org.nix-community.home.gpg-agent.plist assertFileExists "$serviceFile" - assertFileContent "$serviceFile" ${./expected-agent.plist} + assertFileContent "$serviceFile" ${ + ./override-homedir-expected-agent.plist + } '' else '' in="${config.systemd.user.sockets.gpg-agent.Socket.ListenStream}" if [[ $in != "%t/gnupg/d.wp4h7ks5zxy4dodqadgpbbpz/S.gpg-agent" ]]