|
21 | 21 | url = "github:cachix/pre-commit-hooks.nix";
|
22 | 22 | inputs = {
|
23 | 23 | nixpkgs.follows = "nixpkgs";
|
24 |
| - flake-utils.follows = "flake-utils"; |
25 | 24 | };
|
26 | 25 | };
|
27 | 26 | jupyenv = {
|
|
68 | 67 | "^.*\.md"
|
69 | 68 | ];
|
70 | 69 |
|
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 { |
73 | 85 | name = "monad-bayes";
|
74 | 86 | root = src;
|
75 | 87 | cabal2nixOptions = "--benchmark -fdev";
|
|
90 | 102 | microstache = doJailbreak super.microstache;
|
91 | 103 | };
|
92 | 104 | };
|
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; |
106 | 105 |
|
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; |
108 | 109 |
|
109 | 110 | monad-bayes-all-ghcs = pkgs.linkFarm "monad-bayes-all-ghcs" monad-bayes-per-ghc;
|
110 | 111 |
|
|
114 | 115 | ];
|
115 | 116 | };
|
116 | 117 |
|
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 |
| - }; |
128 | 118 | pre-commit = pre-commit-hooks.lib.${system}.run {
|
129 | 119 | inherit src;
|
130 | 120 | hooks = {
|
|
134 | 124 | ormolu.enable = true;
|
135 | 125 | };
|
136 | 126 | };
|
| 127 | + devShellFor = ghcVersion: haskellPackages: addJupyter: haskellPackages.shellFor { |
| 128 | + packages = hps: [ |
| 129 | + (monad-bayes-for haskellPackages) |
| 130 | + ]; |
| 131 | + nativeBuildInputs = with pre-commit-hooks.packages.${system}; [ |
| 132 | + alejandra |
| 133 | + cabal-fmt |
| 134 | + hlint |
| 135 | + ormolu |
| 136 | + ] ++ lib.optional addJupyter jupyterEnvironment |
| 137 | + ++ (with haskellPackages; [ |
| 138 | + haskell-language-server |
| 139 | + ]); |
| 140 | + }; |
137 | 141 | in rec {
|
138 | 142 | packages = {
|
139 | 143 | inherit monad-bayes monad-bayes-per-ghc monad-bayes-all-ghcs pre-commit jupyterEnvironment;
|
140 | 144 | };
|
141 | 145 | packages.default = packages.monad-bayes;
|
142 | 146 | checks = {inherit monad-bayes pre-commit;};
|
143 |
| - devShells.default = monad-bayes-dev; |
| 147 | + devShells = lib.concatMapAttrs (ghcVersion: haskellPackages: { |
| 148 | + "${ghcVersion}" = devShellFor ghcVersion haskellPackages false; |
| 149 | + "${ghcVersion}-jupyter" = devShellFor ghcVersion haskellPackages true; |
| 150 | + }) allHaskellPackages; |
144 | 151 | # Needed for backwards compatibility with Nix versions <2.8
|
145 | 152 | defaultPackage = warnToUpdateNix packages.default;
|
146 | 153 | devShell = warnToUpdateNix devShells.default;
|
|
0 commit comments