@@ -1,4 +1,4 @@
1−{ lib, fetchurl, callPackage
1+{ lib, fetchurl, fetchFromGitHub, callPackage
22, storeDir ? "/nix/store"
33, stateDir ? "/nix/var"
44, confDir ? "/etc"
@@ -12,6 +12,7 @@ common =
1212 { lib, stdenv, fetchpatch, perl, curl, bzip2, sqlite, openssl ? null, xz
1313 , bash, coreutils, gzip, gnutar
1414 , pkgconfig, boehmgc, perlPackages, libsodium, brotli, boost, editline, nlohmann_json
15+ , autoreconfHook, autoconf-archive, bison, flex, libxml2, libxslt, docbook5, docbook_xsl_ns
1516 , jq, libarchive, rustc, cargo
1617 , busybox-sandbox-shell
1718 , storeDir
@@ -20,7 +21,7 @@ common =
2021 , withLibseccomp ? lib.any (lib.meta.platformMatch stdenv.hostPlatform) libseccomp.meta.platforms, libseccomp
2122 , withAWS ? stdenv.isLinux || stdenv.isDarwin, aws-sdk-cpp
2223
23− , name, suffix ? "", src, includesPerl ? false
24+ , name, suffix ? "", src, crates ? null
2425
2526 }:
2627 let
@@ -29,7 +30,6 @@ common =
2930 inherit name src;
3031 version = lib.getVersion name;
3132
32− is20 = lib.versionAtLeast version "2.0pre";
3333 is24 = lib.versionAtLeast version "2.4pre";
3434 isExactly23 = lib.versionAtLeast version "2.3" && lib.versionOlder version "2.4";
3535
@@ -39,15 +39,16 @@ common =
3939
4040 nativeBuildInputs =
4141 [ pkgconfig ]
42− ++ lib.optionals (!is20) [ curl perl ]
43− ++ lib.optionals is24 [ jq ];
42+ ++ lib.optionals is24 [ autoreconfHook autoconf-archive bison flex libxml2 libxslt docbook5 docbook_xsl_ns jq ];
4443
45− buildInputs = [ curl openssl sqlite xz bzip2 nlohmann_json ]
44+ buildInputs =
45+ [ curl openssl sqlite xz bzip2 nlohmann_json
46+ brotli boost editline
47+ ]
4648 ++ lib.optional (stdenv.isLinux || stdenv.isDarwin) libsodium
47− ++ lib.optionals is20 [ brotli boost editline ]
4849 ++ lib.optionals is24 [ libarchive rustc cargo ]
4950 ++ lib.optional withLibseccomp libseccomp
50− ++ lib.optional (withAWS && is20)
51+ ++ lib.optional withAWS
5152 ((aws-sdk-cpp.override {
5253 apis = ["s3" "transfer"];
5354 customMemoryManagement = false;
@@ -66,7 +67,7 @@ common =
6667 preConfigure =
6768 # Copy libboost_context so we don't get all of Boost in our closure.
6869 # https://github.com/NixOS/nixpkgs/issues/45462
69− lib.optionalString is20 ''
70+ ''
7071 mkdir -p $out/lib
7172 cp -pd ${boost}/lib/{libboost_context*,libboost_thread*,libboost_system*} $out/lib
7273 rm -f $out/lib/*.a
@@ -75,6 +76,11 @@ common =
7576 patchelf --set-rpath $out/lib:${stdenv.cc.cc.lib}/lib $out/lib/libboost_thread.so.*
7677 ''}
7778 '' +
79+ # Unpack the Rust crates.
80+ lib.optionalString is24 ''
81+ tar xvf ${crates} -C nix-rust/
82+ mv nix-rust/nix-vendored-crates* nix-rust/vendor
83+ '' +
7884 # For Nix-2.3, patch around an issue where the Nix configure step pulls in the
7985 # build system's bash and other utilities when cross-compiling
8086 lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform && isExactly23) ''
@@ -97,12 +103,7 @@ common =
97103 "--disable-init-state"
98104 "--enable-gc"
99105 ]
100− ++ lib.optionals (!is20) [
101− "--with-dbi=${perlPackages.DBI}/${perl.libPrefix}"
102− "--with-dbd-sqlite=${perlPackages.DBDSQLite}/${perl.libPrefix}"
103− "--with-www-curl=${perlPackages.WWWCurl}/${perl.libPrefix}"
104− "BDW_GC_LIBS=\"-lgc -lgccpp\""
105− ] ++ lib.optionals (is20 && stdenv.isLinux) [
106+ ++ lib.optionals stdenv.isLinux [
106107 "--with-sandbox-shell=${sh}/bin/busybox"
107108 ]
108109 ++ lib.optional (
@@ -143,7 +144,7 @@ common =
143144 };
144145
145146 passthru = {
146− perl-bindings = if includesPerl then nix else stdenv.mkDerivation {
147+ perl-bindings = stdenv.mkDerivation {
147148 pname = "nix-perl";
148149 inherit version;
149150
@@ -154,8 +155,7 @@ common =
154155 # This is not cross-compile safe, don't have time to fix right now
155156 # but noting for future travellers.
156157 nativeBuildInputs =
157− [ perl pkgconfig curl nix libsodium ]
158− ++ lib.optional is20 boost;
158+ [ perl pkgconfig curl nix libsodium boost autoreconfHook autoconf-archive ];
159159
160160 configureFlags =
161161 [ "--with-dbi=${perlPackages.DBI}/${perl.libPrefix}"
@@ -174,19 +174,6 @@ in rec {
174174
175175 nix = nixStable;
176176
177− nix1 = callPackage common rec {
178− name = "nix-1.11.16";
179− src = fetchurl {
180− url = "http://nixos.org/releases/nix/${name}/${name}.tar.xz";
181− sha256 = "0ca5782fc37d62238d13a620a7b4bff6a200bab1bd63003709249a776162357c";
182− };
183−
184− # Nix1 has the perl bindings by default, so no need to build the manually.
185− includesPerl = true;
186−
187− inherit storeDir stateDir confDir boehmgc;
188− };
189−
190177 nixStable = callPackage common (rec {
191178 name = "nix-2.3.3";
192179 src = fetchurl {
@@ -201,10 +188,18 @@ in rec {
201188
202189 nixUnstable = lib.lowPrio (callPackage common rec {
203190 name = "nix-2.4${suffix}";
204− suffix = "pre7250_94c93437";
205− src = fetchurl {
206− url = "https://hydra.nixos.org/build/112193977/download/3/nix-2.4${suffix}.tar.xz";
207− sha256 = "f9baf241c9449c1e3e5c9610adbcd2ce9e5fbcab16aff3ba3030d2fad7b34d7b";
191+ suffix = "pre7346_5e7ccdc9";
192+
193+ src = fetchFromGitHub {
194+ owner = "NixOS";
195+ repo = "nix";
196+ rev = "5e7ccdc9e3ddd61dc85e20c898001345bfb497a5";
197+ sha256 = "10jg0rq92xbigbbri7harn4b75blqaf6rjgq4hhvlnggf2w9iprg";
198+ };
199+
200+ crates = fetchurl {
201+ url = https://hydra.nixos.org/build/115942497/download/1/nix-vendored-crates-2.4pre20200403_3473b19.tar.xz;
202+ sha256 = "a83785553bb4bc5b28220562153e201ec555a00171466ac08b716f0c97aee45a";
208203 };
209204
210205 inherit storeDir stateDir confDir boehmgc;
@@ -212,10 +207,18 @@ in rec {
212207
213208 nixFlakes = lib.lowPrio (callPackage common rec {
214209 name = "nix-2.4${suffix}";
215− suffix = "pre20200220_4a4521f";
216− src = fetchurl {
217− url = "https://hydra.nixos.org/build/113373394/download/3/nix-2.4${suffix}.tar.xz";
218− sha256 = "31fe87c40f40a590bc8f575283725d5f04ecb9aebb6b404f679d77438d75265d";
210+ suffix = "pre20200403_3473b19";
211+
212+ src = fetchFromGitHub {
213+ owner = "NixOS";
214+ repo = "nix";
215+ rev = "3473b1950a90d596a3baa080fdfdb080f55a5cc0";
216+ sha256 = "1bb7a8a5lzmb3pzq80zxd3s9y3qv757q7032s5wvp75la9wgvmvr";
217+ };
218+
219+ crates = fetchurl {
220+ url = https://hydra.nixos.org/build/115942497/download/1/nix-vendored-crates-2.4pre20200403_3473b19.tar.xz;
221+ sha256 = "a83785553bb4bc5b28220562153e201ec555a00171466ac08b716f0c97aee45a";
219222 };
220223
221224 inherit storeDir stateDir confDir boehmgc;