summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthew Bauer <mjbauer95@gmail.com>2019-02-20 20:02:20 -0500
committerMatthew Bauer <mjbauer95@gmail.com>2019-03-02 18:54:42 -0500
commit3ba3d8d8cbec36605095d3a30ff6b82902af289c (patch)
treecd4e0f79ef29997651ae28ff7873a3c89aa0ac1d
parentMerge pull request #47528 from roconnor/bitcoin (diff)
downloadnixpkgs-origin/release-17.09.tar.gz
nixos-rebuild: get Nix from channelorigin/release-17.09gitlab.intr/release-17.09
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)
-rw-r--r--nixos/modules/installer/tools/nixos-rebuild.sh12
1 files changed, 11 insertions, 1 deletions
diff --git a/nixos/modules/installer/tools/nixos-rebuild.sh b/nixos/modules/installer/tools/nixos-rebuild.sh
index 9ede74a54cd7..61e6cd4af4a7 100644
--- a/nixos/modules/installer/tools/nixos-rebuild.sh
+++ b/nixos/modules/installer/tools/nixos-rebuild.sh
@@ -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