-
Notifications
You must be signed in to change notification settings - Fork 247
haskell-nix.extraPkgconfigMappings documentation #1670
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,6 +29,23 @@ nixpkgs.overlays = [ | |
]; | ||
``` | ||
|
||
The user can map package(s) in Nixpkgs to a `pkgconfig-depends` name by | ||
overlaying the `haskell-nix.extraPkgconfigMappings` attribute: | ||
|
||
```nix | ||
nixpkgs.overlays = [ | ||
(self: super: { | ||
haskell-nix = super.haskell-nix // { | ||
extraPkgconfigMappings = super.haskell-nix.extraPkgconfigMappings // { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You have to take care to not clobber other overlays that add mappings. I have some helpers in my Nix code since this gets tedious: {
# See https://stackoverflow.com/a/54505212
recursiveMerge = x: y: recursiveMergeAll [x y];
recursiveMergeAll = attrList:
with super.lib;
let f = attrPath:
zipAttrsWith (n: values:
if tail values == []
then head values
else if all isList values
then unique (concatLists values)
else if all isAttrs values
then f (attrPath ++ [n]) values
else last values
);
in f [] attrList;
mapExtraPkgconfig = super-haskell-nix: name: mappings: recursiveMerge super-haskell-nix {
extraPkgconfigMappings = { "${name}" = mappings; };
};
} So my self: super:
{
haskell-nix = super.macaroniLib.mapExtraPkgconfig super.haskell-nix "freeglut" ["freeglut"];
} |
||
# String pkgconfig-depends names are mapped to lists of Nixpkgs | ||
# package names | ||
"SDL_gpu" = [ "SDL_gpu" ]; | ||
}; | ||
}; | ||
}) | ||
]; | ||
``` | ||
|
||
### Replace libraries of components | ||
|
||
If a component is missing a dependency it can be added via modules. For example: | ||
|
@@ -59,7 +76,7 @@ the Haskell.nix sources, so that it's solved for all users. | |
— for `build-tool-depends`, `frameworks`, `extra-libraries`, etc. | ||
|
||
Each name can be mapped to: | ||
1. A single package from nixkpgs. | ||
1. A single package from nixpkgs. | ||
2. `null` — eliminates the dependency | ||
3. A list of packages — sometimes needed for dependencies such as `X11`. | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,7 @@ final: prev: { | |
# overlays. | ||
defaultModules = []; | ||
|
||
# TODO: doc etc | ||
# Additional user-provided mappings to augment ./../lib/pkgconf-nixpkgs-map.nix | ||
extraPkgconfigMappings = {}; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. re: @L-as
What did you mean by this? I'm not familiar with the whole structure of haskell.nix, but would that also make it easy to set these options globally? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ramirez7 Sorry for the late response, yeah, essentially you add an option for it in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. extraPkgconfigMappings = mkOption {
type = submodule [ fill this out ];
default = {};
description = ''
Extra pkgconfig mappings
'';
}; There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm I'll try this in a branch and get a good comparison going |
||
# Nix Flake based source pins. | ||
# To update all inputs, get unstable Nix and then `nix flake update --recreate-lock-file` | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
re: @yvan-sraka
I added this to the "Nixpkgs overlay" section of this tutorial since it also uses overlays. I guess it's more specifically a
haskell-nix
overlay, but still 🤔