summary refs log tree commit diff
path: root/pkgs/tools
diff options
context:
space:
mode:
authorBernardo Meurer <bernardo@meurer.org>2022-01-26 11:31:20 -0800
committerBernardo Meurer <bernardo@meurer.org>2022-01-26 12:19:10 -0800
commit421abd6e8a2e03c0056487da2cd4123a25e02fa7 (patch)
treef6d958104c10034e8c4b00db2107791c7ce9e095 /pkgs/tools
parentc1d240ffcb119c201ef1f59d4cd6e5136071a308 (diff)
downloadnixpkgs-421abd6e8a2e03c0056487da2cd4123a25e02fa7.tar
nixpkgs-421abd6e8a2e03c0056487da2cd4123a25e02fa7.tar.gz
nixpkgs-421abd6e8a2e03c0056487da2cd4123a25e02fa7.tar.bz2
nixpkgs-421abd6e8a2e03c0056487da2cd4123a25e02fa7.tar.lz
nixpkgs-421abd6e8a2e03c0056487da2cd4123a25e02fa7.tar.xz
nixpkgs-421abd6e8a2e03c0056487da2cd4123a25e02fa7.tar.zst
nixpkgs-421abd6e8a2e03c0056487da2cd4123a25e02fa7.zip
nixVersions: move buildNix functionality into common.nix
Diffstat (limited to 'pkgs/tools')
-rw-r--r--pkgs/tools/package-management/nix/common.nix36
-rw-r--r--pkgs/tools/package-management/nix/default.nix58
2 files changed, 41 insertions, 53 deletions
diff --git a/pkgs/tools/package-management/nix/common.nix b/pkgs/tools/package-management/nix/common.nix
index b0e6b5fdd05..1df29b79163 100644
--- a/pkgs/tools/package-management/nix/common.nix
+++ b/pkgs/tools/package-management/nix/common.nix
@@ -1,3 +1,15 @@
+{ lib, fetchFromGitHub
+, version
+, suffix ? ""
+, sha256 ? null
+, src ? fetchFromGitHub { owner = "NixOS"; repo = "nix"; rev = version; inherit sha256; }
+, patches ? [ ]
+}:
+assert (sha256 == null) -> (src != null);
+let
+  atLeast24 = lib.versionAtLeast version "2.4pre";
+  atLeast25 = lib.versionAtLeast version "2.5pre";
+in
 { stdenv
 , autoconf-archive
 , autoreconfHook
@@ -32,7 +44,7 @@
 , util-linuxMinimal
 , xz
 
-, enableDocumentation ? lib.versionOlder version "2.4pre" || stdenv.hostPlatform == stdenv.buildPlatform
+, enableDocumentation ? atLeast24 || stdenv.hostPlatform == stdenv.buildPlatform
 , enableStatic ? stdenv.hostPlatform.isStatic
 , withAWS ? !enableStatic && (stdenv.isLinux || stdenv.isDarwin), aws-sdk-cpp
 , withLibseccomp ? lib.meta.availableOn stdenv.hostPlatform libseccomp, libseccomp
@@ -40,32 +52,18 @@
 , confDir
 , stateDir
 , storeDir
-
-, version
-, src
-, suffix ? ""
-, patches ? [ ]
 }:
 let
   sh = busybox-sandbox-shell;
