|
1 | 1 | This file contains a summary of changes to Haskell.nix and `nix-tools`
|
2 | 2 | that will impact users.
|
3 | 3 |
|
| 4 | +## Sep 16, 2024 |
| 5 | + |
| 6 | +Haskell.nix now uses the more granular Unit IDs from the plan.json |
| 7 | +to identify packages. This allows for different versions of a |
| 8 | +package to be used when building `built-tool-depend` and setup |
| 9 | +dependencies. |
| 10 | + |
| 11 | +Overrides in the `modules` argument apply to all versions of |
| 12 | +the package. However to make this work we needed to make |
| 13 | +each `packages.somepackage` an option (instead of using the |
| 14 | +`attrsOf` option try). |
| 15 | + |
| 16 | +It is now an error to override a package that is not in the |
| 17 | +plan. This can be a problem if you use the same overrides |
| 18 | +for multiple plans (different GHC versions, target platforms, |
| 19 | +or cabal flag settings). If the package does not exist in |
| 20 | +some of the variants you use `package-keys` to tell include |
| 21 | +the option anyway: |
| 22 | + |
| 23 | +``` |
| 24 | + modules = [{ |
| 25 | + # Tell haskell.nix that `somepackage` may exist. |
| 26 | + package-keys = ["somepackage"]; |
| 27 | + packages.somepackage.flags.someflag = true; |
| 28 | + }]; |
| 29 | +``` |
| 30 | + |
| 31 | +There is a helper function you can use to add `package-keys` |
| 32 | +for all of the `builtins.attrNames` of `packages`: |
| 33 | + |
| 34 | +``` |
| 35 | + modules = [(pkgs.haskell-nix.haskellLib.addPackageKeys { |
| 36 | + packages.somepackage.flags.someflag = true; |
| 37 | + })]; |
| 38 | +``` |
| 39 | + |
| 40 | +Do not use the modules `pkgs` arg to look `addPackageKeys` up |
| 41 | +though or it will result an `infinite recursion` error. |
| 42 | + |
| 43 | +Code that uses `options.packages` will also need to be update. |
| 44 | +For instance the following code that uses `options.packages` |
| 45 | +to set `--Werror` for local packages: |
| 46 | + |
| 47 | +``` |
| 48 | + ({ lib, ... }: { |
| 49 | + options.packages = lib.mkOption { |
| 50 | + type = lib.types.attrsOf (lib.types.submodule ( |
| 51 | + { config, lib, ... }: |
| 52 | + lib.mkIf config.package.isLocal |
| 53 | + { |
| 54 | + configureFlags = [ "--ghc-option=-Werror"]; |
| 55 | + } |
| 56 | + )); |
| 57 | + }; |
| 58 | + }) |
| 59 | +``` |
| 60 | + |
| 61 | +Now needs to do it for each of the entry in `config.package-keys` |
| 62 | +instead of using `attrsOf`: |
| 63 | + |
| 64 | +``` |
| 65 | + ({ config, lib, ... }: { |
| 66 | + options.packages = lib.genAttrs config.package-keys (_: |
| 67 | + lib.mkOption { |
| 68 | + type = lib.types.submodule ( |
| 69 | + { config, lib, ... }: |
| 70 | + lib.mkIf config.package.isLocal |
| 71 | + { |
| 72 | + configureFlags = [ "--ghc-option=-Werror"]; |
| 73 | + } |
| 74 | + ); |
| 75 | + }); |
| 76 | + }) |
| 77 | +``` |
| 78 | + |
4 | 79 | ## Jun 5, 2024
|
5 | 80 |
|
6 | 81 | Haskell.nix now respects the `pre-existing` packages selected
|
|
0 commit comments