mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 21:13:28 +01:00
load database with checksum again but do the same in disko-install
This commit is contained in:
1 parent
8a4585a200
commit
cdefe26742
7 files changed
+48
-60
No files matched your search
@@ -1,45 +0,0 @@
|
||||
# This is a modified version of the closure-info derivation from nixpkgs.
|
||||
# Unlike the original, it does not include hashes in the registration file,
|
||||
# which might be incorrect if a build is not binary reproducible.
|
||||
|
||||
# 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 --register-validity".
|
||||
|
||||
{ stdenv, coreutils, jq }:
|
||||
|
||||
{ rootPaths }:
|
||||
|
||||
assert builtins.langVersion >= 5;
|
||||
|
||||
stdenv.mkDerivation {
|
||||
name = "closure-info";
|
||||
|
||||
__structuredAttrs = true;
|
||||
|
||||
exportReferencesGraph.closure = rootPaths;
|
||||
|
||||
preferLocalBuild = true;
|
||||
|
||||
nativeBuildInputs = [ coreutils jq ];
|
||||
|
||||
empty = rootPaths == [];
|
||||
|
||||
buildCommand =
|
||||
''
|
||||
out=''${outputs[out]}
|
||||
|
||||
mkdir $out
|
||||
|
||||
if [[ -n "$empty" ]]; then
|
||||
echo 0 > $out/total-nar-size
|
||||
touch $out/registration $out/store-paths
|
||||
else
|
||||
jq -r ".closure | map(.narSize) | add" < "$NIX_ATTRS_JSON_FILE" > $out/total-nar-size
|
||||
jq -r '.closure | map([.path, "", (.references | length)] + .references) | add | map("\(.)\n") | add' < "$NIX_ATTRS_JSON_FILE" | head -n -1 > $out/registration
|
||||
jq -r '.closure[].path' < "$NIX_ATTRS_JSON_FILE" > $out/store-paths
|
||||
fi
|
||||
|
||||
'';
|
||||
}
|
||||
@@ -28,6 +28,7 @@ let
|
||||
systemdMinimal
|
||||
nix
|
||||
util-linux
|
||||
xcp
|
||||
] ++ nixosConfig.config.disko.extraDependencies;
|
||||
preVM = ''
|
||||
${lib.concatMapStringsSep "\n" (disk: "truncate -s ${disk.imageSize} ${disk.name}.raw") (lib.attrValues nixosConfig.config.disko.devices.disk)}
|
||||
@@ -39,7 +40,7 @@ let
|
||||
${extraPostVM}
|
||||
'';
|
||||
|
||||
closureInfo = (pkgs.callPackage ./closure-info.nix { }) {
|
||||
closureInfo = pkgs.closureInfo {
|
||||
rootPaths = [ systemToInstall.config.system.build.toplevel ];
|
||||
};
|
||||
partitioner = ''
|
||||
@@ -63,15 +64,11 @@ let
|
||||
installer = ''
|
||||
# populate nix db, so nixos-install doesn't complain
|
||||
export NIX_STATE_DIR=${systemToInstall.config.disko.rootMountPoint}/nix/var/nix
|
||||
# We have to use fakeroot here, because nix tries to chown files in the original store.
|
||||
# fakeroot will make override all chown calls to no-ops.
|
||||
echo "Registering store paths..."
|
||||
${pkgs.fakeroot}/bin/fakeroot nix-store --register-validity --reregister < ${closureInfo}/registration
|
||||
nix-store --load-db < "${closureInfo}/registration"
|
||||
|
||||
# We copy files with cp because `nix copy` seems to have a large memory leak
|
||||
echo "Copying store paths..."
|
||||
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store
|
||||
xargs cp -r --target-directory=${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths
|
||||
xargs -I % xcp --recursive % ${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths
|
||||
|
||||
${systemToInstall.config.system.build.nixos-install}/bin/nixos-install --root ${systemToInstall.config.disko.rootMountPoint} --system ${systemToInstall.config.system.build.toplevel} --keep-going --no-channel-copy -v --no-root-password --option binary-caches ""
|
||||
umount -Rv ${systemToInstall.config.disko.rootMountPoint}
|
||||
|
||||
Reference in new issue
Block a user