-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
68 lines (66 loc) · 2.11 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
{
description = "Flake It";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
utils.url = "github:numtide/flake-utils";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
nixpkgs-stable.follows = "nixpkgs";
flake-utils.follows = "utils";
};
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { nixpkgs, utils, treefmt-nix, pre-commit-hooks, ... }:
utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) haskellPackages;
flakeit = pkgs.lib.pipe (haskellPackages.callCabal2nix "flakeit" ./. { }) [
pkgs.haskell.lib.justStaticExecutables
pkgs.haskell.lib.dontCheck
pkgs.haskell.lib.dontHaddock
(haskellPackages.generateOptparseApplicativeCompletions [ "flakeit" ])
];
treefmtEval = treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
nixpkgs-fmt.enable = true;
fourmolu.enable = true;
cabal-fmt.enable = true;
};
};
preCommit = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
treefmt.enable = true;
};
settings.treefmt.package = treefmtEval.config.build.wrapper;
};
in
{
packages = {
default = flakeit;
inherit flakeit;
flakeit-sdist = pkgs.haskell.lib.sdistTarball flakeit;
};
devShells.default =
haskellPackages.shellFor {
packages = p: [ flakeit ];
inherit (preCommit) shellHook;
withHoogle = true;
nativeBuildInputs = [
treefmtEval.config.build.wrapper
haskellPackages.haskell-language-server
haskellPackages.ghcid
haskellPackages.cabal-install
]
++ (pkgs.lib.attrValues treefmtEval.config.build.programs);
};
});
}