gpg-agent: add launchd service agent and sockets
This adds a Darwin Launchd agent along with its sockets to make gpg-agent starts at load or whenever the sockets are needed. Fixes: https://github.com/nix-community/home-manager/issues/3864
This commit is contained in:
parent
c82fc8cf3f
commit
ef50612457
6 changed files with 151 additions and 87 deletions
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
with lib;
|
||||
|
||||
{
|
||||
mkIf pkgs.stdenv.isLinux {
|
||||
config = {
|
||||
services.gpg-agent.enable = true;
|
||||
services.gpg-agent.pinentryPackage = pkgs.pinentry-gnome3;
|
||||
|
|
|
|||
41
tests/modules/services/gpg-agent/expected-agent.plist
Normal file
41
tests/modules/services/gpg-agent/expected-agent.plist
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>EnvironmentVariables</key>
|
||||
<dict>
|
||||
<key>GNUPGHOME</key>
|
||||
<string>/path/to/hash</string>
|
||||
</dict>
|
||||
<key>KeepAlive</key>
|
||||
<dict>
|
||||
<key>Crashed</key>
|
||||
<true/>
|
||||
<key>SuccessfulExit</key>
|
||||
<false/>
|
||||
</dict>
|
||||
<key>Label</key>
|
||||
<string>org.nix-community.home.gpg-agent</string>
|
||||
<key>ProcessType</key>
|
||||
<string>Background</string>
|
||||
<key>ProgramArguments</key>
|
||||
<array>
|
||||
<string>@gpg@/bin/gpg-agent</string>
|
||||
<string>--supervised</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<false/>
|
||||
<key>Sockets</key>
|
||||
<dict>
|
||||
<key>Agent</key>
|
||||
<dict>
|
||||
<key>SockPathMode</key>
|
||||
<integer>384</integer>
|
||||
<key>SockPathName</key>
|
||||
<string>/private/var/run/org.nix-community.home.gpg-agent/d.wp4h7ks5zxy4dodqadgpbbpz/S.gpg-agent</string>
|
||||
<key>SockType</key>
|
||||
<string>stream</string>
|
||||
</dict>
|
||||
</dict>
|
||||
</dict>
|
||||
</plist>
|
||||
|
|
@ -2,19 +2,25 @@
|
|||
|
||||
with lib;
|
||||
|
||||
{
|
||||
let inherit (pkgs.stdenv) isDarwin;
|
||||
in {
|
||||
config = {
|
||||
services.gpg-agent.enable = true;
|
||||
services.gpg-agent.pinentryPackage = null; # Don't build pinentry package.
|
||||
programs.gpg = {
|
||||
enable = true;
|
||||
homedir = "/path/to/hash";
|
||||
package = config.lib.test.mkStubPackage { outPath = "@gpg@"; };
|
||||
};
|
||||
|
||||
test.stubs.gnupg = { };
|
||||
test.stubs.systemd = { }; # depends on gnupg.override
|
||||
|
||||
nmt.script = ''
|
||||
nmt.script = if isDarwin then ''
|
||||
serviceFile=LaunchAgents/org.nix-community.home.gpg-agent.plist
|
||||
assertFileExists "$serviceFile"
|
||||
assertFileContent "$serviceFile" ${./expected-agent.plist}
|
||||
'' else ''
|
||||
in="${config.systemd.user.sockets.gpg-agent.Socket.ListenStream}"
|
||||
if [[ $in != "%t/gnupg/d.wp4h7ks5zxy4dodqadgpbbpz/S.gpg-agent" ]]
|
||||
then
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue