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