Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make-disk-image: improve xargs invocation #910

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions lib/make-disk-image.nix
Original file line number Diff line number Diff line change
Expand Up @@ -87,14 +87,21 @@ let
${lib.getExe systemToInstall.config.system.build.destroyFormatMount} --yes-wipe-all-disks
'';

installer = lib.optionalString cfg.copyNixStore ''
installer =
let
# let xargs stop directly when cp fails
cpEarlyExit = pkgs.writeScript "cp-early-exit" ''
cp --recursive --target ${systemToInstall.config.disko.rootMountPoint}/nix/store "$@" || exit 255
'';
in
lib.optionalString cfg.copyNixStore ''
# populate nix db, so nixos-install doesn't complain
export NIX_STATE_DIR=${systemToInstall.config.disko.rootMountPoint}/nix/var/nix
nix-store --load-db < "${closureInfo}/registration"

# We copy files with cp because `nix copy` seems to have a large memory leak
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store
xargs cp --recursive --target ${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths
xargs ${cfg.xargsFlags} ${cpEarlyExit} < ${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}
Expand Down
7 changes: 7 additions & 0 deletions module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,13 @@ in
description = "QEMU image format to use for the disk images";
default = "raw";
};

xargsFlags = lib.mkOption {
type = lib.types.str;
description = "flags for xargs invocation";
default = "";
example = "-L 100 -P 0";
};
};

memSize = lib.mkOption {
Expand Down