Rebuild: Separate evaluation
This commit is contained in:
parent
fafc4d45b7
commit
cd4536c53b
|
@ -153,6 +153,7 @@
|
|||
runtimeInputs = with pkgs; [
|
||||
nix-output-monitor
|
||||
nixos-rebuild
|
||||
jq
|
||||
];
|
||||
text = builtins.readFile ./os/rebuild.sh;
|
||||
}
|
||||
|
|
|
@ -24,12 +24,15 @@ then
|
|||
exit 2
|
||||
fi
|
||||
|
||||
info "Building"
|
||||
tmpdir="$(mktemp -d)"
|
||||
info "Evaluating"
|
||||
# Evaluating can take a lot of memory, and Nix doesn't free it until the program ends,
|
||||
# which can be limiting on memory-constrained devices. Hence the build step is separate.
|
||||
# nix eval doesn't use the eval cache, so we do a nix build --dry-run
|
||||
# sudo so the eval cache is shared with nixos-rebuild
|
||||
sudo nom build "$self#nixosConfigurations.$HOSTNAME.config.system.build.toplevel" -o "$tmpdir/toplevel" "$@"
|
||||
toplevel="$(readlink -f "$tmpdir/toplevel")"
|
||||
rm -rf "$tmpdir"
|
||||
toplevel=$(time sudo nix build "$self#nixosConfigurations.$HOSTNAME.config.system.build.toplevel" --dry-run --json | jq '.[0].outputs.out' -r)
|
||||
|
||||
info "Building"
|
||||
sudo nom build "$toplevel" --no-link "$@"
|
||||
|
||||
info "Showing diff"
|
||||
nvd diff "$(readlink -f /nix/var/nix/profiles/system)" "$toplevel"
|
||||
|
|
Loading…
Reference in a new issue