Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ stdenv
2, lib
3, fetchFromGitHub
4, fetchpatch
5, ocamlPackages
6, pkg-config
7, autoreconfHook
8}:
9
10stdenv.mkDerivation rec {
11 pname = "coccinelle";
12 version = "1.1.1";
13
14 src = fetchFromGitHub {
15 repo = pname;
16 rev = version;
17 owner = "coccinelle";
18 hash = "sha256-rS9Ktp/YcXF0xUtT4XZtH5F9huvde0vRztY7vGtyuqY=";
19 };
20
21 patches = [
22 # Fix data path lookup.
23 # https://github.com/coccinelle/coccinelle/pull/270
24 (fetchpatch {
25 url = "https://github.com/coccinelle/coccinelle/commit/540888ff426e0b1f7907b63ce26e712d1fc172cc.patch";
26 sha256 = "sha256-W8RNIWDAC3lQ5bG+gD50r7x919JIcZRpt3QSOSMWpW4=";
27 })
28
29 # Fix attaching code before declarations.
30 # https://github.com/coccinelle/coccinelle/issues/282
31 (fetchpatch {
32 url = "https://github.com/coccinelle/coccinelle/commit/cd33db143416d820f547bf5869482cfcfc0ea9d0.patch";
33 sha256 = "q7wbxbB9Ob0fSJwCjRtDPO3Xg4RO9yrQZG9G0/LGunI=";
34 })
35
36 # Fix attaching declaration metavariables.
37 # https://github.com/coccinelle/coccinelle/issues/281
38 (fetchpatch {
39 url = "https://github.com/coccinelle/coccinelle/commit/df71c5c0fe2a73c7358f73f45a550b57a7e30d85.patch";
40 sha256 = "qrYfligJnXP7J5G/hfzyaKg9aFn74VExtc/Rs/DI2gc=";
41 })
42
43 # Support GLib’s autocleanup macros.
44 # https://github.com/coccinelle/coccinelle/issues/275
45 (fetchpatch {
46 url = "https://github.com/coccinelle/coccinelle/commit/6d5602aca8775c3c5c503939c3dcf0637649d09b.patch";
47 sha256 = "NACf8joOOvN32H/sIfI+oqiT3289zXXQVVfXbRfbIe8=";
48 })
49
50 # Exit with non-zero status on failure.
51 (fetchpatch {
52 url = "https://github.com/coccinelle/coccinelle/commit/6c0a855af14d41864e1e522b93dc39646a3b83c7.patch";
53 sha256 = "6yfK8arB0GDW7o4cXsv0Y9TMvqgGf3/P1ebXrFFUC80=";
54 })
55 (fetchpatch {
56 url = "https://github.com/coccinelle/coccinelle/commit/5448bb2bd03491ffec356bf7bd6ddcdbf4d36bc9.patch";
57 sha256 = "fyyxw2BNZUpyLBieIhOKeWbLFGP1tjULH70w/hU+jKw=";
58 })
59 (fetchpatch {
60 url = "https://github.com/coccinelle/coccinelle/commit/b8b1937657765e991195a10fcd7b8f7a300fc60b.patch";
61 sha256 = "ergWJF6BKrhmJhx1aiVYDHztgjaQvaJ5iZRAmC9i22s=";
62 })
63 ];
64
65 nativeBuildInputs = with ocamlPackages; [
66 autoreconfHook
67 pkg-config
68 ocaml
69 findlib
70 menhir
71 ];
72
73 buildInputs = with ocamlPackages; [
74 ocaml_pcre
75 parmap
76 pyml
77 stdcompat
78 ];
79
80 strictDeps = true;
81
82 postPatch = ''
83 # Ensure dependencies from Nixpkgs are picked up.
84 rm -rf bundles/
85 '';
86
87 meta = {
88 description = "Program to apply semantic patches to C code";
89 longDescription = ''
90 Coccinelle is a program matching and transformation engine which
91 provides the language SmPL (Semantic Patch Language) for
92 specifying desired matches and transformations in C code.
93 Coccinelle was initially targeted towards performing collateral
94 evolutions in Linux. Such evolutions comprise the changes that
95 are needed in client code in response to evolutions in library
96 APIs, and may include modifications such as renaming a function,
97 adding a function argument whose value is somehow
98 context-dependent, and reorganizing a data structure. Beyond
99 collateral evolutions, Coccinelle is successfully used (by us
100 and others) for finding and fixing bugs in systems code.
101 '';
102
103 homepage = "https://coccinelle.gitlabpages.inria.fr/website/";
104 license = lib.licenses.gpl2Only;
105 platforms = lib.platforms.unix;
106 maintainers = [ lib.maintainers.thoughtpolice ];
107 };
108}