diff --git a/flake.nix b/flake.nix index 653cacded00d..f634dbfd0495 100644 --- a/flake.nix +++ b/flake.nix @@ -326,7 +326,12 @@ substitute ${./scripts/install.in} $out/install \ ${pkgs.lib.concatMapStrings - (system: "--replace '@binaryTarball_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${self.hydraJobs.binaryTarball.${system}}/*.tar.xz) ") + (system: + '' \ + --replace '@tarballHash_${system}@' $(nix --experimental-features nix-command hash-file --base16 --type sha256 ${self.hydraJobs.binaryTarball.${system}}/*.tar.xz) \ + --replace '@tarballPath_${system}@' ${self.hydraJobs.binaryTarball.${system}}/*.tar.xz \ + '' + ) [ "x86_64-linux" "i686-linux" "x86_64-darwin" "aarch64-linux" ] } \ --replace '@nixVersion@' ${version} diff --git a/scripts/install.in b/scripts/install.in index 9a281d776384..008aa9f49570 100644 --- a/scripts/install.in +++ b/scripts/install.in @@ -25,18 +25,44 @@ require_util() { } case "$(uname -s).$(uname -m)" in - Linux.x86_64) system=x86_64-linux; hash=@binaryTarball_x86_64-linux@;; - Linux.i?86) system=i686-linux; hash=@binaryTarball_i686-linux@;; - Linux.aarch64) system=aarch64-linux; hash=@binaryTarball_aarch64-linux@;; - Darwin.x86_64) system=x86_64-darwin; hash=@binaryTarball_x86_64-darwin@;; - # eventually maybe: system=arm64-darwin; hash=@binaryTarball_arm64-darwin@;; - Darwin.arm64) system=x86_64-darwin; hash=@binaryTarball_x86_64-darwin@;; + Linux.x86_64) + hash=@tarballHash_x86_64-linux@ + store_path=@tarballPath_x86_64-linux@ + system=x86_64-linux + ;; + Linux.i?86) + hash=@tarballHash_i686-linux@ + store_path=@tarballPath_i686-linux@ + system=i686-linux + ;; + Linux.aarch64) + hash=@tarballHash_aarch64-linux@ + store_path=@tarballPath_aarch64-linux@ + system=aarch64-linux + ;; + Darwin.x86_64) + hash=@tarballHash_x86_64-darwin@ + store_path=@tarballPath_x86_64-darwin@ + system=x86_64-darwin + ;; + Darwin.arm64) + # eventually maybe: system=arm64-darwin + system=x86_64-darwin + store_path=@tarballPath_x86_64-darwin@ + hash=@binaryTarball_x86_64-darwin@ + ;; *) 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" +# Use this command-line option to fetch the tarballs using nar-serve. +if "${1:---nar-serve}"; then + url=${2}${store_path} + shift 2 +else + url=https://releases.nixos.org/nix/nix-@nixVersion@/nix-@nixVersion@-$system.tar.xz +fi -tarball="$tmpDir/$(basename "$tmpDir/nix-@nixVersion@-$system.tar.xz")" +tarball=$tmpDir/nix-@nixVersion@-$system.tar.xz require_util curl "download the binary tarball" require_util tar "unpack the binary tarball"