From b6363c7bc89514e14573cf806326adac46ad06a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Domen=20Ko=C5=BEar?= Date: Wed, 7 Dec 2016 13:29:07 +0100 Subject: [PATCH] make-disk-image: make store validity fix optional This is useful for EC2 AMI generation to speedup the process. In my case it removes 13min out of 45min when generating an image on EC2. --- nixos/lib/make-disk-image.nix | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/nixos/lib/make-disk-image.nix b/nixos/lib/make-disk-image.nix index b8411f5e5ec..e279803f2ea 100644 --- a/nixos/lib/make-disk-image.nix +++ b/nixos/lib/make-disk-image.nix @@ -27,6 +27,10 @@ , name ? "nixos-disk-image" + # This prevents errors while checking nix-store validity, see + # https://github.com/NixOS/nix/issues/1134 +, fixValidity ? true + , format ? "raw" }: @@ -68,9 +72,11 @@ pkgs.vmTools.runInLinuxVM ( printRegistration=1 perl ${pkgs.pathsFromGraph} /tmp/xchg/closure | \ ${config.nix.package.out}/bin/nix-store --load-db --option build-users-group "" - # Add missing size/hash fields to the database. FIXME: - # exportReferencesGraph should provide these directly. - ${config.nix.package.out}/bin/nix-store --verify --check-contents --option build-users-group "" + ${if fixValidity then '' + # Add missing size/hash fields to the database. FIXME: + # exportReferencesGraph should provide these directly. + ${config.nix.package.out}/bin/nix-store --verify --check-contents --option build-users-group "" + '' else ""} # In case the bootloader tries to write to /dev/sda… ln -s vda /dev/xvda