Commit graph

535 commits

Author SHA1 Message Date
Lee Bousfield a5082278a9
nixos/systemd-boot: use /dev/null for empty file
Previously, mktemp was used, but it's not necessary and wasn't deleted.
2025-10-10 19:45:21 -05:00
Sizhe Zhao 3fbc40c0ac
nixos/limine: forceMbr -> force 2025-10-06 21:48:31 +08:00
sternenseemann 85c7452e80 nixos/systemd-boot: fsync() copied files
Since mkstemp() gives us a file descriptor, we may as well call fsync().
2025-09-24 01:35:51 +02:00
sternenseemann 94c190a55c nixos/systemd-boot: atomically update copied destination files
We absolutely do not want to leave an incomplete file behind in /boot
since an incomplete initrd would render the machine unbootable. Errors
while writing are relatively common, mostly due to full /boot
partitions.

systemd-boot-builder does never attempt to re-write already existing
files which means that such situations are not fixable by re-running
nixos-rebuild etc. Instead the user needs to know about internals of the
systemd-boot and manually delete the correct file to recover from a
partially written kernel or (more commonly) initrd in /boot.

Note that this used to be a non issue since systemd-boot-builder used to
always delete all kernels and initrds before copying kernels and
initrds, so dest.exist() would always return False. This was fixed in
f2ca990558, revealing the underlying bad
assumption (that copyfile() always succeeds or fails without writing
anything).

The solution is to write to a temporary file first and move it to the
destination path only after this has succeeded. This way, if an error
occurs during copying, only a file distinct from dest is left behind
which would be cleaned up by subsequent runs of remove_old_entries().

