From 6c13b984d413618acda20172ce3a8eae6b57d7fb Mon Sep 17 00:00:00 2001 From: Graham Christensen Date: Mon, 8 Jun 2020 09:40:06 -0400 Subject: [PATCH] Load the Nix database registration too, and let the GC test pass. --- pkgs/squashfs-recursive/default.nix | 10 +++++++--- quickly.nix | 14 ++++++-------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/pkgs/squashfs-recursive/default.nix b/pkgs/squashfs-recursive/default.nix index d1a66a0..02e9c7d 100644 --- a/pkgs/squashfs-recursive/default.nix +++ b/pkgs/squashfs-recursive/default.nix @@ -1,4 +1,4 @@ -{ runCommand, nix, jq, path }: +{ closureInfo, runCommand, nix, jq, path }: let map-squash = ./map-squash.nix; @@ -9,6 +9,7 @@ let exportReferencesGraph = [ "root" storeContents ]; NIX_PATH = "nixpkgs=${path}"; outputs = [ "out" "manifest" ]; + closureInfo = closureInfo { rootPaths = storeContents; }; } '' cat root | grep /nix/store | sort | uniq | jq -R . | jq -s . > paths.json nix-build ${map-squash} --arg pathsJson ./paths.json @@ -18,12 +19,15 @@ let find "$f" -type f >> $out done - touch $manifest + mkdir $manifest + touch $manifest/squashes for f in $(cat "$out"); do prefix=$(echo "$f" | head -c20) suffix=$(echo "$f" | tail -c+21) - echo "$prefix $suffix" >> $manifest + echo "$prefix $suffix" >> $manifest/squashes done + + cat $closureInfo/registration | gzip -9 > $manifest/registration.gz ''; in mkSquashfsManifest diff --git a/quickly.nix b/quickly.nix index fa4033c..9719c1d 100644 --- a/quickly.nix +++ b/quickly.nix @@ -46,13 +46,14 @@ in mkdir -p /mnt-root/nix/.squash mkdir -p /mnt-root/nix/store + gunzip < /nix-store-squashes/registration.gz > /mnt-root/nix/registration + # the manifest splits the /nix/store/.... path with a " " to # prevent Nix from determining it depends on things. - for f in $(cat /nix-store-isos | sed 's/ //'); do + for f in $(cat /nix-store-squashes/squashes | sed 's/ //'); do prefix=$(basename "$(dirname "$f")") suffix=$(basename "$f") dest="$prefix$suffix" - echo "$dest" mkdir "/mnt-root/nix/.squash/$dest" mount -t squashfs -o loop "$f" "/mnt-root/nix/.squash/$dest" ( @@ -63,10 +64,6 @@ in rm "$f" set +x done - - ls -la /mnt-root/nix/store | grep system-nixos - ls -la /mnt-root/nix/store/*-nixos-system*/ - ls -la /mnt-root/nix/store/*-nixos-system*/* ) ''; @@ -103,7 +100,7 @@ in [ { object = config.system.build.squashfsStore.manifest; - symlink = "/nix-store-isos"; + symlink = "/nix-store-squashes"; } ]; }}/initrd"; @@ -116,7 +113,8 @@ in '' # After booting, register the contents of the Nix store # in the Nix database in the tmpfs. - ${config.nix.package}/bin/nix-store --load-db < /nix/store/nix-path-registration + echo "Loading the Nix database" + ${config.nix.package}/bin/nix-store --load-db < /nix/registration # nixos-rebuild also requires a "system" profile and an # /etc/NIXOS tag.