at master 125 lines 3.4 kB view raw
1{ 2 stdenv, 3 lib, 4 build2, 5 fetchurl, 6 fixDarwinDylibNames, 7 libbutl, 8 libpkgconf, 9 buildPackages, 10 enableShared ? !stdenv.hostPlatform.isStatic, 11 enableStatic ? !enableShared, 12}: 13let 14 configSharedStatic = 15 enableShared: enableStatic: 16 if enableShared && enableStatic then 17 "both" 18 else if enableShared then 19 "shared" 20 else if enableStatic then 21 "static" 22 else 23 throw "neither shared nor static libraries requested"; 24in 25stdenv.mkDerivation rec { 26 pname = "build2"; 27 version = "0.17.0"; 28 29 outputs = [ 30 "out" 31 "dev" 32 "doc" 33 "man" 34 ]; 35 36 setupHook = ./setup-hook.sh; 37 38 src = fetchurl { 39 url = "https://pkg.cppget.org/1/alpha/build2/build2-${version}.tar.gz"; 40 hash = "sha256-Kx5X/GV3GjFSbjo1mzteiHnnm4mr6+NAKIR/mEE+IdA="; 41 }; 42 43 patches = [ 44 # Remove any build/host config entries which refer to nix store paths 45 ./remove-config-store-paths.patch 46 # Pick up sysdirs from NIX_LDFLAGS 47 ./nix-ldflags-sysdirs.patch 48 ]; 49 50 strictDeps = true; 51 nativeBuildInputs = [ 52 build2 53 ]; 54 disallowedReferences = [ 55 build2 56 libbutl.dev 57 libpkgconf.dev 58 ]; 59 buildInputs = [ 60 libbutl 61 libpkgconf 62 ]; 63 64 # Build2 uses @rpath on darwin 65 # https://github.com/build2/build2/issues/166 66 # N.B. this only adjusts the install_name after all libraries are installed; 67 # packages containing multiple interdependent libraries may have 68 # LC_LOAD_DYLIB entries containing @rpath, requiring manual fixup 69 propagatedBuildInputs = lib.optionals stdenv.targetPlatform.isDarwin [ 70 fixDarwinDylibNames 71 72 # Build2 needs to use lld on Darwin because it creates thin archives when it detects `llvm-ar`, 73 # which ld64 does not support. 74 (lib.getBin buildPackages.llvmPackages.lld) 75 ]; 76 77 postPatch = '' 78 patchShebangs --build tests/bash/testscript 79 ''; 80 81 build2ConfigureFlags = [ 82 "config.bin.lib=${configSharedStatic enableShared enableStatic}" 83 "config.cc.poptions+=-I${lib.getDev libpkgconf}/include/pkgconf" 84 "config.build2.libpkgconf=true" 85 ]; 86 87 postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' 88 install_name_tool -add_rpath "''${!outputLib}/lib" "''${!outputBin}/bin/b" 89 ''; 90 91 postFixup = '' 92 substituteInPlace $dev/nix-support/setup-hook \ 93 --subst-var-by isTargetDarwin '${toString stdenv.targetPlatform.isDarwin}' 94 ''; 95 96 passthru = { 97 bootstrap = build2; 98 inherit configSharedStatic; 99 }; 100 101 meta = with lib; { 102 homepage = "https://www.build2.org/"; 103 description = "Build2 build system"; 104 license = licenses.mit; 105 longDescription = '' 106 build2 is an open source (MIT), cross-platform build toolchain 107 that aims to approximate Rust Cargo's convenience for developing 108 and packaging C/C++ projects while providing more depth and 109 flexibility, especially in the build system. 110 111 build2 is a hierarchy of tools consisting of a general-purpose 112 build system, package manager (for package consumption), and 113 project manager (for project development). It is primarily aimed 114 at C/C++ projects as well as mixed-language projects involving 115 one of these languages (see bash and rust modules, for example). 116 ''; 117 changelog = "https://git.build2.org/cgit/build2/tree/NEWS"; 118 platforms = platforms.all; 119 maintainers = with maintainers; [ 120 hiro98 121 r-burns 122 ]; 123 mainProgram = "b"; 124 }; 125}