2023-06-14 08:30:13 +00:00
|
|
|
{ lib, stdenvNoCC, fetchPypi, unzip }:
|
2022-07-13 07:33:54 +00:00
|
|
|
|
|
|
|
let
|
2023-06-14 08:30:13 +00:00
|
|
|
common = import ./common.nix { inherit lib; };
|
2022-07-13 07:33:54 +00:00
|
|
|
in
|
|
|
|
stdenvNoCC.mkDerivation rec {
|
|
|
|
pname = "semgrep-core";
|
|
|
|
inherit (common) version;
|
2023-06-14 08:30:13 +00:00
|
|
|
# fetch pre-built semgrep-core since the ocaml build is complex and relies on
|
|
|
|
# the opam package manager at some point
|
|
|
|
# pulling it out of the python wheel as r2c no longer release a built binary
|
|
|
|
# on github releases
|
|
|
|
src =
|
|
|
|
let
|
|
|
|
inherit (stdenvNoCC.hostPlatform) system;
|
|
|
|
data = common.core.${system} or (throw "Unsupported system: ${system}");
|
|
|
|
in
|
|
|
|
fetchPypi rec {
|
|
|
|
pname = "semgrep";
|
|
|
|
inherit version;
|
|
|
|
format = "wheel";
|
|
|
|
dist = python;
|
2023-07-31 09:47:18 +00:00
|
|
|
python = "cp37.cp38.cp39.cp310.cp311.py37.py38.py39.py310.py311";
|
2023-06-14 08:30:13 +00:00
|
|
|
inherit (data) platform hash;
|
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ unzip ];
|
|
|
|
|
|
|
|
# _tryUnzip from unzip's setup-hook doesn't recognise .whl
|
|
|
|
# "do not know how to unpack source archive"
|
|
|
|
# perform unpack by hand
|
|
|
|
unpackPhase = ''
|
|
|
|
runHook preUnpack
|
|
|
|
LANG=en_US.UTF-8 unzip -qq "$src"
|
|
|
|
runHook postUnpack
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
dontBuild = true;
|
2022-07-13 07:33:54 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
2023-06-14 08:30:13 +00:00
|
|
|
install -Dm 755 -t $out/bin semgrep-${version}.data/purelib/semgrep/bin/semgrep-core
|
2022-07-13 07:33:54 +00:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = common.meta // {
|
|
|
|
description = common.meta.description + " - core binary";
|
|
|
|
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
|
2023-06-14 08:30:13 +00:00
|
|
|
platforms = lib.attrNames common.core;
|
2022-07-13 07:33:54 +00:00
|
|
|
};
|
|
|
|
}
|