Skip to content

Commit f9e4f96

Browse files
committed
Improve flake setup
1 parent 1cd49cd commit f9e4f96

File tree

3 files changed

+34
-31
lines changed

3 files changed

+34
-31
lines changed

.github/workflows/nix.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
needs: lint
4646
strategy:
4747
matrix:
48-
ghc: ["ghc902", "ghc927", "ghc945", "ghc964", "ghc982", "ghc9101"]
48+
ghc: ["ghc90", "ghc92", "ghc94", "ghc96", "ghc98", "ghc910"]
4949
include:
5050
- os: ubuntu-latest
5151
system: x86_64-linux

flake.nix

Lines changed: 32 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
url = "github:cachix/pre-commit-hooks.nix";
2222
inputs = {
2323
nixpkgs.follows = "nixpkgs";
24-
flake-utils.follows = "flake-utils";
2524
};
2625
};
2726
jupyenv = {
@@ -68,8 +67,21 @@
6867
"^.*\.md"
6968
];
7069

71-
monad-bayes-per-ghc = let
72-
opts = {
70+
# Always keep this up to date with the tested-with section in monad-bayes.cabal!
71+
# and the build-all-ghcs job in .github/workflows/nix.yml!
72+
ghcs = [
73+
"ghc90"
74+
"ghc92"
75+
"ghc94"
76+
"ghc96"
77+
"ghc98"
78+
"ghc910"
79+
"default"
80+
];
81+
82+
allHaskellPackages = lib.filterAttrs (ghcVersion: _: builtins.elem ghcVersion ghcs) (pkgs.haskell.packages // {default = pkgs.haskellPackages;});
83+
84+
monad-bayes-for = haskellPackages: haskellPackages.developPackage {
7385
name = "monad-bayes";
7486
root = src;
7587
cabal2nixOptions = "--benchmark -fdev";
@@ -90,21 +102,10 @@
90102
microstache = doJailbreak super.microstache;
91103
};
92104
};
93-
ghcs = [
94-
# Always keep this up to date with the tested-with section in monad-bayes.cabal,
95-
# and the build-all-ghcs job in .github/workflows/nix.yml!
96-
"ghc902"
97-
"ghc927"
98-
"ghc945"
99-
"ghc964"
100-
"ghc982"
101-
"ghc9101"
102-
];
103-
buildForVersion = ghcVersion: (builtins.getAttr ghcVersion pkgs.haskell.packages).developPackage opts;
104-
in
105-
lib.attrsets.genAttrs ghcs buildForVersion;
106105

107-
monad-bayes = monad-bayes-per-ghc.ghc902;
106+
monad-bayes-per-ghc = lib.mapAttrs (_: monad-bayes-for) allHaskellPackages;
107+
108+
monad-bayes = monad-bayes-per-ghc.default;
108109

109110
monad-bayes-all-ghcs = pkgs.linkFarm "monad-bayes-all-ghcs" monad-bayes-per-ghc;
110111

@@ -114,17 +115,6 @@
114115
];
115116
};
116117

117-
monad-bayes-dev = pkgs.mkShell {
118-
inputsFrom = [monad-bayes.env];
119-
packages = with pre-commit-hooks.packages.${system}; [
120-
alejandra
121-
cabal-fmt
122-
hlint
123-
ormolu
124-
jupyterEnvironment
125-
];
126-
shellHook = pre-commit.shellHook;
127-
};
128118
pre-commit = pre-commit-hooks.lib.${system}.run {
129119
inherit src;
130120
hooks = {
@@ -140,7 +130,20 @@
140130
};
141131
packages.default = packages.monad-bayes;
142132
checks = {inherit monad-bayes pre-commit;};
143-
devShells.default = monad-bayes-dev;
133+
devShells = builtins.mapAttrs (_ghcVersion: haskellPackages: haskellPackages.shellFor {
134+
packages = hps: [
135+
(monad-bayes-for haskellPackages)
136+
];
137+
nativeBuildInputs = with pre-commit-hooks.packages.${system}; [
138+
alejandra
139+
cabal-fmt
140+
hlint
141+
ormolu
142+
# jupyterEnvironment # FIXME: Builds monad-bayes
143+
] ++ (with haskellPackages; [
144+
haskell-language-server
145+
]);
146+
}) allHaskellPackages;
144147
# Needed for backwards compatibility with Nix versions <2.8
145148
defaultPackage = warnToUpdateNix packages.default;
146149
devShell = warnToUpdateNix devShells.default;

monad-bayes.cabal

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ maintainer: [email protected]
88
author: Adam Scibior <[email protected]>
99
stability: experimental
1010
tested-with:
11-
GHC ==9.0.2 || ==9.2.7 || ==9.4.5 || ==9.6.4 || ==9.8.2 || ==9.10.1
11+
GHC ==9.0 || ==9.2 || ==9.4 || ==9.6 || ==9.8 || ==9.10
1212

1313
homepage: http://github.com/tweag/monad-bayes#readme
1414
bug-reports: https://github.com/tweag/monad-bayes/issues

0 commit comments

Comments
 (0)