From 7cc5a44a61ac1bab1c998e78e0974d61c8af601e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Xaver=20H=C3=B6rl?= Date: Fri, 10 Jan 2025 20:32:43 +0100 Subject: [PATCH 1/3] make-initrd: use closureInfo --- pkgs/build-support/kernel/make-initrd.nix | 11 +---------- pkgs/build-support/kernel/make-initrd.sh | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/pkgs/build-support/kernel/make-initrd.nix b/pkgs/build-support/kernel/make-initrd.nix index ef591a4d9aa5..946db43afdee 100644 --- a/pkgs/build-support/kernel/make-initrd.nix +++ b/pkgs/build-support/kernel/make-initrd.nix @@ -20,7 +20,6 @@ let in { stdenvNoCC, - perl, cpio, ubootTools, lib, @@ -101,7 +100,6 @@ stdenvNoCC.mkDerivation ( builder = ./make-initrd.sh; nativeBuildInputs = [ - perl cpio ] ++ lib.optional makeUInitrd ubootTools; @@ -121,14 +119,7 @@ stdenvNoCC.mkDerivation ( symlinks = map (x: x.symlink) contents; suffices = map (x: if x ? suffix then x.suffix else "none") contents; - # For obtaining the closure of `contents'. - # Note: we don't use closureInfo yet, as that won't build with nix-1.x. - # See #36268. - exportReferencesGraph = lib.zipListsWith (x: i: [ - ("closure-${toValidStoreName (baseNameOf x.symlink)}-${toString i}") - x.object - ]) contents (lib.range 0 (lib.length contents - 1)); - pathsFromGraph = ./paths-from-graph.pl; + closureInfo = "${pkgsBuildHost.closureInfo { rootPaths = objects; }}"; } // lib.optionalAttrs makeUInitrd { uInitrdCompression = uInitrdCompression; diff --git a/pkgs/build-support/kernel/make-initrd.sh b/pkgs/build-support/kernel/make-initrd.sh index 0149c5d487ac..b0f2341fbf66 100644 --- a/pkgs/build-support/kernel/make-initrd.sh +++ b/pkgs/build-support/kernel/make-initrd.sh @@ -26,7 +26,7 @@ done # Get the paths in the closure of `object'. -storePaths=$(perl $pathsFromGraph closure-*) +storePaths="$(cat $closureInfo/store-paths)" # Paths in cpio archives *must* be relative, otherwise the kernel From e540245ee4a75bde32c931734d5603414ae32f1d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Xaver=20H=C3=B6rl?= Date: Thu, 23 Jan 2025 16:19:39 +0100 Subject: [PATCH 2/3] pkgs/pathsFromGraph: drop Nix 2.* is widely used now, so closureInfo should be used instead. --- pkgs/build-support/kernel/paths-from-graph.pl | 68 ------------------- pkgs/top-level/aliases.nix | 1 + pkgs/top-level/all-packages.nix | 2 - 3 files changed, 1 insertion(+), 70 deletions(-) delete mode 100644 pkgs/build-support/kernel/paths-from-graph.pl diff --git a/pkgs/build-support/kernel/paths-from-graph.pl b/pkgs/build-support/kernel/paths-from-graph.pl deleted file mode 100644 index 1465b73fddb6..000000000000 --- a/pkgs/build-support/kernel/paths-from-graph.pl +++ /dev/null @@ -1,68 +0,0 @@ -# NOTE: this script is deprecated. Use closureInfo instead. - -# Parses a /nix/store/*-closure file and prints -# various information. -# By default, the nodes in the graph are printed to stdout. -# If printRegistration is set, then the graph is written -# as a registration file for a manifest is written -# in the `nix-store --load-db' format. - -use strict; -use File::Basename; - -my %storePaths; -my %refs; - -# Each argument on the command line is a graph file. -# The graph file contains line-triples and a variable -# number of references: -# -# -# -# -# ... -# -foreach my $graph (@ARGV) { - open GRAPH, "<$graph" or die; - - while () { - chomp; - my $storePath = "$_"; - $storePaths{$storePath} = 1; - - my $deriver = ; chomp $deriver; - my $count = ; chomp $count; - - my @refs = (); - for (my $i = 0; $i < $count; ++$i) { - my $ref = ; chomp $ref; - push @refs, $ref; - } - $refs{$storePath} = \@refs; - - } - - close GRAPH; -} - - -if ($ENV{"printRegistration"} eq "1") { - # This is the format used by `nix-store --register-validity - # --hash-given' / `nix-store --load-db'. - foreach my $storePath (sort (keys %storePaths)) { - print "$storePath\n"; - print "0000000000000000000000000000000000000000000000000000000000000000\n"; # !!! fix - print "0\n"; # !!! fix - print "\n"; # don't care about preserving the deriver - print scalar(@{$refs{$storePath}}), "\n"; - foreach my $ref (@{$refs{$storePath}}) { - print "$ref\n"; - } - } -} - -else { - foreach my $storePath (sort (keys %storePaths)) { - print "$storePath\n"; - } -} diff --git a/pkgs/top-level/aliases.nix b/pkgs/top-level/aliases.nix index 453805988349..2f108911ad91 100644 --- a/pkgs/top-level/aliases.nix +++ b/pkgs/top-level/aliases.nix @@ -1028,6 +1028,7 @@ mapAliases { packet-cli = throw "'packet-cli' has been renamed to/replaced by 'metal-cli'"; # Converted to throw 2024-10-17 paperoni = throw "paperoni has been removed, because it is unmaintained"; # Added 2024-07-14 paperless = throw "'paperless' has been renamed to/replaced by 'paperless-ngx'"; # Converted to throw 2024-10-17 + pathsFromGraph = throw "pathsFromGraph has been removed, use closureInfo instead";# Added 2025-01-23 paperless-ng = paperless-ngx; # Added 2022-04-11 partition-manager = libsForQt5.partitionmanager; # Added 2024-01-08 patchelfStable = patchelf; # Added 2024-01-25 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 147d5b23b31b..95c0603e02b4 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -727,8 +727,6 @@ with pkgs; callPackages ../build-support/setup-hooks/patch-rc-path-hooks { } ) patchRcPathBash patchRcPathCsh patchRcPathFish patchRcPathPosix; - pathsFromGraph = ../build-support/kernel/paths-from-graph.pl; - pruneLibtoolFiles = makeSetupHook { name = "prune-libtool-files"; } ../build-support/setup-hooks/prune-libtool-files.sh; From 9270d7cbb6d5cab7d403819df811092713f599f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Xaver=20H=C3=B6rl?= Date: Sun, 9 Mar 2025 14:20:48 +0100 Subject: [PATCH 3/3] nixos/installation-device: add jq.all to extraDependencies As discovered in https://github.com/NixOS/nixpkgs/pull/372931, we need the dev output of jq for closureInfo. We opt to add the whole thing. --- nixos/modules/profiles/installation-device.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nixos/modules/profiles/installation-device.nix b/nixos/modules/profiles/installation-device.nix index a4e5a4aac790..7fcd525263b1 100644 --- a/nixos/modules/profiles/installation-device.nix +++ b/nixos/modules/profiles/installation-device.nix @@ -102,10 +102,10 @@ with lib; stdenv stdenvNoCC # for runCommand busybox - jq # for closureInfo # For boot.initrd.systemd makeInitrdNGTool - ]; + ] + ++ jq.all; # for closureInfo boot.swraid.enable = true; # remove warning about unset mail