Rebuild: Separate evaluation
This commit is contained in:
parent
fafc4d45b7
commit
cd4536c53b
|
@ -153,6 +153,7 @@
|
||||||
runtimeInputs = with pkgs; [
|
runtimeInputs = with pkgs; [
|
||||||
nix-output-monitor
|
nix-output-monitor
|
||||||
nixos-rebuild
|
nixos-rebuild
|
||||||
|
jq
|
||||||
];
|
];
|
||||||
text = builtins.readFile ./os/rebuild.sh;
|
text = builtins.readFile ./os/rebuild.sh;
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,15 @@ then
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Building"
|
info "Evaluating"
|
||||||
tmpdir="$(mktemp -d)"
|
# 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 so the eval cache is shared with nixos-rebuild
|
||||||
sudo nom build "$self#nixosConfigurations.$HOSTNAME.config.system.build.toplevel" -o "$tmpdir/toplevel" "$@"
|
toplevel=$(time sudo nix build "$self#nixosConfigurations.$HOSTNAME.config.system.build.toplevel" --dry-run --json | jq '.[0].outputs.out' -r)
|
||||||
toplevel="$(readlink -f "$tmpdir/toplevel")"
|
|
||||||
rm -rf "$tmpdir"
|
info "Building"
|
||||||
|
sudo nom build "$toplevel" --no-link "$@"
|
||||||
|
|
||||||
info "Showing diff"
|
info "Showing diff"
|
||||||
nvd diff "$(readlink -f /nix/var/nix/profiles/system)" "$toplevel"
|
nvd diff "$(readlink -f /nix/var/nix/profiles/system)" "$toplevel"
|
||||||
|
|
Loading…
Reference in a new issue