forked from semgrep/semgrep
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpysemgrep.nix
More file actions
50 lines (42 loc) · 1.54 KB
/
pysemgrep.nix
File metadata and controls
50 lines (42 loc) · 1.54 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
{ src ? ./cli }:
{ pkgs, semgrep }:
let
pythonPkgs = pkgs.python312Packages;
# pysemgrep inputs pulled from pipfile
pydepsFromPipfile = setupPy: pipfile: type:
let
pipfileLockInputs'' = with builtins;
(attrNames ((fromJSON (readFile (pipfile))).${type}));
# remove semgrep from the lockfile inputs
pipfileLockInputs' = pkgs.lib.lists.remove "semgrep" pipfileLockInputs'';
setupPyFile = (builtins.readFile setupPy);
# check if the package is in the setup.py before adding it to the list
isInSetupPy = name: (builtins.match ".*${name}.*" setupPyFile) != null;
pipfileLockInputs = builtins.filter isInSetupPy pipfileLockInputs';
# replace . with -
in builtins.map (name: builtins.replaceStrings [ "." ] [ "-" ] name)
pipfileLockInputs;
pipfile = src + "/Pipfile.lock";
setupPy = src + "/setup.py";
pythonInputs = builtins.map (name: pythonPkgs.${name})
(pydepsFromPipfile setupPy pipfile "default");
# TODO get working
# devPythonInputs = builtins.map (name: pythonPkgs.${name})
# ((pydepsFromPipfile pipfile "develop"));
devPkgs = [ pkgs.pipenv ];
pysemgrep = pythonPkgs.buildPythonApplication {
# thanks to @06kellyjac
pname = "pysemgrep";
inherit (semgrep) version;
inherit src;
pyproject = true;
build-system = [ pythonPkgs.setuptools ];
propagatedBuildInputs = pythonInputs ++ [ semgrep ];
# Stops weird long step when entering shell
dontUseSetuptoolsShellHook = true;
};
in {
pkg = pysemgrep;
devEnv = { };
inherit devPkgs;
}