2021-10-28 06:52:43 +00:00
|
|
|
{ lib, stdenv
|
|
|
|
, fetchurl
|
|
|
|
, pkgs
|
2023-07-15 17:15:38 +00:00
|
|
|
, buildPackages
|
2021-10-28 06:52:43 +00:00
|
|
|
, fixDarwinDylibNames
|
|
|
|
}:
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "build2-bootstrap";
|
2022-10-30 15:09:59 +00:00
|
|
|
version = "0.15.0";
|
2021-10-28 06:52:43 +00:00
|
|
|
src = fetchurl {
|
|
|
|
url = "https://download.build2.org/${version}/build2-toolchain-${version}.tar.xz";
|
2022-10-30 15:09:59 +00:00
|
|
|
sha256 = "1i1p52fr5sjs5yz6hqhljwhc148mvs4fyq0cf7wjg5pbv9wzclji";
|
2021-10-28 06:52:43 +00:00
|
|
|
};
|
|
|
|
patches = [
|
|
|
|
# Pick up sysdirs from NIX_LDFLAGS
|
|
|
|
./nix-ldflags-sysdirs.patch
|
|
|
|
];
|
|
|
|
|
|
|
|
sourceRoot = "build2-toolchain-${version}/build2";
|
|
|
|
makefile = "bootstrap.gmake";
|
|
|
|
enableParallelBuilding = true;
|
|
|
|
|
|
|
|
setupHook = ./setup-hook.sh;
|
|
|
|
|
|
|
|
strictDeps = true;
|
|
|
|
|
|
|
|
propagatedBuildInputs = lib.optionals stdenv.targetPlatform.isDarwin [
|
|
|
|
fixDarwinDylibNames
|
2023-07-15 17:15:38 +00:00
|
|
|
|
|
|
|
# Build2 needs to use lld on Darwin because it creates thin archives when it detects `llvm-ar`,
|
|
|
|
# which ld64 does not support.
|
|
|
|
(lib.getBin buildPackages.llvmPackages_16.lld)
|
2021-10-28 06:52:43 +00:00
|
|
|
];
|
|
|
|
|
|
|
|
doCheck = true;
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
build2/b-boot --version
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
install -D build2/b-boot $out/bin/b
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2023-07-15 17:15:38 +00:00
|
|
|
postFixup = ''
|
|
|
|
substituteInPlace $out/nix-support/setup-hook \
|
|
|
|
--subst-var-by isTargetDarwin '${toString stdenv.targetPlatform.isDarwin}'
|
|
|
|
'';
|
|
|
|
|
2021-10-28 06:52:43 +00:00
|
|
|
inherit (pkgs.build2) passthru;
|
|
|
|
}
|