forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request NixOS#235466 from 06kellyjac/semgrep
- Loading branch information
Showing
4 changed files
with
102 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,52 @@ | ||
{ lib, stdenvNoCC, callPackage }: | ||
{ lib, stdenvNoCC, fetchPypi, unzip }: | ||
|
||
let | ||
common = callPackage ./common.nix { }; | ||
common = import ./common.nix { inherit lib; }; | ||
in | ||
stdenvNoCC.mkDerivation rec { | ||
pname = "semgrep-core"; | ||
inherit (common) version; | ||
inherit (common.core) src; | ||
# 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; | ||
python = "cp37.cp38.cp39.py37.py38.py39"; | ||
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; | ||
|
||
installPhase = '' | ||
runHook preInstall | ||
install -Dm 755 -t $out/bin semgrep-core | ||
install -Dm 755 -t $out/bin semgrep-${version}.data/purelib/semgrep/bin/semgrep-core | ||
runHook postInstall | ||
''; | ||
|
||
meta = common.meta // { | ||
description = common.meta.description + " - core binary"; | ||
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; | ||
platforms = lib.attrNames common.core; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters