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! (cherry picked from commit 475c8aa018bbdd99e7e9d693c7207cdccdcde7b3)release-18.03-flake
parent
cb0e20d6db
commit
c8c521f0c0
|
@ -260,6 +260,14 @@ if [ -n "$rollback" -o "$action" = dry-build ]; then
|
|||
buildNix=
|
||||
fi
|
||||
|
||||
nixSystem() {
|
||||
machine="$(uname -m)"
|
||||
if [[ "$machine" =~ i.86 ]]; then
|
||||
machine=i686
|
||||
fi
|
||||
echo $machine-linux
|
||||
}
|
||||
|
||||
prebuiltNix() {
|
||||
machine="$1"
|
||||
if [ "$machine" = x86_64 ]; then
|
||||
|
@ -279,7 +287,9 @@ if [ -n "$buildNix" ]; then
|
|||
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>' --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 \
|
||||
--option extra-binary-caches https://cache.nixos.org/; then
|
||||
echo "warning: don't know how to get latest Nix" >&2
|
||||
|
|
Loading…
Reference in New Issue