-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathflake.nix
78 lines (66 loc) · 2.46 KB
/
flake.nix
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
opam-nix.url = "github:tweag/opam-nix";
opam-nix.inputs.nixpkgs.follows = "nixpkgs";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" ];
imports = [
.nix/with-nixpkgs.nix
.nix/with-opam-nix.nix
inputs.pre-commit-hooks.flakeModule
];
perSystem = { self', pkgs, config, ... }: {
formatter = pkgs.nixfmt;
packages.default = self'.packages.with-nixpkgs;
devShells.default = pkgs.mkShell {
buildInputs = with pkgs.ocamlPackages; [
ocaml-lsp
ocp-indent
headache
];
inputsFrom = [ self'.packages.default ];
shellHook = config.pre-commit.installationScript;
};
pre-commit.settings.hooks = {
dune-opam-sync.enable = true;
opam-lint.enable = true;
ocp-indent.enable = true;
nixfmt.enable = true;
deadnix.enable = true;
## NOTE: The version of the `dune-fmt` hook in `pre-commit-hooks.nix`
## forgets to bring OCaml in the environment. In the meantime, we use
## our own; will change back to `dune-fmt.enable = true` later.
tmp-dune-fmt = {
enable = true;
name = "dune-fmt";
description = "Runs Dune's formatters on the code tree.";
entry = let
dune-fmt = pkgs.writeShellApplication {
name = "dune-fmt";
text = ''
export PATH=${pkgs.ocaml}/bin:$PATH
exec ${pkgs.dune_3}/bin/dune fmt "$@"
'';
};
in "${dune-fmt}/bin/dune-fmt";
pass_filenames = false;
};
};
};
## Improve the way `inputs'` are computed by also handling the case of
## flakes having a `lib.${system}` attribute (eg. `opam-nix`).
perInput = system: flake:
if flake ? lib.${system} then { lib = flake.lib.${system}; } else { };
};
nixConfig = {
extra-trusted-substituters = [ "https://morbig.cachix.org/" ];
extra-trusted-public-keys =
[ "morbig.cachix.org-1:l6jrpCfkt03SwhxnK7VNDgrnMDW9OA92BTcuZTNw60I=" ];
};
}