-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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
Allow callCabal2nix callers to tweak its source filtering #257730
Allow callCabal2nix callers to tweak its source filtering #257730
Conversation
A couple random thoughts:
|
@cdepillabout I've incorporated your feedback:
re: whether this should be in upstream vs not:
let expr = self.haskellSrc2nix {
inherit name extraCabal2nixOptions;
src = if pkgs.lib.canCleanSource src
then pkgs.lib.cleanSourceWith { inherit src filter; }
else src;
};
in overrideCabal (orig: {
inherit src;
}) (callPackageKeepDeriver expr args);
|
@ramirez7 Thanks, this looks better to me. Let's see what the other maintainers have to say. |
Bumping this 😁 |
Looks good to me. I would love to see the behaviour documented in the manual! |
@maralorn I'll add something! |
@ramirez7 Hey, just following up, I think we'd like to merge this, but can you do the following first:
|
Sorry I forgot to get back to you here! I'll hopefully make myself some time in the next month to do this - or I'll hand it off to someone at work (since we are using it there for our codebase). |
@cdepillabout some time passed and nothing happened, does the team still want to merge this? i could apply the changes you requested. @ramirez7 could i do so? |
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.
I think the general idea is still sensible even though I kinda wished cabal2nix hadn’t supported this in the first place.
The commit history here feels kinda artificial to me. The steps are very small and do not even eval correctly in between.
Still some docs would be awesome.
let | ||
filter = path: type: | ||
checkOpts = x@{extraCabal2nixOptions ? "", srcModifier ? null}: { inherit extraCabal2nixOptions srcModifier; }; |
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.
Unused x@
.
checkOpts = x@{extraCabal2nixOptions ? "", srcModifier ? null}: { inherit extraCabal2nixOptions srcModifier; }; | ||
checkedOpts = if builtins.isString opts then checkOpts { extraCabal2nixOptions = opts; } else checkOpts opts; | ||
extraCabal2nixOptions = checkedOpts.extraCabal2nixOptions; | ||
srcModifier = checkedOpts.srcModifier; |
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.
I feel like this whole section could be simplified by e.g. using or
or inherit
syntax.
@eldritch-cookie I'm cool handing this off to you! @maralorn eh I think nixpkgs is somewhat stuck supporting Regardless, the fact that the |
824e074
to
6e6bd77
Compare
Fixes NixOS#256769 Repro + test of fix here: https://gitlab.com/ramirez7/bug-repros/-/merge_requests/1 Adds a `srcModifier` argument to `callCabal2nixWithOptions` to allow customizing the source files used to generate the cabal file (e.g. to support `hpack`/`package.yaml`).
6e6bd77
to
99a617b
Compare
@maralorn @eldritch-cookie I've addressed the review comments and added documentation, PTAL. |
Description of changes
Fixes #256769
Repro + test of fix here: https://gitlab.com/ramirez7/bug-repros/-/merge_requests/1
This PR introduces a new
callCabal2nix
variation:callCabal2nixGeneric
. I called it "generic" because it has an additional attrset arg that can be used to stuff various options thecallCabal2nix
Nix code needs.In this case, I've added
extraSrcFilter
, which the caller can use to tellcallCabal2nix
to keep certain files around if they are needed to generate the cabal file. For instance, extra yaml files that apackage.yaml
mightinclude
.Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)