on df2147d help sign in
68 lines 2.4 kB history raw
1# Mapping non-Haskell dependencies to Nixpkgs
3Cabal files may contain dependencies to external non-Haskell
4dependencies via:
6* [`build-tool-depends`](https://cabal.readthedocs.io/en/latest/cabal-package.html#pkg-field-build-tool-depends)
7* [`pkgconfig-depends`](https://cabal.readthedocs.io/en/latest/cabal-package.html#pkg-field-pkgconfig-depends)
8* [`frameworks`](https://cabal.readthedocs.io/en/latest/cabal-package.html#pkg-field-frameworks)
9* [`extra-libraries`](https://cabal.readthedocs.io/en/latest/cabal-package.html#pkg-field-extra-libraries)
11If there is a `pkgs` attribute in Nixpkgs that matches the name given
12in the Cabal file, then it will be added as a dependency (see the
13output of `cabal-to-nix`). Otherwise, there needs to be a mapping from
14Cabal file names (decided by the package author) to Nix package
15identifiers.
17### Nixpkgs overlay
19The user may solve it by themself by overriding Nixpkgs and adding a
20package alias. For example:
22```nix
23nixpkgs.overlays = [
24 (self: super: {
25 icuuc = self.icu;
26 icui18n = self.icu;
27 icudata = self.icu;
28 })
29];
30```
32### Replace libraries of components
34If a component is missing a dependency it can be added via modules. For example:
36``` nix
37project = pkgs.haskell-nix.project' {
38 src = self;
39 compiler-nix-name = "ghc8102";
40 modules = [{
41 # Replace `extra-libraries` dependencies
42 packages.X11.components.library.libs = pkgs.lib.mkForce (with pkgs.xorg;
43 [ libX11 libXrandr libXext libXScrnSaver libXinerama ]);
44 }];
45};
46```
48### Mapping in Haskell.nix
50Alternatively, if the name is commonly used, an alias can be added to
51the Haskell.nix sources, so that it's solved for all users.
53* [`lib/pkgconf-nixpkgs-map.nix`](https://github.com/input-output-hk/haskell.nix/blob/master/lib/pkgconf-nixpkgs-map.nix)
54 — for `pkgconfig-depends`.
56 Each mapping entry is a list of packages.
58* [`lib/system-nixpkgs-map.nix`](https://github.com/input-output-hk/haskell.nix/blob/master/lib/system-nixpkgs-map.nix)
59 — for `build-tool-depends`, `frameworks`, `extra-libraries`, etc.
61 Each name can be mapped to:
62 1. A single package from nixkpgs.
63 2. `null` — eliminates the dependency
64 3. A list of packages — sometimes needed for dependencies such as `X11`.
66!!! tip "Open a PR"
67 Please go ahead and open a [pull request](https://github.com/input-output-hk/haskell.nix/pulls)
68 to improve the package mappings.