-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathflake.nix
96 lines (88 loc) · 2.92 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
{
description = "Cofree.Coffee Matrix Bot";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/24.05";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
{
self,
nixpkgs,
flake-utils,
}:
let
ghcVersion = "982";
compiler = "ghc${ghcVersion}";
in
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs { inherit system; };
# need to do the evalPkgs trick so that IFD works with `nix flake check`
# https://github.com/NixOS/nix/issues/4265
evalPkgs = import nixpkgs { system = "x86_64-linux"; };
# Our haskell packages override, needs to use evalPkgs because
# cabal2nix uses IFD
hsPkgs = evalPkgs.haskell.packages.${compiler}.override {
overrides = hfinal: hprev: {
chat-bots = hfinal.callCabal2nix "chat-bots" ./chat-bots/. { };
chat-bots-contrib = hfinal.callCabal2nix "chat-bots" ./chat-bots-contrib/. { };
cofree-bot = hfinal.callCabal2nix "cofree-bot" ./cofree-bot/. { };
list-t = hfinal.callCabal2nix "list-t" ./list-t/. { };
monoidal-functors = hfinal.callCabal2nix "monoidal-functors" (pkgs.fetchFromGitHub {
owner = "solomon-b";
repo = "monoidal-functors";
rev = "eeb61da953592b7c01ab319b14f961e8f04c82c0";
sha256 = "sha256-XnSffGuRTzr5LCrxu8x7AU3hmNk314Ip2ky2Z9xRJI0=";
}) { };
};
};
scripts = import ./nix/scripts.nix {
s = pkgs.writeShellScriptBin;
ormolu = pkgs.ormolu;
};
in
rec {
# Note: cannot reference anything that depends on `evalPkgs` like `hsPkgs`
# otherwise non-x86_64-linux users will not be able to build the dev env
devShells = {
default = hsPkgs.shellFor {
packages = p: [
p.chat-bots
p.chat-bots-contrib
p.cofree-bot
p.monoidal-functors
p.list-t
];
buildInputs =
with pkgs;
[
cabal2nix
cabal-install
ghcid
haskell.compiler.${compiler}
haskell.packages.${compiler}.haskell-language-server
just
pkg-config
ormolu
shellcheck
zlib
zlib.dev
]
++ (builtins.attrValues scripts);
};
};
packages = flake-utils.lib.flattenTree {
docker = import ./nix/docker.nix {
inherit pkgs;
cofree-bot = hsPkgs.cofree-bot;
};
chat-bots = hsPkgs.chat-bots;
chat-bots-contrib = hsPkgs.chat-bots-contrib;
cofree-bot = hsPkgs.cofree-bot;
default = hsPkgs.cofree-bot;
};
formatter = pkgs.nixfmt-rfc-style;
}
);
}