summaryrefslogtreecommitdiff
path: root/modules/why3.nix
blob: 3a09c12ed9c1e63edd2d563d659bdaf467606d15 (plain)
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
{ pkgs, lib, ... }:

with lib;
let
  cfg = config.why3;
  proverSubmodule = types.submodule {
    options = {
      name = mkOption {
        type = types.nullOr types.str;
        default = null;
        description = ''
          The name of the prover.
        '';
      };
      package = mkOption {
        type = types.package;
        description = ''
          The package providing the prover.
        '';
      };
    };
  };
  why3BuildInputs = [ cfg.package ] ++ cfg.provers.detect
    ++ (mapAttrsToList (_: prover: prover.package) cfg.provers.manual);
in {
  options.why3 = {
    enable = mkEnableOption "why3";
    package = mkOption {
      type = types.package;
      default = pkgs.why3;
      defaultText = literalExample "pkgs.why3";
      description = ''
        The package for why3. This sets the version of Why3.
      '';
    };
    provers = {
      detect = mkOption {
        type = types.listOf types.package;
        default = [ ];
        description = ''
          Provers to use that are known to be supported by Why3.
        '';
        example = literalExample "with pkgs; [ z3 ccv4 ]";
      };
      manual = mkOption {
        type = types.attrsOf proverSubmodule;
        default = { };
        description = ''
          Provers to use that are not known to be supported by Why3.
        '';
        example = literalExample ''
          {
            myProver = {
              package = pkgs.my-prover;
            };
          }
        '';
      };
    };
  };

  config.why3 = mkIf cfg.enable { buildInputs = why3BuildInputs; };
}