at 23.11-beta 141 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.16.1"; 16 17 src = fetchFromGitHub { 18 owner = "exaloop"; 19 repo = "codon"; 20 rev = "v${version}"; 21 hash = "sha256-s2GqiFcekXRts8BU5CSmTrkFZ9xLqq4A5MybhB1o1Gg="; 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 hash = "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 "-DLLVM_ENABLE_RTTI=ON" 47 "-DLLVM_ENABLE_TERMINFO=OFF" 48 "-DLLVM_ENABLE_ZLIB=OFF" 49 "-DLLVM_INCLUDE_TESTS=OFF" 50 "-DLLVM_TARGETS_TO_BUILD=all" 51 "-DLLVM_USE_LINKER=lld" 52 "-S ../llvm" 53 ]; 54 }; 55 56 codon-deps = stdenv.mkDerivation { 57 name = "codon-deps-${version}.tar.gz"; 58 59 inherit src; 60 61 nativeBuildInputs = [ 62 cacert 63 cmake 64 git 65 perl 66 python3 67 ]; 68 69 dontBuild = true; 70 71 cmakeFlags = [ 72 "-DCPM_DOWNLOAD_ALL=ON" 73 "-DCPM_SOURCE_CACHE=${depsDir}" 74 "-DLLVM_DIR=${codon-llvm}/lib/cmake/llvm" 75 ]; 76 77 installPhase = '' 78 # Prune the `.git` directories 79 find ${depsDir} -name .git -type d -prune -exec rm -rf {} \;; 80 # Build a reproducible tar, per instructions at https://reproducible-builds.org/docs/archives/ 81 tar --owner=0 --group=0 --numeric-owner --format=gnu \ 82 --sort=name --mtime="@$SOURCE_DATE_EPOCH" \ 83 -czf $out \ 84 ${depsDir} \ 85 cmake \ 86 _deps/googletest-subbuild/googletest-populate-prefix/src/*.zip 87 ''; 88 89 outputHash = 90 if stdenv.hostPlatform.isDarwin then 91 "sha256-KfemYV42xBAhsPbwTkzdc3GxCVHiWRbyUZORPWxx4vg=" 92 else 93 "sha256-a1zGSpbMjfQBrcgW/aiIdKX8+uI3p/S9pgZjHe2HtWs="; 94 95 outputHashAlgo = "sha256"; 96 }; 97in 98stdenv.mkDerivation { 99 pname = "codon"; 100 101 inherit src version; 102 103 patches = [ 104 # Without the hash, CMake will try to replace the `.zip` file 105 ./Add-a-hash-to-the-googletest-binary.patch 106 ]; 107 108 nativeBuildInputs = [ 109 cmake 110 git 111 lld 112 ninja 113 perl 114 python3 115 ]; 116 117 postUnpack = '' 118 mkdir -p $sourceRoot/build 119 tar -xf ${codon-deps} -C $sourceRoot/build 120 ''; 121 122 cmakeFlags = [ 123 "-DCPM_SOURCE_CACHE=${depsDir}" 124 "-DLLVM_DIR=${codon-llvm}/lib/cmake/llvm" 125 "-DLLVM_USE_LINKER=lld" 126 ]; 127 128 postInstall = lib.optionalString stdenv.isDarwin '' 129 ln -s $out/lib/codon/*.dylib $out/lib/ 130 ''; 131 132 passthru.updateScript = nix-update-script { }; 133 134 meta = { 135 description = "A high-performance, zero-overhead, extensible Python compiler using LLVM"; 136 homepage = "https://docs.exaloop.io/codon"; 137 maintainers = [ lib.maintainers.paveloom ]; 138 license = lib.licenses.bsl11; 139 platforms = lib.platforms.all; 140 }; 141}