at master 1.5 kB view raw
1{ 2 lib, 3 stdenvNoCC, 4 fetchPypi, 5 unzip, 6}: 7 8let 9 common = import ./common.nix { inherit lib; }; 10in 11stdenvNoCC.mkDerivation rec { 12 pname = "semgrep-core"; 13 inherit (common) version; 14 # fetch pre-built semgrep-core since the ocaml build is complex and relies on 15 # the opam package manager at some point 16 # pulling it out of the python wheel as r2c no longer release a built binary 17 # on github releases 18 src = 19 let 20 inherit (stdenvNoCC.hostPlatform) system; 21 data = common.core.${system} or (throw "Unsupported system: ${system}"); 22 in 23 fetchPypi rec { 24 pname = "semgrep"; 25 inherit version; 26 format = "wheel"; 27 dist = python; 28 python = "cp39.cp310.cp311.py39.py310.py311"; 29 inherit (data) platform hash; 30 }; 31 32 nativeBuildInputs = [ unzip ]; 33 34 # _tryUnzip from unzip's setup-hook doesn't recognise .whl 35 # "do not know how to unpack source archive" 36 # perform unpack by hand 37 unpackPhase = '' 38 runHook preUnpack 39 LANG=en_US.UTF-8 unzip -qq "$src" 40 runHook postUnpack 41 ''; 42 43 dontConfigure = true; 44 dontBuild = true; 45 46 installPhase = '' 47 runHook preInstall 48 install -Dm 755 -t $out/bin semgrep-${version}.data/purelib/semgrep/bin/semgrep-core 49 runHook postInstall 50 ''; 51 52 meta = common.meta // { 53 description = common.meta.description + " - core binary"; 54 mainProgram = "semgrep-core"; 55 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; 56 platforms = lib.attrNames common.core; 57 }; 58}