forked from fizruk/telegram-bot-simple
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
72 lines (61 loc) · 2.18 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
{
inputs = {
flake-utils.url = "github:numtide/flake-utils/cfacdce06f30d2b68473a46042957675eebb3401";
nixpkgs.url = "github:NixOS/nixpkgs/1fb781f4a148c19e9da1d35a4cbe15d0158afc4e";
};
outputs = inputs: inputs.flake-utils.lib.eachDefaultSystem (system:
let
pkgs = inputs.nixpkgs.legacyPackages.${system};
telegram-bot-api = "telegram-bot-api";
telegram-bot-simple = "telegram-bot-simple";
systemDepends = [ pkgs.zlib ];
overridePkg = self: name: localDeps: {
"${name}" = pkgs.haskell.lib.overrideCabal
(self.callCabal2nix name ./${name} (__foldl' (x: y: x // { "${y}" = self.${y}; }) { } localDeps))
(x: { librarySystemDepends = systemDepends ++ (x.librarySystemDepends or [ ]); });
};
override = {
overrides = self: super:
(overridePkg self telegram-bot-api [ ]) //
(overridePkg self telegram-bot-simple [ telegram-bot-api ]);
};
ghcVersion = "ghc927";
hpkgs = pkgs.haskell.packages.${ghcVersion};
getHaskellPackagesDeps = packages_:
with pkgs.lib.lists; pkgs.lib.lists.unique (
subtractLists packages_ (
concatLists (map
(package:
__filter pkgs.lib.attrsets.isDerivation (concatLists (
__attrValues package.getCabalDeps
)))
packages_)
)
);
ghcForPackages = hpkgs_: override_: packageNames_:
(hpkgs_.override override_).ghcWithPackages (ps:
getHaskellPackagesDeps (map (x: ps.${x}) packageNames_)
);
ghc = ghcForPackages hpkgs override [ telegram-bot-api telegram-bot-simple ];
tools = [
pkgs.cabal-install
# ghc should go before haskell-language-server - https://github.com/NixOS/nixpkgs/issues/225895
ghc
hpkgs.haskell-language-server
pkgs.dhall-lsp-server
];
devShells.default = pkgs.mkShell {
buildInputs = tools;
LANG = "C.utf8";
shellHook = ''
cat <<EOF > cabal.project.local
ignore-project: False
flags: +examples
EOF
'';
};
in
{
inherit devShells;
});
}