-
Notifications
You must be signed in to change notification settings - Fork 238
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
Modify package options for all local packages #298
Comments
Nevermind. I just realized that you can do something like
which I think will solve at least one of my problems. It would be good to put this in the documentation. |
Ok, so that was a dead end. Trying to define the configuration in terms of the
@angerman @hamishmack, is there a way to accomplish what I'm trying to do? If not, can you suggest an alternative approach? |
Maybe we need more low level |
Perhaps we could have
We could just write:
|
First try:
|
@hamishmack modifying I tried your example and had to change a few things, mainly the way
Seems to work quite well, thanks! |
Oh, I spoke too soon! There are some packages that already have a |
Running into exactly the same problem. How about we change the type of
then nixos module system merging will take care of this. I'll see if I can come up with a patch! |
I ended up with a hack where I check whether the package's By using pkgs.haskell-nix.mkStackPkgSet rec {
stack-pkgs = import ./nix/stack/pkgs.nix;
pkg-def-extras = [];
modules =
[
(
let
pkg-names = lib.attrNames (stack-pkgs.extras {}).packages;
patch = name: builtins.trace name {
# Final hack, workaround for https://github.com/input-output-hk/haskell.nix/issues/298
# we know that local packages sure dont have postUnpack. We find out that they're local based
# on their source beign local
${name} = { config, ... }: lib.mkIf (builtins.typeOf config.src == "path") {
postUnpack = ''
if [[ -e $sourceRoot/package.yaml ]]; then
substituteInPlace $sourceRoot/package.yaml --replace '../../package-defaults.yaml' "${./package-defaults.yaml}"
fi
'';
dontStrip = false;
};
};
in
{
packages = lib.mkMerge (map patch pkg-names);
}
)
];
}; The reason your version broke is that The durable fix is to indeed make |
@arianvp thanks, that's great! I agree it would be better if One thing I'm also wanting to do is wrap executables and tests if they depend on
But keep getting infinite recursion. I haven't been able to figure out if or how a similar hack with |
It is indeed possible to do this with the module system without getting infinite recursion. The important thing to know is that if you have an option of type As an untested example, you can add a { lib, ...}: {
options.packages = lib.mkOption {
type = lib.types.attrsOf (lib.types.submodule ({ config, ... }: {
config = lib.mkIf config.package.isLocal {
postUnpack = lib.mkAfter ''
echo foo
'';
};
}));
};
} |
@infinisil interesting, thanks. With haskell.nix, where would that go? In the |
@purefn Yeah that goes into the |
@infinisil Thanks! That works perfectly! |
IMO this is still an issue, the workaround is pretty unpleasant. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Heads up: Usually, one probably does not want to modify all local packages, but rather only project packages: All project packages are local packages, but e.g. E.g. in #298 (comment), one can simply swap out |
project-vs-non-project packages is a distinction that haskell.nix makes right? AFAIU cabal only distinguishes local vs non-local. |
The solution suggested by @infinisil is the correct one. That does not mean we cannot improve on the situation. Perhaps we could have a |
The current way of modifying package configurations seems to have a few drawbacks I haven't figured out a good way around. One is changing an option, like disabling haddock or setting a postUnpack value, for a subset of unnamed of packages determined by a function, like checking if a package is local. It seems like you can only do it by manually listing the packages.
A separate issue is being able to patch one package with the nix store path of another Haskell package.
Is there a way to accomplish these that I'm not finding?
The text was updated successfully, but these errors were encountered: