-
Notifications
You must be signed in to change notification settings - Fork 237
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
haskell-nix.extraPkgconfigMappings documentation #1670
haskell-nix.extraPkgconfigMappings documentation #1670
Conversation
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
re: @L-as
This should probably be part of the project-common module.
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 comment
The 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 modules/project-common.nix
, then it's in the result of evaluating the module (see cabalProject'
) .
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.
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 comment
The 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
@@ -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: |
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
Should we document that directly on the https://input-output-hk.github.io/haskell.nix/ manual?
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 🤔
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 comment
The 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 extraPkgconfigMappings
overlays end up looking like this:
self: super:
{
haskell-nix = super.macaroniLib.mapExtraPkgconfig super.haskell-nix "freeglut" ["freeglut"];
}
Thanks for these docs, @ramirez7 . I tried to use them to update my Haskell.nix-based packaging to current master@HEAD (05c2012) but I didn't succeed. Here's my attempt - PrivateStorageio/PaymentServer@0ea0037 Note I couldn't follow the example in these docs extremely closely because I am setting up overlays different (I don't have a place to put |
I actually do my overlays like you do (as an arg to the nixpkgs The problem you ran into was subtle: Overlays are applied left-to-right, so your overlay was being applied before the haskell.nix overlay, which is what provides the diff --git a/nix/default.nix b/nix/default.nix
index cafdd6c..b0d5d39 100644
--- a/nix/default.nix
+++ b/nix/default.nix
@@ -14,7 +14,7 @@ let
# Haskell.nix is delivery as an overlay. Add our own overlay, which
# provides one of our crypto dependencies, in a non-destructive way.
- allOverlays = moreOverlays ++ haskellNix.nixpkgsArgs.overlays;
+ allOverlays = haskellNix.nixpkgsArgs.overlays ++ moreOverlays;
# Import nixpkgs and pass the haskell.nix provided nixpkgsArgs
pkgs = import |
Yep, that does it, thanks! I was aware of the possibility of overlays clobbering each other but I overlooked the fact that this applies even to my single overlay, since I'm combining it with Haskell.nix's overlay. I'm not sure if the docs could do a better job keeping people away from this pitfall... overlays seem a bit tricky to get right in Nix in general, not just with Haskell.nix. The only thing that comes to mind is providing the feature as more of a "regular" argument somewhere, maybe to Thanks again. |
Sorry for the comment, but is there a chance you could add context to where
It seems like this documentation might help, but would love to see an example of how exactly to do this and where |
@Ashe I'm actually not sure where this I knew what to do due to past Nix experience - the place to put overlays are in the nixpkgs import: import haskellNix.sources.nixpkgs-unstable
{
config = haskellNix.nixpkgsArgs.config;
overlays = haskellNix.nixpkgsArgs.overlays ++ [ overlay1 overlay2 overlay_etc ];
} And then your overlay would just have to define self: super:
{
c = null;
} So in full you could do this I think: import haskellNix.sources.nixpkgs-unstable
{
config = haskellNix.nixpkgsArgs.config;
overlays = haskellNix.nixpkgsArgs.overlays ++ [ (self: super: { c = null; }) ];
} (assuming mapping |
Thank you @ramirez7 , I appreciate it ! I just thought I'd give my perspective as someone who's probably over-reliant on documentation :) |
bors try |
tryBuild succeeded: |
Following up on #1667
docs/tutorials/pkg-map.md
.TODO
Nix comment and put a real one in.