137 Commits

Author SHA1 Message Date
Emily
38dec9fcff makeInitrd{,NG}: drop legacy U‐Boot image support
Now that ARMv5 no longer uses `uImage`, there’s no point in keeping
around support for this deprecated format that the rest of the NixOS
infrastructure doesn’t handle. Modern U‐Boot setups should not
be affected in any way by this.
2026-06-01 11:12:44 +10:00
countgitmick
b5d70d2ffb make-initrd-ng: suppress spurious glibc dependency warnings
In Nix, glibc libraries lack rpath entries pointing to themselves,
so libc.so.6 and ld-linux-*.so.* can never be resolved through rpath
alone during initrd generation. They are always present in the initrd
through other paths (the ELF interpreter and other binaries' rpath
entries).

The scripted initrd builder (stage-1.nix findLibs) already skips
ld*.so.? for the same reason. This brings make-initrd-ng in line
with that precedent.

Also removes two unused imports (PermissionsExt, Command) and moves
the remaining warning output from stdout to stderr.

Closes #463894
Closes #282145
Closes #399281
2026-04-08 15:44:53 -07:00
mlyxshi
de5cb839e4 pkgs/build-support/kernel/make-initrd.nix: unsafeDiscardReferences.out = true 2026-02-12 15:24:53 +08:00
mlyxshi
8446dfc3c9 pkgs/build-support/kernel/make-initrd-ng.nix: unsafeDiscardReferences.out = true 2026-02-12 15:18:24 +08:00
nixpkgs-ci[bot]
e1c80e8e08 Merge master into staging-nixos 2026-01-28 00:21:17 +00:00
Alyssa Ross
38082ff4d4 kernel/modules-closure.sh: depmod fails on Linux 6.12+ due to missing modules.builtin.modinfo (#484106) 2026-01-27 12:51:43 +00:00
韶光
7c78262410 kernel/modules-closure: copy modules.builtin.modinfo for depmod
Co-authored-by: Alyssa Ross <hi@alyssa.is>
2026-01-27 18:06:11 +08:00
Stefan Frijters
2bceeb45e5 compressFirmwareZstd: enable __structuredAttrs and fix allowedRequisites 2026-01-25 00:58:08 +01:00
Michael Daniels
006ecdbdeb treewide: fix typos (#479869) 2026-01-24 21:36:44 +00:00
Sergei Trofimovich
26acdb1053 make-initrd: drop unused toValidStoreName local 2026-01-22 22:12:36 +00:00
Ben Siraphob
c7e10647ea treewide: fix typos 2026-01-13 14:45:11 -05:00
Wolfgang Walther
91a8fee3aa treewide: remove redundant parentheses
Auto-fixed by nixf-diagnose.
2025-10-05 10:52:03 +02:00
andre4ik3
216d98ab97 nixos/systemd-initrd: silence various warnings
Silences 2 warning messages that appear when using the systemd initrd:

1. "System tainted (var-run-bad)": occurs because `/var/run` isn't a
   symlink to `/run`. Fixed by making /run and linking /var/run to it.

2. "Failed to make /usr a mountpoint": occurs because ProtectSystem
   defaults to true in the initrd, which makes systemd try to remount
   `/usr` as read-only, which doesn't exist in the initrd. Fixed by
   linking `/usr/bin` and `/usr/sbin` to the initrd bin directories.

Also moves the `/tmp` creation from the initrd module to make-initrd-ng,
to avoid making an unnecessary `/tmp/.keep`, saving a store path and a
few bytes in the initrd image.
2025-08-16 00:28:13 +00:00
Wolfgang Walther
5a0711127c treewide: run nixfmt 1.0.0 2025-07-24 13:55:40 +02:00
Gerg-L
98313e2b81 nixos/systemd-initrd: deprecate strip
It only saved ~1MiB of initramfs size, but caused a few issues
like unloadable kernel modules.
2025-05-08 19:08:14 -04:00
r-vdp
a9c75e7689 make-initrd-ng: fix file permissions
We want to strip the write bit from files after we copied them.
XOR is not the right operator for this, since if the bit is 0 in both
the actual permissions and the mask, then the result will be a 1.
So in practice, we were assigning write permissions for group and others
to all files and we were only stripping the write permissions of the
owner (since the owner had write permissions, and so the result of the
XOR is 0).

The correct thing to do is to AND with the maximum permissions that we
want to maintain (which is the inverse of what we want to strip), so
that only those bits are preserved and the others are always set to 0.
2025-05-08 12:13:50 +02:00
sudoBash418
93b98639dd make-initrd-ng: Restore stripped file permissions
Previously, all initrd ELFs would be made *world-writable*.

This commit sets the write bit for the file owner exclusively, and
removes it when done. It also sets the umask so that files don't
implicitly become writable for other users by mistake.

Fixes: https://github.com/NixOS/nixpkgs/security/advisories/GHSA-m7pq-h9p4-8rr4
Reported-By: sudoBash418 <sudobash418@gmail.com>
2025-04-13 12:02:16 -04:00
nixpkgs-ci[bot]
4733649a15 Merge master into staging-next 2025-03-20 00:15:20 +00:00
Jared Baur
ea116654aa nixos/initrd: add extraFirmwarePaths option
(cherry picked from commit 488d4316b9e1510c9b4a2eeb8d7e2cc66839a1fc)
2025-03-18 20:39:52 -07:00
Philip Taron
711bf412a3 make-initrd: use closureInfo again (#372931) 2025-03-09 18:48:12 -07:00
Dominik Xaver Hörl
e540245ee4 pkgs/pathsFromGraph: drop
Nix 2.* is widely used now, so closureInfo should be used instead.
2025-01-23 16:22:41 +01:00
Dominik Xaver Hörl
7cc5a44a61 make-initrd: use closureInfo 2025-01-23 16:22:41 +01:00
Wolfgang Walther
cf127c9dc3 treewide: load structured attributes in all bash builders consistently
It's hard to put the sourcing of ./.attrs.sh into all builder
consistently - mistakes will happen. Thus, load structured attrs once in
make-derivation and then source the remaining builder on top.

This should fix quite a few builders with structured attributes in
principle. Most importantly it helps substitute / substituteAll, which
are required for bootstrap on some platforms.
2024-12-29 18:36:47 +01:00
Silvan Mosberger
667d42c00d treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev 57b193d8dd
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:27:17 +01:00
Silvan Mosberger
4f0dadbf38 treewide: format all inactive Nix files
After final improvements to the official formatter implementation,
this commit now performs the first treewide reformat of Nix files using it.
This is part of the implementation of RFC 166.

Only "inactive" files are reformatted, meaning only files that
aren't being touched by any PR with activity in the past 2 months.
This is to avoid conflicts for PRs that might soon be merged.
Later we can do a full treewide reformat to get the rest,
which should not cause as many conflicts.

A CI check has already been running for some time to ensure that new and
already-formatted files are formatted, so the files being reformatted here
should also stay formatted.

This commit was automatically created and can be verified using

    nix-build a08b3a4d19.tar.gz \
      --argstr baseRev b32a094368
    result/bin/apply-formatting $NIXPKGS_PATH
2024-12-10 20:26:33 +01:00
Yureka
0f216e2578 tree-wide: switch initrd generators back to gnu cpio
Originally, we switched to bsdtar from libarchive to solve a reproducibility issue related to hardlinks

As of gnu cpio 2.14 the --ignore-dirnlink option is introduced and now included in --reproducible, which solves this issue

By switching back, we are in turn solving an issue in libarchive >=3.7.5 erroring out with "Error reading archive -: (null)"

Change-Id: Ib6140d599b6547d8e941b0251ce996e303c41fa6
2024-10-31 01:21:59 +01:00
Aaron Andersen
c7bb47aac1 makeInitrdNG: fixup contents documentation 2024-09-10 15:31:48 -04:00
Jörg Thalheim
3de4714572 make-initrd-ng: also print json itself if it fails to parse
The current error message is hard to debug because the error is in the
nix store:

> Error: failed to parse JSON in
"/build/.attr-1s42g1c76fxb77skzq0b4wdhcrg8jmzb54czmxvh1qm7psgsbcni"
>
> Caused by:
> missing field `source` at line 1 column 102
>
> Location:
> src/main.rs:329:10
2024-08-02 10:24:34 +02:00
Will Fancher
6f959a9e96 nixos/make-initrd-ng: dlopen ELF notes 2024-07-21 06:31:42 -04:00
Will Fancher
e6c544270c nixos/make-initrd-ng: Pass contents as JSON 2024-07-21 06:31:42 -04:00
Krzysztof Nazarewski
4ede20cc6f makeModulesClosure: include /lib/firmware/edid
modules-closure.sh seems to consider everything under
 /lib/firmware to be a kernel module,
 this change adds a special handling of `edid` directory,
 which does not contain kernel modules

fixes #279739
2024-07-18 16:57:18 +03:00
jade
b8946c1bf2 Merge pull request #319220 from ExpidusOS/fix/test-infinite-recurse
Fix failures with pkgs/top-level/release-attrpaths-superset.nix
2024-06-30 09:00:23 -07:00
Linus Heckemann
e5adf0b547 maintainers: drop lheckemann 2024-06-21 15:54:54 +02:00
Tristan Ross
23ce5265d0 pkgs/build-support/kernel/make-initrd.nix: fix eval for test on darwin 2024-06-14 18:38:45 -07:00
Maximilian Bosch
b6ef9ffdfd nixos/udev: compress firmware with zstd if possible
Closes #267442

    $ nix path-info -Sh /nix/store/qj1dm7wfw5m3mxf1gn3fdm0az9y1h5ny-linux-firmware-20240312-xz
    /nix/store/qj1dm7wfw5m3mxf1gn3fdm0az9y1h5ny-linux-firmware-20240312-xz	440.3M
    $ nix path-info -Sh /nix/store/c3szcjxb3g990dbiz7llwmkaf0bi98j2-linux-firmware-20240312-zstd
    /nix/store/c3szcjxb3g990dbiz7llwmkaf0bi98j2-linux-firmware-20240312-zstd	460.6M

This is an increase of 4.4%, but OTOH zstd has a significantly higher
decompression speed[1].

[1] https://gregoryszorc.com/blog/2017/03/07/better-compression-with-zstandard/
2024-04-19 16:46:25 +02:00
Maximilian Bosch
378177d269 linux kernel: prefer zstd where possible
Closes #302291
Closes #301536

The following things have changed:

* For 5.7+: ZSWAP compressor uses zstd now.
* For 5.11+: ZRAM compressor uses zstd now.
* For 5.13+: kernel modules are compressed with zstd instead of xz.
* For 5.19+: support zstd-compressed firmware.

The modules-closure functionality needed explicit support for copying
over `.zst` files. Also, the VM image builder used busybox's `insmod`
before which doesn't support zstd. Switched to `kmod` and added xz/zstd
as dependencies for it, similar to how it's done for the actual stage1
in d33e52b253. The use of `kmod` here
doesn't seem to be such a big deal since it's only a build-time
dependency.
2024-04-19 16:45:35 +02:00
Will Fancher
6504cbb171 Merge pull request #288212 from r-ryantm/auto-update/makeInitrdNGTool
makeInitrdNGTool: 0.1.0 -> 0.1.0
2024-03-27 00:43:03 -04:00
stuebinm
ff1a94e523 treewide: add meta.mainProgram to packages with a single binary
The nixpkgs-unstable channel's programs.sqlite was used to identify
packages producing exactly one binary, and these automatically added
to their package definitions wherever possible.
2024-03-19 03:14:51 +01:00
R. Ryantm
2214a3f6e4 makeInitrdNGTool: 0.1.0 -> 0.1.0 2024-02-12 05:11:50 +00:00
Will Fancher
f8781c3668 Merge pull request #283770 from r-ryantm/auto-update/makeInitrdNGTool
makeInitrdNGTool: 0.1.0 -> 0.1.0
2024-02-10 22:19:21 -05:00
Alyssa Ross
59fca7cb67 compressFirmwareXz: don't allow references 2024-01-28 11:57:38 +01:00
Alyssa Ross
24bb06069f compressFirmwareXz: fail on broken symlinks
This would have caught the last two issues we had with compression.
2024-01-28 11:57:37 +01:00
Alyssa Ross
a136def4f7 compressFirmwareXz: fix symlink type check
The previous version didn't work in the case of relative symlinks in
subdirectories.  If "foo/bar" was a link to "baz", it would check for
a link to "baz" in the root, rather than under "foo".

We don't need to dereference the symlink ourselves for [ anyway, as it
dereferences its arguments itself, so all we need to do to fix this is
to pass it the link.

Fixes: 14f83d5c6f ("compressFirmwareXz: fix links to directories")
2024-01-28 11:57:30 +01:00
R. Ryantm
d4e775bd1a makeInitrdNGTool: 0.1.0 -> 0.1.0 2024-01-25 13:37:20 +00:00
Franz Pletz
14f83d5c6f compressFirmwareXz: fix links to directories
Only add the `.xz` suffix to links if link target is a regular file.
This breaks if the target is a directory.

Fixes #283005.
2024-01-23 07:16:59 +01:00
R. Ryantm
19b4bac3d0 makeInitrdNGTool: 0.1.0 -> 0.1.0 2024-01-07 10:39:28 +00:00
R. Ryantm
5ff7811393 makeInitrdNGTool: 0.1.0 -> 0.1.0 2024-01-01 20:10:05 +00:00
Atemu
d7b70652ef Merge pull request #272125 from yaxitech/reproducible-initrd
make-initrd-ng: fix reproducibility problems
2023-12-24 11:53:33 +01:00
R. Ryantm
d2ffb24948 makeInitrdNGTool: 0.1.0 -> 0.1.0 2023-12-16 14:58:17 +00:00
Andreas Stührk
4084ee0cd5 make-initrd-ng: fix reproducibility problems
The previous find invocation didn't match the root directory, so the
root directory's access and modification time wasn't set to a
deterministic value and the build time leaked into the output.

`make-initrd` replaced `cpio` with `bsdtar` in #165892 because the
former includes the number of hardlinks in the created archive, which
depends on the filesystem (and can also be influenced by `nix-store
--optimise`). The same problem applies to `make-initrd-ng`, so this
commit replaces `cpio` with `libarchive`'s `bsdtar`.
2023-12-04 19:23:06 +01:00