-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
80 lines (80 loc) · 2.41 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
79
80
{
description = "procex";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
};
outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "aarch64-linux" ];
perSystem = nixpkgs.lib.genAttrs supportedSystems;
pkgsFor = system: nixpkgs.legacyPackages.${system};
hsOverlay = hsPkgs: hsPkgs.override {
overrides = final: prev: {
procex = final.callPackage ./procex.nix { hspec = final.hspec_2_10_0_1; };
};
};
hsPkgsFor = system: hsOverlay (pkgsFor system).haskell.packages.ghc924;
formattersFor = system: with (pkgsFor system); [
nixpkgs-fmt
haskellPackages.cabal-fmt
(haskell.lib.compose.overrideCabal (_: { doCheck = false; }) (hsPkgsFor system).fourmolu_0_8_0_0)
];
regen = system: (pkgsFor system).writeShellApplication {
name = "regen";
runtimeInputs = [ (pkgsFor system).cabal2nix ] ++ formattersFor system;
text = ''
set -xe
cabal2nix ./. > procex.nix
./bin/format
'';
};
in
{
checks = perSystem (system: {
formatting = (pkgsFor system).runCommandNoCC "formatting-check"
{
nativeBuildInputs = formattersFor system;
} ''
cd ${self}
./bin/format check
touch $out
'';
cabal2nix = (pkgsFor system).runCommandNoCC "cabal2nix-check"
{
nativeBuildInputs = [ (pkgsFor system).cabal2nix ];
} ''
cd ${self}
diff <(cabal2nix ./.) procex.nix
touch $out
'';
});
apps = perSystem (system: {
regen.type = "app";
regen.program = "${regen system}/bin/regen";
});
packages = perSystem (system: {
default = (hsPkgsFor system).procex;
});
devShells = perSystem (system: {
default = (hsPkgsFor system).shellFor {
packages = p: [ p.procex ];
buildHoogle = true;
nativeBuildInputs = with (pkgsFor system); [
cabal-install
hlint
cabal2nix
curl
] ++ formattersFor system;
};
raw = with (pkgsFor system); mkShell {
nativeBuildInputs = [
cabal-install
hlint
cabal2nix
curl
haskell.compiler.ghc941
] ++ formattersFor system;
};
});
};
}