|
21 | 21 |
|
22 | 22 | agent.enableSSHSupport = mkOption {
|
23 | 23 | type = types.bool;
|
24 |
| - default = true; |
| 24 | + default = false; |
25 | 25 | description = ''
|
26 | 26 | Enable SSH agent support in GnuPG agent. Also sets SSH_AUTH_SOCK
|
27 | 27 | environment variable correctly. This will disable socket-activation
|
28 | 28 | and thus always start a GnuPG agent per user session.
|
29 | 29 | '';
|
30 | 30 | };
|
| 31 | + |
| 32 | + agent.enableExtraSocket = mkOption { |
| 33 | + type = types.bool; |
| 34 | + default = false; |
| 35 | + description = '' |
| 36 | + Enable extra socket for GnuPG agent. |
| 37 | + ''; |
| 38 | + }; |
| 39 | + |
| 40 | + agent.enableBrowserSocket = mkOption { |
| 41 | + type = types.bool; |
| 42 | + default = false; |
| 43 | + description = '' |
| 44 | + Enable browser socket for GnuPG agent. |
| 45 | + ''; |
| 46 | + }; |
| 47 | + |
| 48 | + dirmngr.enable = mkOption { |
| 49 | + type = types.bool; |
| 50 | + default = false; |
| 51 | + description = '' |
| 52 | + Enables GnuPG network certificate management daemon with socket-activation for every user session. |
| 53 | + ''; |
| 54 | + }; |
31 | 55 | };
|
32 | 56 |
|
33 | 57 | config = mkIf cfg.agent.enable {
|
|
38 | 62 | ("${pkgs.gnupg}/bin/gpg-agent --supervised "
|
39 | 63 | + optionalString cfg.agent.enableSSHSupport "--enable-ssh-support")
|
40 | 64 | ];
|
| 65 | + ExecReload = "${pkgs.gnupg}/bin/gpgconf --reload gpg-agent"; |
41 | 66 | };
|
42 | 67 | };
|
43 | 68 |
|
44 | 69 | systemd.user.sockets.gpg-agent = {
|
45 | 70 | wantedBy = [ "sockets.target" ];
|
| 71 | + listenStreams = [ "%t/gnupg/S.gpg-agent" ]; |
| 72 | + socketConfig = { |
| 73 | + FileDescriptorName = "std"; |
| 74 | + SocketMode = "0600"; |
| 75 | + DirectoryMode = "0700"; |
| 76 | + }; |
46 | 77 | };
|
47 | 78 |
|
48 | 79 | systemd.user.sockets.gpg-agent-ssh = mkIf cfg.agent.enableSSHSupport {
|
49 | 80 | wantedBy = [ "sockets.target" ];
|
| 81 | + listenStreams = [ "%t/gnupg/S.gpg-agent.ssh" ]; |
| 82 | + socketConfig = { |
| 83 | + FileDescriptorName = "ssh"; |
| 84 | + Service = "gpg-agent.service"; |
| 85 | + SocketMode = "0600"; |
| 86 | + DirectoryMode = "0700"; |
| 87 | + }; |
| 88 | + }; |
| 89 | + |
| 90 | + systemd.user.sockets.gpg-agent-extra = mkIf cfg.agent.enableExtraSocket { |
| 91 | + wantedBy = [ "sockets.target" ]; |
| 92 | + listenStreams = [ "%t/gnupg/S.gpg-agent.extra" ]; |
| 93 | + socketConfig = { |
| 94 | + FileDescriptorName = "extra"; |
| 95 | + Service = "gpg-agent.service"; |
| 96 | + SocketMode = "0600"; |
| 97 | + DirectoryMode = "0700"; |
| 98 | + }; |
| 99 | + }; |
| 100 | + |
| 101 | + systemd.user.sockets.gpg-agent-browser = mkIf cfg.agent.enableBrowserSocket { |
| 102 | + wantedBy = [ "sockets.target" ]; |
| 103 | + listenStreams = [ "%t/gnupg/S.gpg-agent.browser" ]; |
| 104 | + socketConfig = { |
| 105 | + FileDescriptorName = "browser"; |
| 106 | + Service = "gpg-agent.service"; |
| 107 | + SocketMode = "0600"; |
| 108 | + DirectoryMode = "0700"; |
| 109 | + }; |
| 110 | + }; |
| 111 | + |
| 112 | + systemd.user.services.dirmngr = { |
| 113 | + requires = [ "dirmngr.socket" ]; |
| 114 | + after = [ "dirmngr.socket" ]; |
| 115 | + unitConfig = { |
| 116 | + RefuseManualStart = "true"; |
| 117 | + }; |
| 118 | + serviceConfig = { |
| 119 | + ExecStart = "${pkgs.gnupg}/bin/dirmngr --supervised"; |
| 120 | + ExecReload = "${pkgs.gnupg}/bin/gpgconf --reload dirmngr"; |
| 121 | + }; |
| 122 | + }; |
| 123 | + |
| 124 | + systemd.user.sockets.dirmngr = { |
| 125 | + wantedBy = [ "sockets.target" ]; |
| 126 | + listenStreams = [ "%t/gnupg/S.dirmngr" ]; |
| 127 | + socketConfig = { |
| 128 | + SocketMode = "0600"; |
| 129 | + DirectoryMode = "0700"; |
| 130 | + }; |
50 | 131 | };
|
51 | 132 |
|
52 | 133 | systemd.packages = [ pkgs.gnupg ];
|
|
0 commit comments