Skip to content
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

How do I override a dependency's source? (e.g. to build from a fork) #1293

Closed
cumber opened this issue Nov 15, 2021 · 5 comments
Closed

How do I override a dependency's source? (e.g. to build from a fork) #1293

cumber opened this issue Nov 15, 2021 · 5 comments
Labels

Comments

@cumber
Copy link

cumber commented Nov 15, 2021

I'm not clear on how I'm supposed to override a package's source using haskell.nix infrastructure. (e.g. at the moment there are a lot of packages that don't build on 9.2.1 that have pull requests floating around to enable them to build; overriding sources to use these pull requests gets my project building in the meantime). Using straight nixpkgs I would have used an overlay.

I've found if I list a source-repository-package in cabal.project I can override it provided the dependency is only a direct dependency. If it's a dependency of a dependency then haskell.nix doesn't provide the source-repository-package version when building the dependency; I can add source-repository-pacage stanzas all the way down the dependency chain, of course, but that's extremely tedious if it's more than a few levels deep.

Is this something I can do with the modules or pkg-def-extras arguments to cabalProject'?

Would be great to have an example in the docs.

@smunix
Copy link

smunix commented Dec 4, 2021

Agreed, it would be great to be able to override package dependencies right from project'.

@angerman
Copy link
Collaborator

angerman commented Dec 6, 2021

Is this something I can do with the modules or pkg-def-extras arguments to cabalProject'?

yes. You can override the src attribute on packages in a module. E.g.

{ 
   # default is:
   # pkgs.fetchurl {
   #    url = "mirror://hackage/${config.name}.tar.gz";
   #    inherit (config) sha256;
   # };
   package.xyz.src = ... 
}

see: https://input-output-hk.github.io/haskell.nix/reference/modules/#packagessrc

However this will only work if you are modifying the source, for changes to the cabal file, this is a bit trickier, as that would need to go into the hackage.nix index. We don't have support for hackage overlays yet, which would be really nice to have in this case to have a 9.2 compat hackage overlay (as an example head.hackage is a hackage overlay to facilitate working with ghc HEAD).

@cumber
Copy link
Author

cumber commented Dec 6, 2021

Aha, good to know. That's still something.

The cabal file is usually part of that tarball, so if I update the src location it could well have cabal file differences. Do I understand right that the problem is none of these differences will be used by haskell.nix's build plan, because it's decided on that by the time it's downloaded the tarball? So e.g. relaxing dependency bounds won't help, right? Can I also work around that with further config? allow-newer in cabal.project, perhaps?

@ilyakooo0
Copy link
Contributor

ilyakooo0 commented Dec 20, 2021

I made a thing that seems work in all cases (even with cabal changes): https://github.com/ilyakooo0/haskell-nix-extra-hackage

@stale
Copy link

stale bot commented Sep 28, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants