-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
94 lines (90 loc) · 2.74 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
{
description = "Collie-the-bot";
inputs = {
haskellNix.url = "github:input-output-hk/haskell.nix";
nixpkgs.follows = "haskellNix/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
nixpak = {
url = "github:max-privatevoid/nixpak";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = inputs@{ nixpkgs, flake-utils, haskellNix, pre-commit-hooks, ... }:
flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" ] (system:
let
overlays = [ haskellNix.overlay ];
pkgs = import nixpkgs {
inherit system overlays;
inherit (haskellNix) config;
};
mkNixPak = inputs.nixpak.lib.nixpak {
inherit (pkgs) lib;
inherit pkgs;
};
sandboxed-ghci = mkNixPak {
config = _: {
app.package =
(pkgs.ghc.withPackages (gPkgs: with gPkgs; [
aeson
template-haskell
QuickCheck
tagsoup
http-conduit
megaparsec
containers
optics
]));
app.binPath = "bin/ghci";
dbus.enable = false;
};
};
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
settings = {
ormolu.defaultExtensions = [
"TypeApplications"
"PatternSynonyms"
];
};
hooks = {
nixpkgs-fmt.enable = true;
cabal-fmt.enable = true;
fourmolu.enable = true;
hlint.enable = true;
statix.enable = true;
deadnix.enable = true;
};
};
project = pkgs.haskell-nix.project' {
inherit (pre-commit-check.shellHook);
src = ./.;
compiler-nix-name = "ghc964";
shell = {
tools = {
cabal = { };
hlint = { };
haskell-language-server = { };
};
nativeBuildInputs = with pkgs; [
nixpkgs-fmt
fd
git
gnumake
];
};
};
flake = project.flake { };
in
flake // rec {
inherit project;
checks = flake.checks // { formatting-checks = pre-commit-check; };
packages.ghci = sandboxed-ghci.config.script;
packages.collie-the-bot = flake.packages."collie-the-bot:exe:collie-the-bot";
packages.runBot =
pkgs.writeShellScript "RunCollie" ''
export COLLIE_GHCI_PATH=${packages.ghci}/bin/ghci
${packages.collie-the-bot}/bin/collie-the-bot
'';
});
}