593 Commits

Author SHA1 Message Date
phanirithvij 4abe0c81a7 various: replace deprecated os.system with subprocess calls
Signed-off-by: phanirithvij <phanirithvij2000@gmail.com>
2026-07-13 16:27:07 +05:30
Florian Klink 22ef2ba154 nixos/limine: fix location for boot.loader.limine.additionalFiles
The documentation describes this as a set of files copied to /boot, with
the attribute name denoting the destination file name in /boot.

This uses essentially the same description as refind, systemd-boot and
grub. However limine put it into limine_install_dir (/boot/limine by
default) by accident, which broke downstream users.

For example, nixos-apple-silicon uses boot.loader.limine.additionalFiles
(and similar directives for other bootloaders) to update its m1n1
bootloader (which chainloads into u-boot, which chainloads into the
bootloader selected in NixOS), and due to this bug, put new versions of
it in the wrong location, effectively never updating m1n1.

Fix this, by updating the location. The next commit adds a regression VM
test for it.
2026-07-07 23:14:45 +03:00
r-vdp bb258c2dbe nixos/systemd-boot: update via Varlink instead of parsing bootctl status
systemd v261 lists the new systemd-boot-fallback binary in `bootctl
status`, so our regex picked up the older fallback version and ran
`bootctl update` on an already current ESP, which then exits non-zero.

Switch from parsing the `bootctl --status` output to having bootctl
compare versions itself by calling io.systemd.BootControl.Install over
Varlink. bootctl is spawned as a stdio Varlink server so that we always
use the bootctl from the target closure. An already current binary comes
back as an io.systemd.System error carrying ESTALE, which we treat as
success.
2026-07-01 12:08:51 +02:00
r-vdp 5f267f4dda nixos/boot: allow passing extra initrd archives to the bootloader
This is for instance useful on Asahi where an additional initrd archive
containing firmware blobs and per-device calibration files is placed
on the ESP and updated by the Asahi Linux Installer.
These need to be loaded alongside the NixOS initrd.

Implemented for systemd-boot and Limine. Grub is left out since its
install script does not use bootspec yet.

Co-authored-by: Florian Klink <flokli@flokli.de>
2026-06-26 13:39:08 +03:00
r-vdp 5640e1f935 nixos/limine: add extraInstallCommands option
Allows running additional shell commands after the limine install script
generates menu entries, mirroring the systemd-boot option of the same
name.

