git.iko.soy/typeable/nixpkgs
on master help sign in
nixos-install: use FIFO for system closure

This avoids running out of space in space-constrained environments, e.g. VMs with relatively small amounts of memory and tmp on tmpfs

commit77ce02201e1bc7facabb774d7e9996ab803145d2 authorLinus Heckemann <git@sphalerite.org> dateWed 12 Jul 2017, 22:04 (9 years ago) parent8b1f1d9
1 file changed+6−1
nixos/modules/installer/tools/nixos-install.sh+6−1
nixos/modules/installer/tools/nixos-install.sh+6−1
@@ -126,6 +126,9 @@ function closure() {
126126}
127127
128128system_closure="$tmpdir/system.closure"
129+# Use a FIFO for piping nix-store --export into nix-store --import, saving disk
130+# I/O and space. nix-store --import is run by nixos-prepare-root.
131+mkfifo $system_closure
129132
130133if [ -z "$closure" ]; then
131134 expr="(import <nixpkgs/nixos> {}).system"
@@ -135,7 +138,9 @@ else
135138 system_root=$closure
136139 # Create a temporary file ending in .closure (so nixos-prepare-root knows to --import it) to transport the store closure
137140 # to the filesytem we're preparing. Also delete it on exit!
138− nix-store --export $(nix-store -qR $closure) > $system_closure
141+ # Run in background to avoid blocking while trying to write to the FIFO
142+ # $system_closure refers to
143+ nix-store --export $(nix-store -qR $closure) > $system_closure &
139144fi
140145
141146channel_root="$(nix-env -p /nix/var/nix/profiles/per-user/root/channels -q nixos --no-name --out-path 2>/dev/null || echo -n "")"