Commit Graph

110 Commits

Author SHA1 Message Date
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
Alyssa Ross
1557027e33 makeModulesClosure: handle firmware glob patterns
A handful of kernel modules use glob patterns to express their
firmware dependencies.  (`git grep 'MODULE_FIRMWARE.*\*'`)

Previously, we weren't handling these patterns.  Now, we are.
2023-11-29 16:03:16 +01:00
R. Ryantm
8c15911d79 makeInitrdNGTool: 0.1.0 -> 0.1.0 2023-11-23 13:26:47 +00:00
Will Fancher
18013cc71e systemd-stage-1: Use specific fs packages 2023-10-19 21:13:22 -04:00
R. Ryantm
3876a545ed makeInitrdNGTool: 0.1.0 -> 0.1.0 2023-10-11 02:44:30 +00:00
Adam Joseph
a97e8fc272 make-initrd-ng: use hostPlatform.ubootArch for uinitrdArch
This allows make-initrd-ng to pick up the few cases where Linux and
u-boot disagree.
2023-08-14 01:34:08 -07:00
Felix Bühler
0a2745684e
Merge pull request #239624 from Stunkymonkey/use-optionalString-then
treewide: use optionalString instead of 'then ""'
2023-07-22 13:02:47 +02:00
rnhmjoj
4124eb7bd5
compressFirmwareXz: preserve meta attributes
Among other things, this preserves the package priority, which is
important when building the `hardware.firmware` environment in NixOS.
2023-06-25 11:08:32 +02:00
Felix Buehler
f3719756b5 treewide: use optionalString instead of 'then ""' 2023-06-24 20:19:19 +02:00
Cole Helbling
3e63608c7b makeInitrdNGTool: better errors
It's extremely frustrating seeing "Error: Os { code: 13, kind:
PermissionDenied, message: "Permission denied" }" without any hint as to
where exactly that occurred.

This commit fixes that by adding context to most errors.
2023-05-25 13:26:05 -07:00
Will Fancher
762b69f2ff systemd-initrd: Fix up root directory mode 2023-04-11 15:20:47 -04:00
Lily Foster
d01bc6f9cb
make-initrd-ng: document wrapped file behavior 2023-02-20 07:02:55 -05:00
Lily Foster
4df8f9a2f8
make-initrd-ng: support wrapped executables 2023-02-20 07:02:55 -05:00
Artturin
341e6fd558 splice.nix: start deprecating nativeDrv and crossDrv 2022-11-19 00:04:54 +02:00
K900
de93795b46 make-initrd-ng: clean up a bit 2022-08-02 10:54:55 +03:00
Linus Heckemann
ee38010981 makeInitrdNG: add meta and update script 2022-08-02 10:54:55 +03:00
Linus Heckemann
6fc909a1cc makeInitrdNG: make stripping fully optional
Now the tool will only strip binaries if a strip executable is passed
via the STRIP environment variable. This is exposed via the strip
option for makeInitrdNG and the NixOS option boot.initrd.systemd.strip.
2022-08-02 10:19:48 +03:00
K900
daee67dae6 make-initrd-ng: use goblin instead of shelling out to patchelf and friends 2022-08-02 10:19:48 +03:00
K900
1356441cb1 make-initrd-ng: rustfmt 2022-08-02 10:19:48 +03:00
Alyssa Ross
76405e3077
compressFirmwareXz: fix with empty lib/firmware
Fixes: 8aa8e0ce7f ("nixos/udev: compress all firmware if supported")
2022-05-26 07:08:50 +00:00
Alyssa Ross
8aa8e0ce7f
nixos/udev: compress all firmware if supported
This should be a significant disk space saving for most NixOS
installations.  This method is a bit more complicated than doing it in
the postInstall for the firmware derivations, but this way it's
automatic, so each firmware package doesn't have to separately
implement its compression.

Currently, only xz compression is supported, but it's likely that
future versions of Linux will additionally support zstd, so I've
written the code in such a way that it would be very easy to implement
zstd compression for those kernels when they arrive, falling back to
xz for older (current) kernels.

I chose the highest possible level of compression (xz -9) because even
at this level, decompression time is negligible.  Here's how long it took
to decompress every firmware file my laptop uses:

	i915/kbl_dmc_ver1_04.bin                  	2ms
	regulatory.db                             	4ms
	regulatory.db.p7s                         	3ms
	iwlwifi-7265D-29.ucode                    	62ms
	9d71-GOOGLE-EVEMAX-0-tplg.bin             	22ms
	intel/dsp_fw_kbl.bin                      	65ms
	dsp_lib_dsm_core_spt_release.bin          	6ms
	intel/ibt-hw-37.8.10-fw-22.50.19.14.f.bseq	7ms

And since booting NixOS is a parallel process, it's unlikely (but
difficult to measure) that the time to user interaction was held up at
all by most of these.

Fixes (partially?) #148197
2022-05-13 14:36:34 +00:00
Janne Heß
e5995b2235
makeInitrdNG: Strip more and remove output
This strips all elf files as far as possible and removes a lot of
unnecessary output. Also wrap in the binaries instead of relying on
$PATH.
2022-05-01 17:06:14 +02:00
Artturi
98ff3e401c
Merge pull request #165892 from tpwrules/fix-initrd-dirlinks
make-initrd: fix reproducibility problems
2022-04-21 20:51:35 +03:00
Janne Heß
b9bf28fd70
nixos/stage-1-init: Pass all parameters to the builder
This is for compatiblity with the old builder to get compat with uboot
support and to prepend microcode updates to the initrd
2022-04-16 20:36:18 +01:00
Thomas Watson
7fd6cea253 make-initrd: fix reproducibility problems
cpio includes the number of directory hard links in archives it creates.
Some filesystems, like btrfs, do not count directory hard links the same
way as more common filesystems like ext4 or tmpfs, so archives built
when /tmp is on such a filesystem do not reproduce. This patch replaces
cpio with bsdtar, which does not have this issue. The specific
invocation is from this page:
https://reproducible-builds.org/docs/archives/
2022-04-14 19:06:30 -05:00
Will Fancher
d193ef8a57 make-initrd-ng: init 2022-03-22 07:02:22 -04:00
Thomas Watson
d8bb89b9ff make-initrd: fix reproducibility problems with hard links 2022-01-29 18:07:11 -05:00
Linus Heckemann
b0fc6e8ff9 make-initrd: fix #132059 2021-08-08 07:53:59 +02:00