summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorLinus Heckemann <git@sphalerite.org>2017-07-12 22:04:49 +0100
committerLinus Heckemann <git@sphalerite.org>2017-07-13 06:30:24 +0100
commit77ce02201e1bc7facabb774d7e9996ab803145d2 (patch)
treea860b416c291711cdbe6be8b97ea7b45d61ff194 /nixos
parent8b1f1d93fa8e3524e0e01378dbe813e6eb06712e (diff)
downloadnixlib-77ce02201e1bc7facabb774d7e9996ab803145d2.tar
nixlib-77ce02201e1bc7facabb774d7e9996ab803145d2.tar.gz
nixlib-77ce02201e1bc7facabb774d7e9996ab803145d2.tar.bz2
nixlib-77ce02201e1bc7facabb774d7e9996ab803145d2.tar.lz
nixlib-77ce02201e1bc7facabb774d7e9996ab803145d2.tar.xz
nixlib-77ce02201e1bc7facabb774d7e9996ab803145d2.tar.zst
nixlib-77ce02201e1bc7facabb774d7e9996ab803145d2.zip
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
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/installer/tools/nixos-install.sh7
1 files changed, 6 insertions, 1 deletions
diff --git a/nixos/modules/installer/tools/nixos-install.sh b/nixos/modules/installer/tools/nixos-install.sh
index 7fae915871e4..79ed18c923c0 100644
--- a/nixos/modules/installer/tools/nixos-install.sh
+++ b/nixos/modules/installer/tools/nixos-install.sh
@@ -126,6 +126,9 @@ function closure() {
 }
 
 system_closure="$tmpdir/system.closure"
+# Use a FIFO for piping nix-store --export into nix-store --import, saving disk
+# I/O and space. nix-store --import is run by nixos-prepare-root.
+mkfifo $system_closure
 
 if [ -z "$closure" ]; then
     expr="(import <nixpkgs/nixos> {}).system"
@@ -135,7 +138,9 @@ else
     system_root=$closure
     # Create a temporary file ending in .closure (so nixos-prepare-root knows to --import it) to transport the store closure
     # to the filesytem we're preparing. Also delete it on exit!
-    nix-store --export $(nix-store -qR $closure) > $system_closure
+    # Run in background to avoid blocking while trying to write to the FIFO
+    # $system_closure refers to
+    nix-store --export $(nix-store -qR $closure) > $system_closure &
 fi
 
 channel_root="$(nix-env -p /nix/var/nix/profiles/per-user/root/channels -q nixos --no-name --out-path 2>/dev/null || echo -n "")"