Skip to content

Commit c5be6b1

Browse files
committed
Add support for additional packs and extractors
1 parent 3efa7b5 commit c5be6b1

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

scripts/codeql/codeql-cli/2.16.0.nix

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
{ lib, stdenv, fetchzip, withQlExtractor ? null}:
1+
{ lib, stdenv, fetchzip, withExtractors ? [], withPacks ? [] }:
22

33
stdenv.mkDerivation rec {
44
pname = "codeql-cli";
@@ -11,25 +11,30 @@ stdenv.mkDerivation rec {
1111

1212
src = fetchzip {
1313
url = "https://github.com/github/codeql-cli-binaries/releases/download/v${version}/codeql-${platform}.zip";
14-
hash = "sha256-trWUSMOT7h7J5ejjp9PzhGgBS3DYsJxzcv6aYKuk8TI=";
14+
hash = "sha256-trWUSMOT7h7J5ejjp9PzhGgBS3DYsJxzcv6aYKuk8TI=";
1515
};
16-
17-
buildInputs = if isNull withQlExtractor then [ ] else [ withQlExtractor ];
18-
inherit withQlExtractor;
16+
17+
buildInputs = if (lib.length withExtractors) == 0 then [ ] else withExtractors;
18+
inherit withExtractors withPacks;
1919

2020
installPhase = ''
2121
# codeql directory should not be top-level, otherwise,
2222
# it'll include /nix/store to resolve extractors.
2323
env
24-
mkdir -p $out/{codeql,bin}
24+
mkdir -p $out/{codeql/qlpacks,bin}
2525
cp -R * $out/codeql/
2626
2727
ln -s $out/codeql/codeql $out/bin/
2828
29-
if [ -n "$withQlExtractor" ]; then
29+
for extractor in $withExtractors; do
3030
# Copy the extractor, because CodeQL doesn't follow symlinks.
31-
cp -R $withQlExtractor $out/codeql/ql
32-
fi
31+
cp -R $extractor $out/codeql/ql
32+
done
33+
34+
for pack in $withPacks ; do
35+
# Copy the pack, because CodeQL doesn't follow symlinks.
36+
cp -R $pack/ $out/codeql/qlpacks/
37+
done
3338
'';
3439

3540

0 commit comments

Comments
 (0)