nixos-rebuild: get Nix from channel
If our old Nix can’t evaluate the Nixpkgs channel, try the fallback from the new channel /first/. That way we can upgrade Nix to a newer version and support breaking changes to Nix (like seen in the upgrade o Nix 2.0). This change should be backported to older NixOS versions!
This commit is contained in:
parent
266315c91d
commit
475c8aa018
@ -260,6 +260,14 @@ if [ -n "$rollback" -o "$action" = dry-build ]; then
|
|||||||
buildNix=
|
buildNix=
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
nixSystem() {
|
||||||
|
machine="$(uname -m)"
|
||||||
|
if [[ "$machine" =~ i.86 ]]; then
|
||||||
|
machine=i686
|
||||||
|
fi
|
||||||
|
echo $machine-linux
|
||||||
|
}
|
||||||
|
|
||||||
prebuiltNix() {
|
prebuiltNix() {
|
||||||
machine="$1"
|
machine="$1"
|
||||||
if [ "$machine" = x86_64 ]; then
|
if [ "$machine" = x86_64 ]; then
|
||||||
@ -279,7 +287,9 @@ if [ -n "$buildNix" ]; then
|
|||||||
nixDrv=
|
nixDrv=
|
||||||
if ! nixDrv="$(nix-instantiate '<nixpkgs/nixos>' --add-root $tmpDir/nix.drv --indirect -A config.nix.package.out "${extraBuildFlags[@]}")"; then
|
if ! nixDrv="$(nix-instantiate '<nixpkgs/nixos>' --add-root $tmpDir/nix.drv --indirect -A config.nix.package.out "${extraBuildFlags[@]}")"; then
|
||||||
if ! nixDrv="$(nix-instantiate '<nixpkgs>' --add-root $tmpDir/nix.drv --indirect -A nix "${extraBuildFlags[@]}")"; then
|
if ! nixDrv="$(nix-instantiate '<nixpkgs>' --add-root $tmpDir/nix.drv --indirect -A nix "${extraBuildFlags[@]}")"; then
|
||||||
nixStorePath="$(prebuiltNix "$(uname -m)")"
|
if ! nixStorePath="$(nix-instantiate --eval '<nixpkgs/nixos/modules/installer/tools/nix-fallback-paths.nix>' -A $(nixSystem) | sed -e 's/^"//' -e 's/"$//')"; then
|
||||||
|
nixStorePath="$(prebuiltNix "$(uname -m)")"
|
||||||
|
fi
|
||||||
if ! nix-store -r $nixStorePath --add-root $tmpDir/nix --indirect \
|
if ! nix-store -r $nixStorePath --add-root $tmpDir/nix --indirect \
|
||||||
--option extra-binary-caches https://cache.nixos.org/; then
|
--option extra-binary-caches https://cache.nixos.org/; then
|
||||||
echo "warning: don't know how to get latest Nix" >&2
|
echo "warning: don't know how to get latest Nix" >&2
|
||||||
|
Loading…
x
Reference in New Issue
Block a user