1{
2 buildNpmPackage,
3 fetchFromGitHub,
4 lib,
5 nix-update-script,
6 gitlab-ci-local,
7 testers,
8 makeBinaryWrapper,
9 rsync,
10 gitMinimal,
11}:
12
13buildNpmPackage rec {
14 pname = "gitlab-ci-local";
15 version = "4.60.1";
16
17 src = fetchFromGitHub {
18 owner = "firecow";
19 repo = "gitlab-ci-local";
20 rev = version;
21 hash = "sha256-6v5iyQCP+3bJdG9uvPAsMaJ7mW2xj1kMhn8h2eLsl28=";
22 };
23
24 npmDepsHash = "sha256-P09uxOtlY9AAJyKLTdnFOfw0H6V4trr2hznEonOO58E=";
25
26 nativeBuildInputs = [
27 makeBinaryWrapper
28 ];
29
30 postPatch = ''
31 # remove cleanup which runs git commands
32 substituteInPlace package.json \
33 --replace-fail "npm run cleanup" "true"
34 '';
35
36 postInstall = ''
37 NODE_MODULES=$out/lib/node_modules/gitlab-ci-local/node_modules
38
39 # Remove intermediate build files for re2 to reduce dependencies.
40 #
41 # This does not affect the behavior. On npm `re2` does not ship
42 # the build directory and downloads a prebuilt version of the
43 # `re2.node` binary. This method produces the same result.
44 find $NODE_MODULES/re2/build -type f ! -path "*/Release/re2.node" -delete
45 strip -x $NODE_MODULES/re2/build/Release/re2.node
46
47 # Remove files that depend on python3
48 #
49 # The node-gyp package is only used for building re2, so it is
50 # not needed at runtime. I did not remove the whole directory
51 # because of some dangling links to the node-gyp directory which
52 # is not required. It is possible to remove the directory and all
53 # the files that link to it, but I figured it was not worth
54 # tracking down the files.
55 #
56 # The re2/vendor directory is used for building the re2.node
57 # binary, so it is not needed at runtime.
58 rm -rf $NODE_MODULES/{node-gyp/gyp,re2/vendor}
59
60 wrapProgram $out/bin/gitlab-ci-local \
61 --prefix PATH : "${
62 lib.makeBinPath [
63 rsync
64 gitMinimal
65 ]
66 }"
67 '';
68
69 passthru = {
70 updateScript = nix-update-script { };
71 tests.version = testers.testVersion {
72 package = gitlab-ci-local;
73 };
74 };
75
76 meta = with lib; {
77 description = "Run gitlab pipelines locally as shell executor or docker executor";
78 mainProgram = "gitlab-ci-local";
79 longDescription = ''
80 Tired of pushing to test your .gitlab-ci.yml?
81 Run gitlab pipelines locally as shell executor or docker executor.
82 Get rid of all those dev specific shell scripts and make files.
83 '';
84 homepage = "https://github.com/firecow/gitlab-ci-local";
85 license = licenses.mit;
86 maintainers = with maintainers; [ pineapplehunter ];
87 platforms = platforms.all;
88 };
89}