mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-25 08:23:09 +00:00
Add function closureInfo to replace pathsFromGraph
Unlike pathsFromGraph, on Nix 1.12, this function produces a registration file containing correct NAR hash/size information. https://hydra.nixos.org/build/62832723
This commit is contained in:
parent
5939af52b3
commit
8f349a3bf3
@ -92,7 +92,7 @@ let
|
||||
-drive index=0,id=drive1,file=$NIX_DISK_IMAGE,if=${cfg.qemu.diskInterface},cache=writeback,werror=report \
|
||||
-kernel ${config.system.build.toplevel}/kernel \
|
||||
-initrd ${config.system.build.toplevel}/initrd \
|
||||
-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo} ${kernelConsole} $QEMU_KERNEL_PARAMS" \
|
||||
-append "$(cat ${config.system.build.toplevel}/kernel-params) init=${config.system.build.toplevel}/init regInfo=${regInfo}/registration ${kernelConsole} $QEMU_KERNEL_PARAMS" \
|
||||
''} \
|
||||
$extraDisks \
|
||||
${qemuGraphics} \
|
||||
@ -102,15 +102,7 @@ let
|
||||
'';
|
||||
|
||||
|
||||
regInfo = pkgs.runCommand "reginfo"
|
||||
{ exportReferencesGraph =
|
||||
map (x: [("closure-" + baseNameOf x) x]) config.virtualisation.pathsInNixDB;
|
||||
buildInputs = [ pkgs.perl ];
|
||||
preferLocalBuild = true;
|
||||
}
|
||||
''
|
||||
printRegistration=1 perl ${pkgs.pathsFromGraph} closure-* > $out
|
||||
'';
|
||||
regInfo = pkgs.closureInfo { rootPaths = config.virtualisation.pathsInNixDB; };
|
||||
|
||||
|
||||
# Generate a hard disk image containing a /boot partition and GRUB
|
||||
|
55
pkgs/build-support/closure-info.nix
Normal file
55
pkgs/build-support/closure-info.nix
Normal file
@ -0,0 +1,55 @@
|
||||
# This derivation builds two files containing information about the
|
||||
# closure of 'rootPaths': $out/store-paths contains the paths in the
|
||||
# closure, and $out/registration contains a file suitable for use with
|
||||
# "nix-store --load-db" and "nix-store --register-validity
|
||||
# --hash-given".
|
||||
|
||||
{ stdenv, coreutils, jq, perl, pathsFromGraph }:
|
||||
|
||||
{ rootPaths }:
|
||||
|
||||
if builtins.langVersion >= 5 then
|
||||
|
||||
# Nix >= 1.12: Include NAR hash / size info.
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "closure-info";
|
||||
|
||||
__structuredAttrs = true;
|
||||
|
||||
exportReferencesGraph.closure = rootPaths;
|
||||
|
||||
PATH = "${coreutils}/bin:${jq}/bin";
|
||||
|
||||
builder = builtins.toFile "builder"
|
||||
''
|
||||
if [ -e .attrs.sh ]; then . .attrs.sh; fi
|
||||
|
||||
out=''${outputs[out]}
|
||||
|
||||
mkdir $out
|
||||
|
||||
jq -r '.closure | map([.path, .narHash, .narSize, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < .attrs.json | head -n -1 > $out/registration
|
||||
jq -r .closure[].path < .attrs.json > $out/store-paths
|
||||
'';
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
# Nix < 1.12
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "closure-info";
|
||||
|
||||
exportReferencesGraph =
|
||||
map (x: [("closure-" + baseNameOf x) x]) rootPaths;
|
||||
|
||||
buildInputs = [ perl ];
|
||||
|
||||
buildCommand =
|
||||
''
|
||||
mkdir $out
|
||||
printRegistration=1 perl ${pathsFromGraph} closure-* > $out/registration
|
||||
perl ${pathsFromGraph} closure-* > $out/store-paths
|
||||
'';
|
||||
}
|
@ -305,6 +305,8 @@ with pkgs;
|
||||
|
||||
pathsFromGraph = ../build-support/kernel/paths-from-graph.pl;
|
||||
|
||||
closureInfo = callPackage ../build-support/closure-info.nix { };
|
||||
|
||||
setupSystemdUnits = callPackage ../build-support/setup-systemd-units.nix { };
|
||||
|
||||
singularity-tools = callPackage ../build-support/singularity-tools { };
|
||||
|
Loading…
Reference in New Issue
Block a user