Skip to content

Commit

Permalink
installer: simplify the per-build installation
Browse files Browse the repository at this point in the history
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 NixOS#4047
  • Loading branch information
zimbatm committed Nov 6, 2020
1 parent 387f824 commit f3fec9f
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
12 changes: 12 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion scripts/install.in
Original file line number Diff line number Diff line change
Expand Up @@ -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")"

Expand Down

0 comments on commit f3fec9f

Please sign in to comment.