Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at litex 137 lines 3.0 kB view raw
1{ cacert 2, cmake 3, fetchFromGitHub 4, git 5, lib 6, lld 7, ninja 8, nix-update-script 9, perl 10, python3 11, stdenv 12}: 13 14let 15 version = "0.15.5"; 16 17 src = fetchFromGitHub { 18 owner = "exaloop"; 19 repo = "codon"; 20 rev = "v${version}"; 21 sha256 = "sha256-/IUGX5iSRvZzwyRdkGe0IVHp44D+GXZtbkdtswekwSU="; 22 }; 23 24 depsDir = "deps"; 25 26 codon-llvm = stdenv.mkDerivation { 27 pname = "codon-llvm"; 28 version = "unstable-2022-09-23"; 29 30 src = fetchFromGitHub { 31 owner = "exaloop"; 32 repo = "llvm-project"; 33 rev = "55b0b8fa1c9f9082b535628fc9fa6313280c0b9a"; 34 sha256 = "sha256-03SPQgNdrpR6/JZ5aR/ntoh/FnZvCjT/6bTAcZaFafw="; 35 }; 36 37 nativeBuildInputs = [ 38 cmake 39 git 40 lld 41 ninja 42 python3 43 ]; 44 45 cmakeFlags = [ 46 "-DCMAKE_CXX_COMPILER=clang++" 47 "-DCMAKE_C_COMPILER=clang" 48 "-DLLVM_ENABLE_RTTI=ON" 49 "-DLLVM_ENABLE_TERMINFO=OFF" 50 "-DLLVM_ENABLE_ZLIB=OFF" 51 "-DLLVM_INCLUDE_TESTS=OFF" 52 "-DLLVM_TARGETS_TO_BUILD=all" 53 "-DLLVM_USE_LINKER=lld" 54 "-S ../llvm" 55 ]; 56 }; 57 58 codon-deps = stdenv.mkDerivation { 59 name = "codon-deps-${version}.tar.gz"; 60 61 inherit src; 62 63 nativeBuildInputs = [ 64 cacert 65 cmake 66 git 67 perl 68 python3 69 ]; 70 71 dontBuild = true; 72 73 cmakeFlags = [ 74 "-DCPM_DOWNLOAD_ALL=ON" 75 "-DCPM_SOURCE_CACHE=${depsDir}" 76 "-DLLVM_DIR=${codon-llvm}/lib/cmake/llvm" 77 ]; 78 79 installPhase = '' 80 # Prune the `.git` directories 81 find ${depsDir} -name .git -type d -prune -exec rm -rf {} \;; 82 # Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/ 83 tar --owner=0 --group=0 --numeric-owner --format=gnu \ 84 --sort=name --mtime="@$SOURCE_DATE_EPOCH" \ 85 -czf $out \ 86 ${depsDir} \ 87 cmake \ 88 _deps/googletest-subbuild/googletest-populate-prefix/src/*.zip 89 ''; 90 91 outputHash = "sha256-a1zGSpbMjfQBrcgW/aiIdKX8+uI3p/S9pgZjHe2HtWs="; 92 outputHashAlgo = "sha256"; 93 }; 94in 95stdenv.mkDerivation { 96 pname = "codon"; 97 98 inherit src version; 99 100 patches = [ 101 # Without the hash, CMake will try to replace the `.zip` file 102 ./Add-a-hash-to-the-googletest-binary.patch 103 ]; 104 105 nativeBuildInputs = [ 106 cmake 107 git 108 lld 109 ninja 110 perl 111 python3 112 ]; 113 114 postUnpack = '' 115 mkdir -p $sourceRoot/build 116 tar -xf ${codon-deps} -C $sourceRoot/build 117 ''; 118 119 cmakeFlags = [ 120 "-DCMAKE_BUILD_TYPE=Release" 121 "-DCMAKE_CXX_COMPILER=clang++" 122 "-DCMAKE_C_COMPILER=clang" 123 "-DCPM_SOURCE_CACHE=${depsDir}" 124 "-DLLVM_DIR=${codon-llvm}/lib/cmake/llvm" 125 "-DLLVM_USE_LINKER=lld" 126 ]; 127 128 passthru.updateScript = nix-update-script { }; 129 130 meta = { 131 description = "A high-performance, zero-overhead, extensible Python compiler using LLVM"; 132 homepage = "https://docs.exaloop.io/codon"; 133 maintainers = [ lib.maintainers.paveloom ]; 134 license = lib.licenses.bsl11; 135 platforms = lib.platforms.all; 136 }; 137}