nixos/security.gnupg: provisioning GnuPG-protected secrets through the Nix store#93659
nixos/security.gnupg: provisioning GnuPG-protected secrets through the Nix store#93659ju1m wants to merge 1 commit intoNixOS:masterfrom
Conversation
|
Interesting I was working on this: https://github.com/Mic92/sops-nix |
ac38f67 to
3d0f14e
Compare
430fed9 to
7508128
Compare
nixos/modules/security/gnupg.nix
Outdated
There was a problem hiding this comment.
So does this service starts a new gnupg daemon? Because it bind mounts /var/lib/gnupg/empty?
|
Sorry for the late response, was kinda swamped. Removing myself from reviewers, since I'm personally not very keen on an approach tied to a specific "backend", but also don't want to block this PR in any way. Aside from that, without having tried it, I think this is a rather small addition easy enough to get in and can be useful enough to some people/setups with only moderate transition costs should something else come around. What I think could be important here to get more feedback is an updated documentation on the usage scenarios early on, including scenarios in which this would not work well (i.e. to aid reviewers/testers gain understanding quicker). For instance, from first glance it seems to me like this would not work with services utilizing What would be also good to check is whether this could benefit from some likely upcoming related changes in systemd and how this might change the interface (see systemd/systemd#16568). |
DynamicUser can be also supported like this: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/monitoring/prometheus/alertmanager.nix#L170 |
|
I've updated according to @rycee's review. Beware that I've also removed I've also moved |
6187f80 to
b59410e
Compare
|
Introducing the possiblity to |
|
Opt-out |
|
Improved the documentation a little bit and fixed |
|
Fixed permission of |
|
Sorry, I forgot I had rebased a bit so Github's force-pushed link is not pretty; the diff is b3dc3af437f..58410e3735e, changelog is:
|
|
|
systemd v250 shall bring the systemd-creds utility (wrongly announced for v249 in that manpage). I'll have to actually use the new feature to be sure, but so far I'm looking forward to abandon this Some pros:
Some cons:
|
Motivation for this change
This
security.gnupgproposal aims at granularly sending, decrypting, and installing secrets (and if need be reloading services depending on them) coming from GnuPG encrypted files put into the Nix store, by leveragingpassword-store,gpg-agent,systemdandnix copy.Thanks in advance for your feedbacks.
Features
password-store's$PASSWORD_STORE_DIRor any.gpgloadable into the Nix store by any mean available.config.security.pass.secrets).password-store), and do not resend them unless they've changed.gpg-preset-passphrase).RuntimeDirectory), or persistent secrets only if theirpostStopis configured to do so.secret-${secret}.serviceper entry inconfig.security.gnupg.secretsallow fine grainedpostStart,after,wants, orrequires).pipe).extraBuiltins.execcallingpassand/ornixops send-keys.gnupguser instead ofrootto rungpg-agent.config.security.gnupg.agent.sendKeys) to send throughssha decrypting key and its password togpg-agent.TODO
nixos/tests/.Inconvenients
apparmor(for which I happen to be proposing the PR apparmor: fix and improve the service #93457 ).Example
First just rebuild your configuration without configuring secrets, just to enable
gpg-agent.service, using:Then make sure secrets are (re)encrypted to the right OpenPGP recipients (eg.
root@example.org's key):Now configure and use some secret (eg.
pass hosts/foo/transmission/settings.json) :Without a
flake.nixFrom there you can use
<nixpkgs/nixos>as usual, interleaving a call tosendKeys:Logged in as
root@example.org, you can then list the systemd units responsible to install those secrets with:and check the ones decrypted on the default destination, like so:
With a
flake.nixThings done
sandboxinnix.confon non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"./result/bin/)nix path-info -Sbefore and after)