Co-authored-by: Florian Klink <flokli@flokli.de>
2026-06-25 22:58:22 +02:00
r-vdp b3a73f17ba nixos/limine: format the install script 2026-06-22 16:21:35 +02:00
Masum Reza 0c505d8bfa nixos/limine: fix secure boot key generation when using impermanence (#514762) 2026-06-17 04:57:48 +00:00
Arian van Putten f9335936bc nixos/bootspec: remove enable option (#530066) 2026-06-10 19:34:34 +00:00
Alyssa Ross 2d18606282 lib/systems: move kernel configuration out of the platform structure (#530133) 2026-06-10 17:39:49 +00:00
Emily 31d1d80b3f lib/systems: move kernel configuration out of the platform structure
Currently, you need to override `stdenv.hostPlatform` to request a
compressed kernel on AArch64, and the kernel configuration is split
between the central structured configuration and string snippets in
platform definitions. This has consequently made the latter bitrot
terribly. Since the platform‐specific logic is now very limited after
cleaning up the detritus, we can move it into the kernel derivation
and expose the relevant configuration there for anyone who wants to
customize it further or needs to read it out.

Co-authored-by: zowoq <59103226+zowoq@users.noreply.github.com>
2026-06-10 11:17:38 +10:00
r-vdp dff88cbd79 nixos/systemd-boot: drop bootspec synthesize fallback
Older generations without boot.json are skipped with a
warning.
2026-06-09 22:03:07 +03:00
Masum Reza 4b59bc72ab nixos/limine: fix fwupd-efi signing script under strict shell checks (#526918) 2026-06-09 16:37:53 +00:00
r-vdp 919b70b29f nixos/systemd-boot: refuse to wipe ESP when no generations found 2026-06-05 18:01:06 +03:00
r-vdp 9eb570f453 nixos/systemd-boot-builder: drop unused BootFile.{current,system_identifier}
Both fields are now write-only after the previous two commits, so
remove them. BootFile is back to being just a (path, writer) pair.
2026-06-02 12:20:55 +03:00
r-vdp c38ca6ab7d nixos/systemd-boot-builder: handle initrd-secrets failure in the writer
The CalledProcessError can only come from the append-initrd-secrets
script, so catching it in the generic write loop and then asserting
on the writer type to reach back into its `source` is the wrong
layer. Move the catch, the pristine-initrd fallback and the warning
into InitrdWithSecretsWriter itself, and pass `critical` through the
writer protocol so it can decide between aborting and falling back.

The writer carries the generation number so the warning can still
name the affected generation. write_boot_files no longer knows
anything about secrets and the isinstance assertion is gone.

Suggested-by: Will Fancher <elvishjerricco@gmail.com>
2026-06-02 12:20:55 +03:00
r-vdp 9d46e91c49 nixos/systemd-boot-builder: track critical paths separately from BootFile
Whether a write failure must be fatal is a property of the destination
path (is it needed by the configuration we are switching to?), not of
the particular BootFile instance that happened to survive
deduplication. Compute the set of critical paths up front and look it
up in write_boot_files, so the dedup loop no longer needs to pick the
"right" instance and becomes a plain order-preserving seen-set walk.

This leaves BootFile.current unused.

Suggested-by: Will Fancher <elvishjerricco@gmail.com>
2026-06-02 12:20:55 +03:00
r-vdp dff3315fac nixos/systemd-boot-builder: use with for the secrets temp file
This guarantees the descriptor is closed even when copyfileobj raises,
matching the other writer implementations. The append-initrd-secrets
script reopens the file by path, so flush() is enough before invoking
it and the explicit close() is no longer needed.
2026-06-02 12:20:55 +03:00
r-vdp 30552ab00b nixos/systemd-boot-builder: clarify stale initrd secrets warning
Tell the user what actually happens (the old secrets stay in place) and
how to get rid of the warning, instead of just saying it is "normal".

Suggested-by: Will Fancher <elvishjerricco@gmail.com>
2026-06-02 12:20:54 +03:00
r-vdp b4e756627d nixos/systemd-boot-builder: write each ESP path only once
Shared kernels and initrds appear once per generation in boot_files, so
InitrdWithSecretsWriter rebuilt the same file repeatedly. Prefer the
current configuration's entry so its failures stay fatal.
2026-06-02 12:20:54 +03:00
r-vdp 76673e2736 nixos/systemd-boot-builder: fall back to pristine initrd when secrets fail
Otherwise the .conf for that generation references a missing initrd and
the boot entry fails to load.
2026-06-02 12:20:54 +03:00
r-vdp 3ff32972f8 nixos/systemd-boot-builder: verify content of existing entry files
A file named nixos-<hash>.conf whose content no longer hashes to <hash>
is corrupt. Skip it so GC removes it and a fresh entry is written.
2026-06-02 12:20:54 +03:00
r-vdp 820d20f8b9 nixos/systemd-boot-builder: cache boot_path()
It calls Path.resolve() and is invoked several times per generation for
the same store paths.
2026-06-02 12:20:53 +03:00
r-vdp 85d59c4f3d nixos/systemd-boot-builder: use a set for GC root lookup
has_gc_root() iterated the entire BootFileList for every file on the
ESP, giving O(files * roots) comparisons. Build the set of kept paths
once and use O(1) membership tests instead.
2026-06-02 12:20:53 +03:00
r-vdp 146acf965f nixos/systemd-boot-builder: warn instead of aborting when an old gen's secrets fail
After removing or renaming a file in boot.initrd.secrets, older
generations' append scripts start failing. Aborting on that blocks
deploying the new configuration, so only treat a failure as fatal when
it belongs to the configuration being switched to.
2026-06-02 12:20:53 +03:00
r-vdp 6eba7d60f3 nixos/systemd-boot-builder: rebuild secret-bearing initrds atomically each run
Appending to the existing file made it grow on every rebuild and a
failed script could leave it half-written. Always rebuild from the
pristine initrd into a temp file and rename into place.
2026-06-02 12:20:53 +03:00
r-vdp 6ef460ec9d nixos/systemd-boot-builder: write loader.conf after the entries it points at
A crash between the two would leave `default <id>` referring to a
.conf that does not exist yet.
2026-06-02 12:20:53 +03:00
Will Fancher 44a974d0eb nixos/systemd-boot: Rerun secrets every switch 2026-06-02 12:20:52 +03:00
Will Fancher 1d081050c3 nixos/systemd-boot: Separate finding the placement of files from writing files 2026-06-02 12:20:52 +03:00
r-vdp b4c278c06b nixos/systemd-boot-builder: store boot loader configs using content hashing
Co-Authored-By: AkechiShiro <14914796+AkechiShiro@users.noreply.github.com>
2026-06-02 12:20:51 +03:00
r-vdp 69ce6b2391 nixos/systemd-boot-builder: re-instate boot counting
Co-Authored-By: Julien Malka <julien@malka.sh>
Co-Authored-By: AkechiShiro <14914796+AkechiShiro@users.noreply.github.com>
2026-06-02 12:20:12 +03:00
r-vdp ac2410be5d nixos/systemd-boot-builder: format 2026-06-02 12:20:12 +03:00
Aliaksandr e5ec5c94d8 nixos/limine: fix fwupd-efi signing script under strict shell checks
The signing service builds `fwupd_efi` as a bash array but referenced
it as a scalar, tripping SC2128 (array expanded without index) and
SC2046 (unquoted command substitution). With enableStrictShellChecks
these are promoted to errors, breaking the unit-script build when
secureBoot, fwupd and strict shell checks are all enabled.

Loop over the array and sign every matched fwupd EFI binary, quoting
the basename and the -o argument. Indexing a single element would
silently skip any additional files the glob matches.

Assisted-by: claude-code with claude-opus-4-8[1m]-high
2026-06-02 02:46:28 +03:00
Viktor Fedorov c982604bb8 nixos/limine: correct timeout logic
Although the documentation for `boot.loader.timeout` says to use `null` for an indefinite display, in limine nixos module it incorrectly sets `10` instead of `no`. https://github.com/Limine-Bootloader/Limine/blob/v12.x/CONFIG.md
2026-05-23 19:30:36 +02:00
Ryan Omasta 94a009f821 nixos/limine: fix option_from_config to use yes/no values 2026-05-07 21:05:54 -06:00
Ryan Omasta 833fe2d511 nixos/limine: add helpColor and helpColorBright options 2026-05-02 14:30:55 -06:00
programmerlexi 027454c0ee nixos/limine: fix secure boot key generation when using impermanence 2026-04-29 17:48:42 +02:00
Sizhe Zhao bea3efecfa nixos/limine: disable editor for secure boot 2026-04-26 10:51:51 +08:00
Léana 江 3a8c4e697c nixos/limine: pass distroName using JSON 2026-04-05 14:28:35 +02:00
Léana 江 450c46303f nixos/limine: show config.system.nixos.distroName value in menu
Previously the entry section always shows "NixOS".
Now it would show the value configured in config.system.nixos.distroName.
2026-04-04 10:57:57 +02:00
Masum Reza 21601ecc68 nixos/limine: add settings autoGenerateKeys & autoEnrollKeys (#486777) 2026-04-03 18:12:28 +00:00
Thomas Gerbet 915093332c nixos/grub: re-install grub on package change (#495788) 2026-03-26 09:33:45 +00:00
Vladimír Čunát d6acf1b543 Revert "nixos/initrd: refactor secrets option into secretPaths and extraSecretsHook" 2026-03-21 15:58:52 +01:00
nixpkgs-ci[bot] 83fd733037 Merge master into staging-next 2026-03-20 00:24:19 +00:00
Josh Hoffer b62dba13c6 nixos/systemd-boot: set strict error handling in installer script
Previously, if `boot.loader.systemd-boot.extraInstallCommands`
was non-empty, errors from `systemdBootBuilder` would be ignored.
2026-03-18 11:17:16 -07:00
lwb c3f0c3ec35 nixos/limine: add settings autoGenerateKeys & autoEnrollKeys 2026-03-07 12:16:33 +08:00
Oliver Schmidt 41997d49da nixos/grub: re-install grub on package change
Trigger re-installation of grub files when the store path of the grub
package changes.
This is consistent with how side-effects are executed in other parts of
NixOS, e.g. systemd service management, and ensures that the actually
running grub stays in sync with the grub package in the Nix store that
is part of the system closure.
In particular, this causes security patches or dependency changes to be
taken into effect without the need to bump the package version.

Impact:
This change causes a re-installation of grub for all systems,
due to the lack of a persisted grub store path in existing state files.

Background:
So far we only re-installed grub outside of the store when its its
version, the package name, or some flags changed.
This leads to the various security patches only fixing new installations
of grub and not existing ones. This has been like this for over a decade,
but it remains unclear why the implementation decision had been to
be overly cautious with modifying boot loader side effects.

Fixes #486315

PL-135147
2026-03-02 11:51:26 +01:00
cyclopentane 9ddcf0365c nixos/treewide: replace boot.initrd.secrets with boot.initrd.secretPaths 2026-02-24 21:38:41 +01:00
cyclopentane 72e4df576e nixos/initrd: add secretPaths and extraSecretsHook 2026-02-24 21:38:40 +01:00
programmerlexi 081365d23d nixos/limine: change name of signed fwupd file 2026-02-13 13:50:31 +01:00
Dyego Aurélio 28096cc5e3 treewide: apply nixfmt 1.2.0 2026-01-22 18:37:56 -03:00