Resolves #444066.
2025-09-24 01:00:44 +02:00
r-vdp c4753ff331
nixos/systemd-boot-builder: make sure to print informational messages to stderr
Otherwise this gets printed to stdout when running things like
nixos-rebuild, while people rely on the toplevel store path being the only
output of such commands.
2025-09-15 10:19:15 +02:00
Rane 77448445c1 nixos/limine: fix install script when using Xen with EFI (#441473) 2025-09-10 08:55:40 +10:00
John Titor 5d9e8f43d7 nixos/refind: allow use only on UEFI platforms 2025-09-06 12:29:15 +05:30
Tristan Ross 062b58f36f nixos/refind: init 2025-09-06 12:29:15 +05:30
Jared Baur 231bf43f72
nixos/systemd-boot-builder: remove old devicetree files (#439585) 2025-09-03 15:33:13 +01:00
Jeremy Fleischman 683d9e3b54
nixos/systemd-boot-builder: remove old devicetree files
I just stumbled across this during code inspection. I haven't tested
this at all.
2025-09-03 13:35:57 +01:00
Acid Bong 68dacf00f4 nixos/limine: use SBctl from the option 2025-09-03 01:12:09 +05:30
Rane 647c04f2e9 nixos/limine: Add support for booting Xen 2025-08-30 14:43:43 +10:00
dish 970dcca69c
treewide: Fix links in module documentation 2025-08-25 12:55:11 -04:00
Luj 30f409ed23
nixos/systemd-boot-builder: use pathlib.Path where possible (#434767) 2025-08-22 10:27:08 +01:00
K900 31d5c4e753 nixos/treewide: clean up some more references to deleted qt5 things 2025-08-22 11:38:49 +03:00
Linus Heckemann f2ca990558 nixos/systemd-boot-builder: use pathlib.Path where possible
`switch-to-configuration boot` was taking suspiciously long on a machine
of mine where the boot partition is on a slow SD card. Some tracing led
me to discover that it was in fact deleting all the kernels and initrds
every time, only to rewrite them.

This turned out to be because of the naive (non-path-normalising) string
concatenation used to construct paths in `known_paths`, so all the files
were recognised as obsolete and deleted:


known_paths=['/EFI/nixos/5jz3m9df1cbxn4hzjjs3aaz8lb9vvimc-linux-6.15.7-Image.efi', '/EFI/nixos/xri8qzfvzclf89x7nfwgq248miw7jbp0-initrd-linux-6.15.7-initrd.efi', '/EFI/nixos/b18llskzrcdgw2nbib58qqcaabiik6yc-linux-6.16-Image.efi', '/EFI/nixos/mdj53j746bii1vw227dfhkyd8ajwab2w-initrd-linux-6.16-initrd.efi', '/EFI/nixos/b18llskzrcdgw2nbib58qqcaabiik6yc-linux-6.16-Image.efi', '/EFI/nixos/mdj53j746bii1vw227dfhkyd8ajwab2w-initrd-linux-6.16-initrd.efi', '/EFI/nixos/b18llskzrcdgw2nbib58qqcaabiik6yc-linux-6.16-Image.efi', '/EFI/nixos/mdj53j746bii1vw227dfhkyd8ajwab2w-initrd-linux-6.16-initrd.efi', '/EFI/nixos/5jz3m9df1cbxn4hzjjs3aaz8lb9vvimc-linux-6.15.7-Image.efi', '/EFI/nixos/1ihk03c1i5518hlgm5mnhrig2hy3hq24-initrd-linux-6.15.7-initrd.efi', '/EFI/nixos/5jz3m9df1cbxn4hzjjs3aaz8lb9vvimc-linux-6.15.7-Image.efi', '/EFI/nixos/1ihk03c1i5518hlgm5mnhrig2hy3hq24-initrd-linux-6.15.7-initrd.efi', '/EFI/nixos/5jz3m9df1cbxn4hzjjs3aaz8lb9vvimc-linux-6.15.7-Image.efi', '/EFI/nixos/1ihk03c1i5518hlgm5mnhrig2hy3hq24-initrd-linux-6.15.7-initrd.efi']
path='/boot//EFI/nixos/5jz3m9df1cbxn4hzjjs3aaz8lb9vvimc-linux-6.15.7-Image.efi'
path='/boot//EFI/nixos/xri8qzfvzclf89x7nfwgq248miw7jbp0-initrd-linux-6.15.7-initrd.efi'
path='/boot//EFI/nixos/b18llskzrcdgw2nbib58qqcaabiik6yc-linux-6.16-Image.efi'
path='/boot//EFI/nixos/mdj53j746bii1vw227dfhkyd8ajwab2w-initrd-linux-6.16-initrd.efi'
path='/boot//EFI/nixos/1ihk03c1i5518hlgm5mnhrig2hy3hq24-initrd-linux-6.15.7-initrd.efi'


This can be avoided by using pathlib.Path, which normalises paths and
generally provides a more consistent and convenient API. I therefore
went ahead and replaced all use of `str` for path handling with `Path`
in the builder. This may fix some other, similar bugs, as well, but I
haven't checked in detail.
2025-08-18 20:11:57 +02:00
Colin d538aa4a55
nixos/grub: install memtest and other grub.extraFiles correctly when using mirroredBoots (#420861) 2025-08-15 19:01:26 +00:00
Alex Lyon 38ee02a873 nixos/limine: fix installation when using initrd secrets 2025-08-01 21:59:49 +05:30
Will Fancher 4b3b18a44f
nixos/systemd-boot: refactor json.load() logic for better error message (#421916) 2025-07-27 23:08:42 -04:00
jack dedf852ccd nixos/systemd-boot: refactor json.load() logic for better error message 2025-07-27 13:05:03 +02:00
Wolfgang Walther 5a0711127c
treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Wolfgang Walther 62fe016519
treewide: run treefmt with mdcr/nixfmt 2025-07-24 13:52:31 +02:00
sanana 6baed48380 limine-install: fix profile enumeration
Fixes #425158.
2025-07-15 13:49:05 +05:30
Shelvacu 8f0f76a32c nixos/grub: install memtest and other grub.extraFiles correctly when using mirroredBoots 2025-06-28 15:01:00 -07:00
Masum Reza a2b5af4710
limine-install: cleanup, improve type hinting (#416188) 2025-06-23 23:08:45 +05:30
Masum Reza 4c902775b8
nixos/limine: make the install script more resilent (#413390) 2025-06-03 20:40:14 +05:30
programmerlexi 2c673b6e67
nixos/limine: fix boot entry not being created properly (#410935) 2025-05-26 13:19:36 +05:30
John Titor 88d5e40fcb
limine, nixos/limine, nixosTests.limine: inherit pkgs.limine maintainers
also adds @programmerlexi to limine package maintainers

Signed-off-by: John Titor <50095635+JohnRTitor@users.noreply.github.com>
2025-05-23 15:06:50 +05:30
hustlerone de6905ee37 nixos/limine: tidy up the boot menu 2025-05-22 20:45:00 +05:30
Paul Haerle 190ee55caa
systemd-boot: improve error message if no previous systemd boot is fo… (#409073) 2025-05-22 00:54:16 +02:00
programmerlexi 95030d7eb3 nixos/limine: don't modify boot order on bootloader update 2025-05-21 23:17:42 +05:30
programmerlexi 36ecfe6216 nixos/limine: add support for secure boot
Signed-off-by: John Titor <50095635+JohnRTitor@users.noreply.github.com>
2025-05-21 21:59:23 +05:30
programmerlexi a094b5d8cc nixos/limine: carefully remove files instead of nuking them 2025-05-21 15:22:45 +05:30
programmerlexi 2c7659b1ff nixos/limine: atomically copy files 2025-05-21 15:22:45 +05:30
Jörg Thalheim b6c1663986 systemd-boot: improve error message if no previous systemd boot is found. 2025-05-20 15:39:07 +02:00
nat e51e0da386
nixos/limine: substituteAll -> replaceVarsWith 2025-05-13 23:14:43 +02:00
Raito Bezarius 139bfb5b5e nixos/system/activation/bootspec: generalize the bootspec tooling package
After RFC-0125 implementation, Determinate Systems was pinged multiple
times to transfer the repository ownership of the tooling to a
vendor-neutral repository.

Unfortunately, this never manifested. Additionally, the leadership of
the NixOS project was too dysfunctional to deal with this sort of
problem. It might even still be the case up to this day.

Nonetheless, nixpkgs is about enabling end users to enact their own
policies. It would be better to live in a world where there is one
obvious choice of bootspec tooling, in the meantime, we can live in a
world where people can choose their bootspec tooling.

The Lix forge possess one fork of the Bootspec tooling:
https://git.lix.systems/lix-community/bootspec which will live its own
life from now on.

Change-Id: I00c4dd64e00b4c24f6641472902e7df60ed13b55
Signed-off-by: Raito Bezarius <masterancpp@gmail.com>
2025-04-24 18:22:02 +02:00
Silvan Mosberger 374e6bcc40 treewide: Format all Nix files
Format all Nix files using the officially approved formatter,
making the CI check introduced in the previous commit succeed:

  nix-build ci -A fmt.check

This is the next step of the of the [implementation](https://github.com/NixOS/nixfmt/issues/153)
of the accepted [RFC 166](https://github.com/NixOS/rfcs/pull/166).

This commit will lead to merge conflicts for a number of PRs,
up to an estimated ~1100 (~33%) among the PRs with activity in the past 2
months, but that should be lower than what it would be without the previous
[partial treewide format](https://github.com/NixOS/nixpkgs/pull/322537).

Merge conflicts caused by this commit can now automatically be resolved while rebasing using the
[auto-rebase script](8616af08d9/maintainers/scripts/auto-rebase).

If you run into any problems regarding any of this, please reach out to the
[formatting team](https://nixos.org/community/teams/formatting/) by
pinging @NixOS/nix-formatting.
2025-04-01 20:10:43 +02:00
Luj e21904681e
nixos/systemd-boot: strip newline from machine-id (#375298) 2025-03-24 11:06:53 +01:00
Angelo Bulfone 9ed29c65a4
nixos/limine: Fix reading generations and specialisations
Previously, all generations for the primary system profile
read their data from the currently active one rather than
their own path, and specialisations in general all used
their parent bootspec rather than their own. This fixes both issues.

This commit still uses the parent path's build date for
specialisations, but this is more minor issue and the times
shouldn't be meaningfully different in most cases anyways.
2025-03-19 15:19:41 -07:00
programmerlexi 1a830fe9d9 nixos/limine: fix the install script 2025-03-18 01:06:55 +05:30
Rane 2cc1d33489
nixos/limine: cast partition index to string (#390732) 2025-03-18 01:01:15 +05:30
programmerlexi 12779dc091
nixos/limine: init module
Co-Authored-By: Gabriel Waksmundzki <czapek1337@gmail.com>
2025-03-06 08:05:08 +01:00
Samuel Dionne-Riel 6ec6eae586
Revert "nixos/grub: generate BLS entries" 2025-02-28 14:30:10 -05:00
rnhmjoj 435a72e469
nixos/grub: generate BLS entries 2025-02-28 09:51:20 +01:00
nixpkgs-ci[bot] 3a870eb511
Merge master into staging-next 2025-02-19 18:04:49 +00:00
Jörg Thalheim 39dd19122f install-grub: add missing rmtree 2025-02-19 14:33:46 +07:00
nixpkgs-ci[bot] 83f409d731
Merge master into staging-next 2025-02-18 06:04:52 +00:00
Jörg Thalheim 5be6db6b3d
grub modernize (#374844) 2025-02-18 13:03:24 +07:00
Jared Baur 3de7bccd4a
nixos/systemd-boot: strip newline from machine-id
To make each line in the entry file consistent, strip the newline from
the machine-id content.
2025-02-13 18:52:14 -08:00