Skip to content

mkSignedPackages: init - #549373

Merged
ElvishJerricco merged 11 commits into
masterfrom
wip-emily/push-txyvuyysulqv
Aug 28, 2026
Merged

ElvishJerricco merged 11 commits into
masterfrom
wip-emily/push-txyvuyysulqv

Conversation

@emilazy

@emilazy emilazy commented Aug 5, 2026 •

Copy link
Copy Markdown
Member

Building on package introduced in #545457 (which this is stacked on top of), this PR adds a Nix library to allow the creation of basic self‐signed X.509 code signing certificates and Authenticode‐signed PE files (as used in UEFI Secure Boot), and support for signing the UEFI executables from fwupd-efi, systemd-boot, and shim-unsigned with a user-provided signing key. Signing of kernel images will come in a follow‐up PR. The only thing Hydra will build at present is the example testSignedPackages set using an insecure test key.

These signed packages will require further integration work in NixOS to enable configuration of Secure Boot setups, but could be used as‐is with custom deployment setups. Preparing for the requirements and logistics involved in support for official signing of a shim with the Microsoft Secure Boot keys is also left for future work.


This is part of the end‐to‐end NixOS boot security project, funded through NGI Fediversity Fund, a fund established by NLnet with financial support from the European Commission’s Next Generation Internet programme.

Things done

@emilazy
emilazy requested a review from a team August 5, 2026 02:31
@emilazy
emilazy force-pushed the wip-emily/push-txyvuyysulqv branch 2 times, most recently from 513b7d9 to d7d3f0d Compare August 5, 2026 02:35
@nixpkgs-ci
nixpkgs-ci Bot requested review from baloo, infinisil and philiptaron August 5, 2026 02:43
@nixpkgs-ci nixpkgs-ci Bot added 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. labels Aug 5, 2026
Comment on lines +7 to +8
uefiSigningKey,
uefiCertificate,

@baloo baloo Aug 5, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally this would be a single argument to the derivation (as they should be kept consistent with each other). This applies to the whole call-stack.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is mechanically checked, FWIW:

assert self.uefiCertificate.verificationKey == uefiSigningKey.verificationKey;

I agree that it might be nice to have an abstraction here that bundles the certificate and signing key; the lack of a good universal term for it like “key pair” for raw keys is probably the main reason I didn’t try :) I think “identity” gets some use, but it feels a little vague. I suppose something like the unwieldy “certified signing key” would be an option.

However, the two do have fairly different statuses here, as we want to expose uefiCertificate publicly in the scope, but not uefiSigningKey (because we don’t want packages outside the scope to be signing things). So this is comparable to having separate .crt and .key files for a TLS server, as opposed to a bundled .p12… the ergonomics would be nicer to combine them but not sure if the conceptual clarity would suffer as a result.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I played around with trying to unify these into a single object; although it saves a little boilerplate in the mkSignedPe callers, I think it’s probably the wrong way to go for now.

We want the certificate sans the signing key to be a derivation; either a certified key pair has to be a derivation that can “override itself” to remove the signing key (while retaining the same derivation hash), or a certified key pair is just an attribute set containing a signing key and a certificate derivation, which means that the semantics of passthru and meta get more awkward and we can’t use overrideMkDerivation like everything else does, which makes the mental model of certificates and keys as store objects less smooth.

It’s true that whenever we use uefiSigningKey we almost certainly need the uefiCertificate, but trying to couple the two together when they have very different privacy expectations seems to be a net increase in awkwardness. There’s more common boilerplate in the signed packages here than I’d like, but I think that it’ll be best to see how that shakes out when adding support for signed kernel images, external Microsoft shim signatures, etc. to get a better idea of what redundancy can be effectively reduced.

@emilazy
emilazy force-pushed the wip-emily/push-txyvuyysulqv branch from d7d3f0d to a72f5f0 Compare August 14, 2026 07:49
@emilazy
emilazy force-pushed the wip-emily/push-nvpsyzzvkvyq branch from e836025 to f3b80ee Compare August 14, 2026 08:13
@emilazy
emilazy force-pushed the wip-emily/push-txyvuyysulqv branch from a72f5f0 to 0dc3e4f Compare August 14, 2026 08:13
@nixpkgs-ci nixpkgs-ci Bot removed the 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. label Aug 14, 2026
@emilazy
emilazy force-pushed the wip-emily/push-nvpsyzzvkvyq branch from f3b80ee to 6c1758b Compare August 27, 2026 18:33
@emilazy
emilazy force-pushed the wip-emily/push-nvpsyzzvkvyq branch from 6c1758b to 914ae55 Compare August 27, 2026 18:35
@emilazy
emilazy force-pushed the wip-emily/push-txyvuyysulqv branch from 0dc3e4f to bbd01e9 Compare August 27, 2026 18:37
@emilazy emilazy mentioned this pull request Aug 27, 2026
7 of 13 tasks
This signs the shim with the same vendor certificate that gets embedded
in the shim, which is not what you want for supporting Microsoft Secure
Boot keys. The Microsoft signature will require different handling in
future work, and is blocked on compliance anyway, but this is still
useful for having a uniform bootloader chain and MOK handling.
@emilazy
emilazy force-pushed the wip-emily/push-txyvuyysulqv branch from bbd01e9 to 3c85327 Compare August 27, 2026 18:41
@nixpkgs-ci nixpkgs-ci Bot added the 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. label Aug 27, 2026
@emilazy

emilazy commented Aug 27, 2026

Copy link
Copy Markdown
Member Author

I’ve moved the Nix library from #545457 into this PR, so it can be reviewed alongside the packages that utilize it. I also dropped the .lib, since it would behave weirdly with lib.getLib and seemed like unnecessary verbosity. No substantive changes otherwise.

@emilazy
emilazy changed the base branch from wip-emily/push-nvpsyzzvkvyq to master August 27, 2026 19:07
@nixpkgs-ci nixpkgs-ci Bot closed this Aug 27, 2026
@nixpkgs-ci nixpkgs-ci Bot reopened this Aug 27, 2026
@ElvishJerricco
ElvishJerricco added this pull request to the merge queue Aug 28, 2026
Merged via the queue into master with commit bf581a8 Aug 28, 2026
52 checks passed
@ElvishJerricco
ElvishJerricco deleted the wip-emily/push-txyvuyysulqv branch August 28, 2026 01:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants