|
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 = { |
|
32 | 31 | }; |
33 | 32 | }; |
34 | 33 | }; |
35 | | - outputs = { |
36 | | - self, |
37 | | - nixpkgs, |
38 | | - jupyenv, |
39 | | - flake-compat, |
40 | | - flake-utils, |
41 | | - pre-commit-hooks, |
42 | | - } @ inputs: |
| 34 | + outputs = |
| 35 | + { self |
| 36 | + , nixpkgs |
| 37 | + , jupyenv |
| 38 | + , flake-compat |
| 39 | + , flake-utils |
| 40 | + , pre-commit-hooks |
| 41 | + , |
| 42 | + } @ inputs: |
43 | 43 | flake-utils.lib.eachSystem |
44 | | - [ |
45 | | - # Tier 1 - Tested in CI |
46 | | - flake-utils.lib.system.x86_64-linux |
47 | | - flake-utils.lib.system.x86_64-darwin |
48 | | - # Tier 2 - Not tested in CI (at least for now) |
49 | | - flake-utils.lib.system.aarch64-linux |
50 | | - flake-utils.lib.system.aarch64-darwin |
51 | | - ] |
52 | | - ( |
53 | | - system: let |
54 | | - inherit (nixpkgs) lib; |
55 | | - inherit (jupyenv.lib.${system}) mkJupyterlabNew; |
56 | | - pkgs = import nixpkgs { |
57 | | - inherit system; |
58 | | - config.allowBroken = true; |
59 | | - }; |
| 44 | + [ |
| 45 | + # Tier 1 - Tested in CI |
| 46 | + flake-utils.lib.system.x86_64-linux |
| 47 | + flake-utils.lib.system.x86_64-darwin |
| 48 | + # Tier 2 - Not tested in CI (at least for now) |
| 49 | + flake-utils.lib.system.aarch64-linux |
| 50 | + flake-utils.lib.system.aarch64-darwin |
| 51 | + ] |
| 52 | + ( |
| 53 | + system: |
| 54 | + let |
| 55 | + inherit (nixpkgs) lib; |
| 56 | + inherit (jupyenv.lib.${system}) mkJupyterlabNew; |
| 57 | + pkgs = import nixpkgs { |
| 58 | + inherit system; |
| 59 | + config.allowBroken = true; |
| 60 | + }; |
60 | 61 |
|
61 | | - warnToUpdateNix = pkgs.lib.warn "Consider updating to Nix > 2.7 to remove this warning!"; |
62 | | - src = lib.sourceByRegex self [ |
63 | | - "^benchmark.*$" |
64 | | - "^models.*$" |
65 | | - "^monad-bayes\.cabal$" |
66 | | - "^src.*$" |
67 | | - "^test.*$" |
68 | | - "^.*\.md" |
69 | | - ]; |
| 62 | + warnToUpdateNix = pkgs.lib.warn "Consider updating to Nix > 2.7 to remove this warning!"; |
| 63 | + src = lib.sourceByRegex self [ |
| 64 | + "^benchmark.*$" |
| 65 | + "^models.*$" |
| 66 | + "^monad-bayes\.cabal$" |
| 67 | + "^src.*$" |
| 68 | + "^test.*$" |
| 69 | + "^.*\.md" |
| 70 | + ]; |
70 | 71 |
|
71 | | - monad-bayes-per-ghc = let |
72 | | - opts = { |
| 72 | + # Always keep this up to date with the tested-with section in monad-bayes.cabal! |
| 73 | + # and the build-all-ghcs job in .github/workflows/nix.yml! |
| 74 | + ghcs = [ |
| 75 | + "ghc90" |
| 76 | + "ghc92" |
| 77 | + "ghc94" |
| 78 | + "ghc96" |
| 79 | + "ghc98" |
| 80 | + "ghc910" |
| 81 | + "default" |
| 82 | + ]; |
| 83 | + |
| 84 | + allHaskellPackages = lib.filterAttrs (ghcVersion: _: builtins.elem ghcVersion ghcs) (pkgs.haskell.packages // { default = pkgs.haskellPackages; }); |
| 85 | + |
| 86 | + monad-bayes-for = haskellPackages: haskellPackages.developPackage { |
73 | 87 | name = "monad-bayes"; |
74 | 88 | root = src; |
75 | 89 | cabal2nixOptions = "--benchmark -fdev"; |
|
81 | 95 | else pkgs.haskell.lib.dontCheck drv; |
82 | 96 | overrides = self: super: |
83 | 97 | with pkgs.haskell.lib; |
84 | | - { |
85 | | - # Please check after flake.lock updates whether some of these overrides can be removed |
86 | | - brick = super.brick_2_4; |
87 | | - } |
88 | | - // lib.optionalAttrs (lib.versionAtLeast super.ghc.version "9.10") { |
89 | | - # Please check after flake.lock updates whether some of these overrides can be removed |
90 | | - microstache = doJailbreak super.microstache; |
91 | | - }; |
| 98 | + { |
| 99 | + # Please check after flake.lock updates whether some of these overrides can be removed |
| 100 | + brick = super.brick_2_4; |
| 101 | + } |
| 102 | + // lib.optionalAttrs (lib.versionAtLeast super.ghc.version "9.10") { |
| 103 | + # Please check after flake.lock updates whether some of these overrides can be removed |
| 104 | + microstache = doJailbreak super.microstache; |
| 105 | + }; |
92 | 106 | }; |
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 | 107 |
|
107 | | - monad-bayes = monad-bayes-per-ghc.ghc902; |
| 108 | + monad-bayes-per-ghc = lib.mapAttrs (_: monad-bayes-for) allHaskellPackages; |
108 | 109 |
|
109 | | - monad-bayes-all-ghcs = pkgs.linkFarm "monad-bayes-all-ghcs" monad-bayes-per-ghc; |
| 110 | + monad-bayes = monad-bayes-per-ghc.default; |
110 | 111 |
|
111 | | - jupyterEnvironment = mkJupyterlabNew { |
112 | | - imports = [ |
113 | | - (import ./kernels/haskell.nix {inherit monad-bayes;}) |
114 | | - ]; |
115 | | - }; |
| 112 | + monad-bayes-all-ghcs = pkgs.linkFarm "monad-bayes-all-ghcs" monad-bayes-per-ghc; |
116 | 113 |
|
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 | | - pre-commit = pre-commit-hooks.lib.${system}.run { |
129 | | - inherit src; |
130 | | - hooks = { |
131 | | - alejandra.enable = true; |
132 | | - cabal-fmt.enable = true; |
133 | | - hlint.enable = false; |
134 | | - ormolu.enable = true; |
| 114 | + jupyterEnvironment = mkJupyterlabNew { |
| 115 | + imports = [ |
| 116 | + (import ./kernels/haskell.nix { inherit monad-bayes; }) |
| 117 | + ]; |
| 118 | + }; |
| 119 | + |
| 120 | + |
| 121 | + pre-commit = pre-commit-hooks.lib.${system}.run { |
| 122 | + inherit src; |
| 123 | + hooks = { |
| 124 | + alejandra.enable = true; |
| 125 | + cabal-fmt.enable = true; |
| 126 | + hlint.enable = false; |
| 127 | + ormolu.enable = true; |
| 128 | + }; |
| 129 | + }; |
| 130 | + devShellFor = ghcVersion: haskellPackages: addJupyter: haskellPackages.shellFor { |
| 131 | + packages = hps: [ |
| 132 | + (monad-bayes-for haskellPackages) |
| 133 | + ]; |
| 134 | + nativeBuildInputs = with pre-commit-hooks.packages.${system}; [ |
| 135 | + alejandra |
| 136 | + cabal-fmt |
| 137 | + hlint |
| 138 | + ormolu |
| 139 | + ] ++ lib.optional addJupyter jupyterEnvironment |
| 140 | + ++ (with haskellPackages; [ |
| 141 | + haskell-language-server |
| 142 | + ]); |
| 143 | + }; |
| 144 | + in |
| 145 | + rec { |
| 146 | + packages = { |
| 147 | + inherit monad-bayes monad-bayes-per-ghc monad-bayes-all-ghcs pre-commit jupyterEnvironment; |
135 | 148 | }; |
136 | | - }; |
137 | | - in rec { |
138 | | - packages = { |
139 | | - inherit monad-bayes monad-bayes-per-ghc monad-bayes-all-ghcs pre-commit jupyterEnvironment; |
140 | | - }; |
141 | | - packages.default = packages.monad-bayes; |
142 | | - checks = {inherit monad-bayes pre-commit;}; |
143 | | - devShells.default = monad-bayes-dev; |
144 | | - # Needed for backwards compatibility with Nix versions <2.8 |
145 | | - defaultPackage = warnToUpdateNix packages.default; |
146 | | - devShell = warnToUpdateNix devShells.default; |
147 | | - } |
148 | | - ); |
| 149 | + packages.default = packages.monad-bayes; |
| 150 | + checks = { inherit monad-bayes pre-commit; }; |
| 151 | + devShells = lib.concatMapAttrs |
| 152 | + (ghcVersion: haskellPackages: { |
| 153 | + "${ghcVersion}" = devShellFor ghcVersion haskellPackages false; |
| 154 | + "${ghcVersion}-jupyter" = devShellFor ghcVersion haskellPackages true; |
| 155 | + }) |
| 156 | + allHaskellPackages; |
| 157 | + # Needed for backwards compatibility with Nix versions <2.8 |
| 158 | + defaultPackage = warnToUpdateNix packages.default; |
| 159 | + devShell = warnToUpdateNix devShells.default; |
| 160 | + formatter = pkgs.nixpkgs-fmt; |
| 161 | + } |
| 162 | + ); |
149 | 163 | } |
0 commit comments