Skip to content

Automatically generate and use a signing key#15708

Open
lisanna-dettwyler wants to merge 1 commit intoNixOS:masterfrom
lisanna-dettwyler:auto-sign
Open

Automatically generate and use a signing key#15708
lisanna-dettwyler wants to merge 1 commit intoNixOS:masterfrom
lisanna-dettwyler:auto-sign

Conversation

@lisanna-dettwyler
Copy link
Copy Markdown
Contributor

@lisanna-dettwyler lisanna-dettwyler commented Apr 17, 2026

Sets the default value of secret-key-files to /nix/var/nix/keys/secret-key, and automatically generates this keypair if it doesn't exist. The effect of this is that locally built paths are always signed, making it easier to trace where builds come from and to establish trust. The corresponding public key is stored at /nix/var/nix/public-keys/public-key.

Closes #3023

Motivation

In addition to enabling tracing of what machine built what store path, this makes a future --target-store flag more usable, because you can obtain and add the automatically-generated public key of the remote store rather than having to manually generate and configure a new key.

Context

#3023


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

@github-actions github-actions Bot added the store Issues and pull requests concerning the Nix store label Apr 17, 2026
@Ericson2314
Copy link
Copy Markdown
Member

I think this should be done on the remote side. Singing builds that a different machine may have performed by default is a bit dangerous. But if the logic is moved to the local build code path, then it is safe.

@lisanna-dettwyler
Copy link
Copy Markdown
Contributor Author

I think this should be done on the remote side. Singing builds that a different machine may have performed by default is a bit dangerous. But if the logic is moved to the local build code path, then it is safe.

@Ericson2314 isn't that where I have it? LocalStore inherits Store::buildPathsWithResults (what this PR touches), but SSHStore inherits RemoteStore::buildPathsWithResults (which this PR doesn't touch).

@lisanna-dettwyler
Copy link
Copy Markdown
Contributor Author

Oh, I'm silly, there's already logic to sign paths with the contents of secret-key-files. This should end up being a much simpler change.

@github-actions github-actions Bot added the with-tests Issues related to testing. PRs with tests have some priority label Apr 18, 2026
@lisanna-dettwyler lisanna-dettwyler changed the title WIP: Sign built paths by default Automatically generate and use a signing key Apr 18, 2026
@lisanna-dettwyler lisanna-dettwyler marked this pull request as ready for review April 18, 2026 22:27
@lisanna-dettwyler lisanna-dettwyler force-pushed the auto-sign branch 2 times, most recently from 81114b9 to b8db7b4 Compare April 18, 2026 22:30
@xokdvium
Copy link
Copy Markdown
Contributor

Tbh I'm not sure having the default be in /etc is a great idea. At the very least is should be in an unlistable directory, but it's certainly a policy question...

Sets the default value of `secret-key-files` to
/nix/var/nix/keys/secret-key, and automatically generates this keypair
if it doesn't exist. The effect of this is that locally built paths are
always signed, making it easier to trace where builds come from and to
establish trust. The corresponding public key is stored at
`/nix/var/nix/public-keys/public-key`.

Closes NixOS#3023

Signed-off-by: Lisanna Dettwyler <lisanna.dettwyler@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation store Issues and pull requests concerning the Nix store with-tests Issues related to testing. PRs with tests have some priority

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generate and use signing keys automatically

3 participants