From c42eb9bab15254b3e1084c007e1b1e145675b0eb Mon Sep 17 00:00:00 2001
From: Allan Blanchard <allan.blanchard@cea.fr>
Date: Fri, 28 Oct 2022 09:03:46 +0200
Subject: [PATCH] [nix] add Frama-C lint

---
 nix/frama-c-checkers-shell.nix |  2 ++
 nix/frama-c-lint.nix           | 40 ++++++++++++++++++++++++++++++++++
 nix/ocp-indent.nix             |  3 ++-
 nix/pkgs.nix                   |  1 +
 4 files changed, 45 insertions(+), 1 deletion(-)
 create mode 100644 nix/frama-c-lint.nix

diff --git a/nix/frama-c-checkers-shell.nix b/nix/frama-c-checkers-shell.nix
index de048333505..40a0406a776 100644
--- a/nix/frama-c-checkers-shell.nix
+++ b/nix/frama-c-checkers-shell.nix
@@ -2,6 +2,7 @@
 , stdenv
 , clang_10
 , frama-c-hdrck
+, frama-c-lint
 , git
 , git-lfs
 , gnumake
@@ -13,6 +14,7 @@ stdenv.mkDerivation rec {
   buildInputs = [
     clang_10
     frama-c-hdrck
+    frama-c-lint
     git
     git-lfs
     gnumake
diff --git a/nix/frama-c-lint.nix b/nix/frama-c-lint.nix
new file mode 100644
index 00000000000..d33b2587007
--- /dev/null
+++ b/nix/frama-c-lint.nix
@@ -0,0 +1,40 @@
+{ lib
+, stdenv
+, camomile
+, dune_3
+, findlib
+, gitignoreSource
+, ocaml
+, ocp-indent
+} :
+
+stdenv.mkDerivation rec {
+  pname = "frama-c-lint";
+  version =
+    lib.strings.replaceStrings ["~"] ["-"]
+      (lib.strings.removeSuffix "\n"
+        (builtins.readFile ../VERSION));
+  slang = lib.strings.removeSuffix "\n" (builtins.readFile ../VERSION_CODENAME);
+
+  src = gitignoreSource ./../tools/lint ;
+
+  buildInputs = [
+    camomile
+    dune_3
+    findlib
+    ocaml
+    ocp-indent
+  ];
+
+  configurePhase = ''
+    true
+  '';
+
+  buildPhase = ''
+    dune build --root .
+  '';
+
+  installPhase = ''
+    dune install --prefix $out --root .
+  '';
+}
diff --git a/nix/ocp-indent.nix b/nix/ocp-indent.nix
index 089d6ac9b6d..395c663ae31 100644
--- a/nix/ocp-indent.nix
+++ b/nix/ocp-indent.nix
@@ -1,5 +1,6 @@
 { lib
 , fetchFromGitHub
+, findlib
 , buildDunePackage
 , cmdliner
 }:
@@ -18,7 +19,7 @@ buildDunePackage rec {
   minimumOCamlVersion = "4.02";
   useDune2 = true;
 
-  buildInputs = [ cmdliner ];
+  buildInputs = [ cmdliner findlib ];
 
   meta = with lib; {
     homepage = http://typerex.ocamlpro.com/ocp-indent.html;
diff --git a/nix/pkgs.nix b/nix/pkgs.nix
index 522be707e11..113c31eac7b 100644
--- a/nix/pkgs.nix
+++ b/nix/pkgs.nix
@@ -28,6 +28,7 @@ let
     # Builds
     frama-c = oself.callPackage ./frama-c.nix {};
     frama-c-hdrck = oself.callPackage ./frama-c-hdrck.nix {};
+    frama-c-lint = oself.callPackage ./frama-c-lint.nix {};
     lint = oself.callPackage ./lint.nix {};
 
     # Tests
-- 
GitLab