1 # `builtins.fetchTarball` only accepts a `sha256` argument in Nix version 1.12
2 # or later, so here we provide a function that can provide a compatible interface
3 # to Nix 1.11 or Nix 1.12
5 # TODO FIXME: remove this sometime after Nix 1.12 goes stable
7 { url # URL of the nixpkgs tarball to download
8 , rev # The Git revision of nixpkgs to fetch
9 , sha256 # The SHA256 of the downloaded data
10 , system ? builtins.currentSystem # This is overridable if necessary
14 ifThenElse = { bool, thenValue, elseValue }: (
15 if bool then thenValue else elseValue);
19 bool = (0 <= builtins.compareVersions builtins.nixVersion "1.12");
21 # In Nix 1.12, we can just give a `sha256` to `builtins.fetchTarball`.
22 thenValue = (builtins.fetchTarball { inherit url sha256; });
24 # This hack should at least work for Nix 1.11
27 tarball = import <nix/fetchurl.nix> { inherit url sha256; };
28 builtin-paths = import <nix/config.nix>;
30 script = builtins.toFile "nixpkgs-unpacker" ''
31 "$coreutils/mkdir" "$out"
33 "$gzip" --decompress < "$tarball" | "$tar" -x --strip-components=1
36 nixpkgs = builtins.derivation {
37 name = "nixpkgs-${builtins.substring 0 6 rev}";
39 builder = builtins.storePath builtin-paths.shell;
42 inherit tarball system;
43 tar = builtins.storePath builtin-paths.tar;
44 gzip = builtins.storePath builtin-paths.gzip;
45 coreutils = builtins.storePath builtin-paths.coreutils;