Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at devShellTools-shell 83 lines 2.0 kB view raw
1{ 2 lib, 3 stdenv, 4 fetchurl, 5 cctools, 6 fixDarwinDylibNames, 7 autoSignDarwinBinariesHook, 8 replaceVars, 9 buildPackages, 10 binutils, 11}: 12 13stdenv.mkDerivation rec { 14 pname = "lp_solve"; 15 version = "5.5.2.11"; 16 17 src = fetchurl { 18 url = "mirror://sourceforge/project/lpsolve/lpsolve/${version}/lp_solve_${version}_source.tar.gz"; 19 sha256 = "sha256-bUq/9cxqqpM66ObBeiJt8PwLZxxDj2lxXUHQn+gfkC8="; 20 }; 21 22 nativeBuildInputs = [ 23 binutils 24 ] 25 ++ lib.optionals stdenv.hostPlatform.isDarwin [ 26 cctools 27 fixDarwinDylibNames 28 ] 29 ++ lib.optionals (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64) [ 30 autoSignDarwinBinariesHook 31 ]; 32 33 env = { 34 NIX_CFLAGS_COMPILE = "-Wno-error=implicit-int"; 35 } 36 // lib.optionalAttrs (stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isx86_64) { 37 NIX_LDFLAGS = "-headerpad_max_install_names"; 38 }; 39 40 dontConfigure = true; 41 42 patches = [ 43 (replaceVars ./0001-fix-cross-compilation.patch { 44 emulator = "${stdenv.hostPlatform.emulator buildPackages}"; 45 }) 46 ]; 47 48 buildPhase = 49 let 50 ccc = if stdenv.hostPlatform.isDarwin then "ccc.osx" else "ccc"; 51 in 52 '' 53 runHook preBuild 54 55 (cd lpsolve55 && bash -x -e ${ccc}) 56 (cd lp_solve && bash -x -e ${ccc}) 57 58 runHook postBuild 59 ''; 60 61 installPhase = '' 62 runHook preInstall 63 64 install -d -m755 $out/bin $out/lib $out/include/lpsolve 65 install -m755 lp_solve/bin/*/lp_solve -t $out/bin 66 install -m644 lpsolve55/bin/*/liblpsolve* -t $out/lib 67 install -m644 lp_*.h -t $out/include/lpsolve 68 69 rm $out/lib/liblpsolve*.a 70 rm $out/include/lpsolve/lp_solveDLL.h # A Windows header 71 72 runHook postInstall 73 ''; 74 75 meta = with lib; { 76 description = "Mixed Integer Linear Programming (MILP) solver"; 77 mainProgram = "lp_solve"; 78 homepage = "https://lpsolve.sourceforge.net"; 79 license = licenses.gpl2Plus; 80 maintainers = with maintainers; [ smironov ]; 81 platforms = platforms.unix; 82 }; 83}