-
Notifications
You must be signed in to change notification settings - Fork 6
/
flake.nix
79 lines (79 loc) · 2.5 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
{
description = "Plutarch 2.0";
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 = hLib: hsPkgs: hsPkgs.override {
overrides = final: prev: {
plutarch-core = final.callPackage ./plutarch-core.nix { };
};
};
hsPkgsFor = system: with pkgsFor system; hsOverlay haskell.lib haskellPackages;
formattersFor = system: with (pkgsFor system); [
# nixpkgs-fmt
# haskellPackages.cabal-fmt
# haskellPackages.haskell-language-server
# haskellPackages.fourmolu
];
regen = system: (pkgsFor system).writeShellApplication {
name = "regen";
runtimeInputs = [ (pkgsFor system).cabal2nix ] ++ formattersFor system;
text = ''
set -xe
cabal2nix ./. > plutarch-core.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 ./.) plutarch-core.nix
touch $out
'';
});
apps = perSystem (system: {
regen.type = "app";
regen.program = "${regen system}/bin/regen";
});
packages = perSystem (system: {
default = (hsPkgsFor system).plutarch-core;
});
devShells = perSystem (system: {
default = (hsPkgsFor system).shellFor {
packages = p: [ p.plutarch-core ];
buildHoogle = true;
nativeBuildInputs = with (pkgsFor system); [
cabal-install
# hlint
cabal2nix
curl
] ++ formattersFor system;
};
});
hydraJobs = {
checks = { inherit (self.checks) x86_64-linux; };
packages = { inherit (self.packages) x86_64-linux; };
devShells = { inherit (self.devShells) x86_64-linux; };
apps.x86_64-linux.regen = regen "x86_64-linux";
};
herculesCI.ciSystems = [ "x86_64-linux" ];
};
}