-
-  atLeast24 = lib.versionAtLeast version "2.4pre";
-  atLeast25 = lib.versionAtLeast version "2.5pre";
-
-  nix-aws-sdk = (aws-sdk-cpp.override {
-    apis = [ "s3" "transfer" ];
-    customMemoryManagement = false;
-  }).overrideDerivation (args: {
-    patches = (args.patches or [ ]) ++ [ ./patches/aws-sdk-cpp-TransferManager-ContentEncoding.patch ];
-  });
 in
 stdenv.mkDerivation {
   pname = "nix";
-  inherit src patches;
 
   version = "${version}${suffix}";
   VERSION_SUFFIX = suffix;
 
+  inherit src patches;
+
   outputs =
     [ "out" "dev" ]
     ++ lib.optionals enableDocumentation [ "man" "doc" ];
@@ -108,7 +106,7 @@ stdenv.mkDerivation {
   ] ++ lib.optionals withLibseccomp [
     libseccomp
   ] ++ lib.optionals withAWS [
-    nix-aws-sdk
+    aws-sdk-cpp
   ];
 
   propagatedBuildInputs = [ boehmgc ];
@@ -208,6 +206,6 @@ stdenv.mkDerivation {
   passthru = {
     inherit boehmgc;
 
-    perl-bindings = perl.pkgs.toPerlModule (callPackage ./nix-perl.nix { inherit version src; });
+    perl-bindings = perl.pkgs.toPerlModule (callPackage ./nix-perl.nix { inherit src version;  });
   };
 }
diff --git a/pkgs/tools/package-management/nix/default.nix b/pkgs/tools/package-management/nix/default.nix
index 38bf1933f85..490ddcc53bf 100644
--- a/pkgs/tools/package-management/nix/default.nix
+++ b/pkgs/tools/package-management/nix/default.nix
@@ -1,8 +1,10 @@
 { lib
+, aws-sdk-cpp
 , boehmgc
 , callPackage
 , fetchFromGitHub
 , fetchurl
+, fetchpatch
 , Security
 
 , storeDir ? "/nix/store"
@@ -10,64 +12,52 @@
 , confDir ? "/etc"
 }:
 let
-  boehmgc_nix_2_3 = boehmgc.override { enableLargeConfig = true; };
+  boehmgc-nix_2_3 = boehmgc.override { enableLargeConfig = true; };
 
-  boehmgc_nix = boehmgc_nix_2_3.overrideAttrs (drv: {
+  boehmgc-nix = boehmgc-nix_2_3.overrideAttrs (drv: {
     # Part of the GC solution in https://github.com/NixOS/nix/pull/4944
     patches = (drv.patches or [ ]) ++ [ ./patches/boehmgc-coroutine-sp-fallback.patch ];
   });
 
-  buildNix =
-    { version
-    , suffix ? ""
-    , src ? null
-    , sha256  ? null
-    , boehmgc ? boehmgc_nix
-    , patches ? [ ]
-    }:
-      assert (src == null) -> (sha256 != null);
-      assert (sha256 == null) -> (src != null);
-    callPackage ./common.nix {
-      inherit version suffix;
-
-      src =
-        if src != null
-        then src
-        else fetchFromGitHub {
-          owner = "NixOS";
-          repo = "nix";
-          rev = version;
-          inherit sha256;
-        };
+  aws-sdk-cpp-nix = (aws-sdk-cpp.override {
+    apis = [ "s3" "transfer" ];
+    customMemoryManagement = false;
+  }).overrideDerivation (args: {
+    patches = (args.patches or [ ]) ++ [ ./patches/aws-sdk-cpp-TransferManager-ContentEncoding.patch ];
+  });
 
-      inherit boehmgc patches Security;
-      inherit storeDir stateDir confDir;
-    };
+  common = args:
+    callPackage
+      (import ./common.nix ({ inherit lib fetchFromGitHub; } // args))
+      {
+        inherit Security storeDir stateDir confDir;
+        boehmgc = boehmgc-nix;
+        aws-sdk-cpp = aws-sdk-cpp-nix;
+      };
 in rec {
-  nix_2_3 = buildNix rec {
+  nix_2_3 = (common rec {
     version = "2.3.16";
     src = fetchurl {
       url = "https://nixos.org/releases/nix/nix-${version}/nix-${version}.tar.xz";
       sha256 = "sha256-fuaBtp8FtSVJLSAsO+3Nne4ZYLuBj2JpD2xEk7fCqrw=";
     };
-    boehmgc = boehmgc_nix_2_3;
-  };
+  }).override { boehmgc = boehmgc-nix_2_3; };
 
-  nix_2_4 = buildNix {
+  nix_2_4 = common {
     version = "2.4";
     sha256 = "sha256-op48CCDgLHK0qV1Batz4Ln5FqBiRjlE6qHTiZgt3b6k=";
     # https://github.com/NixOS/nix/pull/5537
     patches = [ ./patches/install-nlohmann_json-headers.patch ];
   };
 
-  nix_2_5 = buildNix {
+  nix_2_5 = common {
     version = "2.5.1";
     sha256 = "sha256-GOsiqy9EaTwDn2PLZ4eFj1VkXcBUbqrqHehRE9GuGdU=";
     # https://github.com/NixOS/nix/pull/5536
     patches = [ ./patches/install-nlohmann_json-headers.patch ];
   };
 
-  nix_2_6 = buildNix {
+  nix_2_6 = common {
     version = "2.6.0";
     sha256 = "sha256-xEPeMcNJVOeZtoN+d+aRwolpW8mFSEQx76HTRdlhPhg=";
   };
@@ -75,7 +65,7 @@ in rec {
   # FIXME: nix_2_6 is broken on aarch64-darwin for now.
   stable = nix_2_5;
 
-  unstable = lib.lowPrio (buildNix rec {
+  unstable = lib.lowPrio (common rec {
     version = "2.7";
     suffix = "pre20220124_${lib.substring 0 7 src.rev}";
     src = fetchFromGitHub {