From f3fec9f795f88b4a9d0eabc97a43e2c551de0483 Mon Sep 17 00:00:00 2001 From: zimbatm Date: Fri, 6 Nov 2020 11:53:00 +0100 Subject: [PATCH] installer: simplify the per-build installation The goal is to simplify the installation and testing of arbitrary Nix versions. 1. Extend the base installer to accept a NIX_RELEASE_URL to change where Nix is getting installed from. 2. Generate a new output from Hydra that combines all the released tarballs. Once this is merged it should allow to: 1. Pick an evaluation at https://hydra.nixos.org/jobset/nix/master that looks healthy 2. Select the installedScript build and get the "install" download link. 3. Select the allTarballs build and get the download link. Now equipped with all of this: curl -sfL https://hydra.nixos.org/build/1234/download/1/install | \ NIX_RELEASE_URL=https://hydra.nixos.org/build/5678/download/1/XXX sh Fixes #4047 --- flake.nix | 12 ++++++++++++ scripts/install.in | 6 +++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index 2abbdff5399e..ed8c2a302b55 100644 --- a/flake.nix +++ b/flake.nix @@ -311,6 +311,18 @@ $(cat ${installerClosureInfo}/store-paths) ''); + # Group all the tarballs into a single symlink tree + allTarballs = + with nixpkgsFor.x86_64-linux; + runCommand "all-tarballs" {} + '' + mkdir $out/nix-${version} + for output in ${builtins.attrValues self.hydraJobs.binaryTarball}; + do + ln -s "$output"/*.tar.xz "$out/nix-${version}" + end + ''; + # The first half of the installation script. This is uploaded # to https://nixos.org/nix/install. It downloads the binary # tarball for the user's system and calls the second half of the diff --git a/scripts/install.in b/scripts/install.in index 39fae37e351d..91ab19e93f01 100644 --- a/scripts/install.in +++ b/scripts/install.in @@ -32,7 +32,11 @@ case "$(uname -s).$(uname -m)" in *) oops "sorry, there is no binary distribution of Nix for your platform";; esac -url="https://releases.nixos.org/nix/nix-@nixVersion@/nix-@nixVersion@-$system.tar.xz" +# Set this environment variable to switch where Nix will fetch the tarball +# from. Since the content is verified after download, changing this is still +# secure. +: "${NIX_RELEASE_URL:-https://releases.nixos.org/nix}" +url="${NIX_RELEASE_URL}/nix-@nixVersion@/nix-@nixVersion@-$system.tar.xz" tarball="$tmpDir/$(basename "$tmpDir/nix-@nixVersion@-$system.tar.xz")"