-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
128 lines (117 loc) · 3.45 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
{
description = "A brainfuck interpreter";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
nix-filter.url = "github:numtide/nix-filter";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{ self
, nixpkgs
, flake-utils
, nix-filter
, pre-commit-hooks
, ...
}:
let
pkgsFor = system: import nixpkgs {
inherit system;
overlays = [ self.overlays.default ];
};
filteredSrc = nix-filter.lib {
root = ./.;
include = [
"src/"
"package.yaml"
"LICENSE"
"benchmark/"
"brainfucks/"
];
};
in
{
overlays.default = final: prev:
with final.haskell.lib;
{
haskellPackages = prev.haskellPackages.override (old: {
overrides = final.lib.composeExtensions
(old.overrides or (_: _: { }))
(self: super: {
sydtest = unmarkBroken (dontCheck super.sydtest);
brainhask = self.generateOptparseApplicativeCompletions
[ "brainhask" ]
(self.callCabal2nix "brainhask" filteredSrc { });
}
);
});
}
;
} //
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = pkgsFor system;
precommitCheck = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
actionlint.enable = true;
hlint.enable = true;
hpack.enable = true;
markdownlint.enable = true;
nil.enable = true;
nixpkgs-fmt.enable = true;
ormolu.enable = true;
statix.enable = true;
};
};
in
rec {
packages.brainhask = pkgs.haskellPackages.brainhask;
packages.brainhask-bench-results = pkgs.stdenv.mkDerivation {
name = "brainhask-bench-results";
src = filteredSrc;
buildPhase = "${apps.brainhask-bench.program} --output benchmark-results.html";
installPhase = ''
mkdir -p $out
mv benchmark-results.html $out/
'';
};
packages.default = packages.brainhask;
apps.brainhask = flake-utils.lib.mkApp {
drv = pkgs.haskell.lib.justStaticExecutables (
packages.brainhask.overrideAttrs (oldAttrs: {
configureFlags = oldAttrs.configureFlags ++ [ "--ghc-option=-O2" ];
})
);
};
apps.brainhask-bench = flake-utils.lib.mkApp {
name = "brainhask-bench";
drv = pkgs.haskell.lib.justStaticExecutables (
packages.brainhask.overrideAttrs (oldAttrs: {
configureFlags = oldAttrs.configureFlags ++ [ "--ghc-option=-O2" ];
})
);
};
apps.default = apps.brainhask;
devShells.default = pkgs.haskellPackages.shellFor {
packages = p: [ packages.brainhask ];
buildInputs = with pkgs; with pkgs.haskellPackages; [
actionlint
cabal-install
ghcid
haskell-language-server
hlint
nil
nixpkgs-fmt
ormolu
statix
];
inherit (precommitCheck) shellHook;
};
});
nixConfig = {
extra-substituters = "https://opensource.cachix.org";
extra-trusted-public-keys = "opensource.cachix.org-1:6t9YnrHI+t4lUilDKP2sNvmFA9LCKdShfrtwPqj2vKc=";
};
}