summary refs log tree commit diff
path: root/pkgs/applications/science/logic/why3/with-provers.nix
blob: d4fdbfd6937c30b57add83fac92ea249c144c128 (plain) (blame)
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
{ stdenv, makeWrapper, runCommand, symlinkJoin, why3 }:
provers:
let configAwkScript = runCommand "why3-conf.awk" { inherit provers; }
    ''
      for p in $provers; do
        for b in $p/bin/*; do
          BASENAME=$(basename $b)
          echo "/^command =/{ gsub(\"$BASENAME\", \"$b\") }" >> $out
        done
      done
      echo '{ print }' >> $out
    '';
in stdenv.mkDerivation {
  name = "${why3.name}-with-provers";

  phases = [ "buildPhase" "installPhase" ];

  nativeBuildInputs = [ makeWrapper ];
  buildInputs = [ why3 ] ++ provers;

  buildPhase = ''
      mkdir -p $out/share/why3/
      why3 config --detect-provers -C $out/share/why3/why3.conf
      awk -i inplace -f ${configAwkScript} $out/share/why3/why3.conf
  '';

  installPhase = ''
      mkdir -p $out/bin
      makeWrapper ${why3}/bin/why3 $out/bin/why3 --add-flags "--extra-config $out/share/why3/why3.conf"
  '';
}