summary refs log tree commit diff
diff options
context:
space:
mode:
authorsternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-08-03 21:35:28 +0200
committersternenseemann <0rpkxez4ksa01gb3typccl0i@systemli.org>2021-08-04 12:00:55 +0200
commitf3a42b27e3bb9187d7496cee65572be2dafe21a3 (patch)
tree559768bd5c2a7ff968bc86ec55304bea405796bd
parent7b8141a42c35b08f6392ba72e4c395679e47574c (diff)
downloadnixpkgs-f3a42b27e3bb9187d7496cee65572be2dafe21a3.tar
nixpkgs-f3a42b27e3bb9187d7496cee65572be2dafe21a3.tar.gz
nixpkgs-f3a42b27e3bb9187d7496cee65572be2dafe21a3.tar.bz2
nixpkgs-f3a42b27e3bb9187d7496cee65572be2dafe21a3.tar.lz
nixpkgs-f3a42b27e3bb9187d7496cee65572be2dafe21a3.tar.xz
nixpkgs-f3a42b27e3bb9187d7496cee65572be2dafe21a3.tar.zst
nixpkgs-f3a42b27e3bb9187d7496cee65572be2dafe21a3.zip
boost-build: allow supplying a boost version to build b2 for
The `useBoost` argument expects an attribute set with an src and version
attribute (so a boost derivation works) and builds b2 for the given
version of boost. This is useful when bootstrapping boost: We can
override boost-build to get a boost-build derivation matching the
current boost version we want to build (b2 is not backwards compatible
enough to build older boost versions) without the need of having
one boost-build${version} attribute for every boost version we have
which is not very useful for nixpkgs' users.
-rw-r--r--pkgs/development/tools/boost-build/default.nix35
1 files changed, 29 insertions, 6 deletions
diff --git a/pkgs/development/tools/boost-build/default.nix b/pkgs/development/tools/boost-build/default.nix
index 5016aa590b5..c6c66d4d212 100644
--- a/pkgs/development/tools/boost-build/default.nix
+++ b/pkgs/development/tools/boost-build/default.nix
@@ -2,18 +2,36 @@
 , stdenv
 , fetchFromGitHub
 , bison
+# boost derivation to use for the src and version.
+# This is used by the boost derivation to build
+# a b2 matching their version (by overriding this
+# argument). Infinite recursion is not an issue
+# since we only look at src and version of boost.
+, useBoost ? {}
 }:
 
-stdenv.mkDerivation rec {
+let
+  defaultVersion = "4.4.1";
+in
+
+stdenv.mkDerivation {
   pname = "boost-build";
-  version = "4.4.1";
+  version =
+    if useBoost ? version
+    then "boost-${useBoost.version}"
+    else defaultVersion;
 
-  src = fetchFromGitHub {
+  src = useBoost.src or (fetchFromGitHub {
     owner = "boostorg";
     repo = "build";
-    rev = version;
+    rev = defaultVersion;
     sha256 = "1r4rwlq87ydmsdqrik4ly5iai796qalvw7603mridg2nwcbbnf54";
-  };
+  });
+
+  # b2 is in a subdirectory of boost source tarballs
+  postUnpack = lib.optionalString (useBoost ? src) ''
+    sourceRoot="$sourceRoot/tools/build"
+  '';
 
   patches = [
     # Upstream defaults to gcc on darwin, but we use clang.
@@ -32,8 +50,13 @@ stdenv.mkDerivation rec {
 
   installPhase = ''
     runHook preInstall
+
     ./b2 install --prefix="$out"
-    ln -s b2 "$out/bin/bjam"
+
+    # older versions of b2 created this symlink,
+    # which we want to support building via useBoost.
+    test -e "$out/bin/bjam" || ln -s b2 "$out/bin/bjam"
+
     runHook postInstall
   '';