-
Notifications
You must be signed in to change notification settings - Fork 8
/
flake.nix
90 lines (81 loc) · 2.91 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
{
description = "Cofree.Coffee Matrix Bot";
inputs = {
nixpkgs.url = github:NixOS/nixpkgs/nixos-23.11;
flake-utils = {
url = github:numtide/flake-utils;
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, flake-utils }:
let
ghcVersion = "963";
compiler = "ghc${ghcVersion}";
# default systems compatible with pre-commit-hooks.nix
# https://github.com/cachix/pre-commit-hooks.nix/pull/122
defaultSystems = [
"aarch64-linux"
# "aarch64-darwin"
"i686-linux"
"x86_64-darwin"
"x86_64-linux"
];
in
flake-utils.lib.eachSystem defaultSystems (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: {
bifunctors = hfinal.bifunctors_5_6_1;
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/. { };
monoidal-functors = hfinal.callCabal2nix "monoidal-functors"
(pkgs.fetchFromGitHub {
owner = "solomon-b";
repo = "monoidal-functors";
rev = "eeb61da953592b7c01ab319b14f961e8f04c82c0";
sha256 = "sha256-XnSffGuRTzr5LCrxu8x7AU3hmNk314Ip2ky2Z9xRJI0=";
})
{ };
semigroupoids = hfinal.semigroupoids_6_0_0_1;
};
};
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
devShell = pkgs.mkShell {
buildInputs = with pkgs; [
cabal2nix
cabal-install
ghcid
haskell.compiler.${compiler}
haskell.packages.${compiler}.haskell-language-server
nixpkgs-fmt
ormolu
shellcheck
zlib
] ++ (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;
};
defaultPackage = packages.cofree-bot;
});
}