-
Notifications
You must be signed in to change notification settings - Fork 248
Any way to override a Haskell package using Nix expressions? #510
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
Comments
Also, I've just verified that with |
This approach also appears to have issues with Hydra. For the project I'm testing this with, I need the GitHub version of
I assume this is due to restricted mode? |
Ah yes, you need to use this unfortunate hack to make it into a fixed-output derivation. I think this is a major wart. I remember thinking we should be able to use |
OK, that seems to have fixed the Hydra evaluation. I'm tempted to switch to git submodules for these packages, though, as it would probably be less maintenance until/unless a |
Hi, I have similar case, but in this case, my library located in different folder. I have this structure:
when building I already try to add the I wonder how to add my local package in
with |
I think the combination of doing things in |
With
nixpkgs.haskellPackages
, it's really easy to override a particular package(s) in the Haskell package set using "pure Nix"; that is, without needing to resort to using Cabal or Stackage tooling. For example, I often need to override a dependency (temporarily) while it's in development and hasn't yet been pushed out to Hackage.Here's an example with
nixpkgs.haskellPackges
and Agda, where I wanted some features in the latest version (now 2.6.1) that weren't available on Hackage for nearly 9 months:https://github.com/hackworthltd/hacknix/blob/e8f64c291a076b48569463af32b5ca6fd18e18a3/overlays/haskell-packages.nix#L31
One nice thing about this approach is that the overridden
haskellPackages
set can then be put in an overlay and shared by multiple downstream Nix projects, and that it can be built and cached by CI just like any othernixpkgs
package.With
haskell.nix
, I can do this very easily for a top-level package. For example, here's what I do to buildghcide
from its GitHub repo:https://github.com/hackworthltd/haskell-hacknix/blob/4efd4d58cf6d7c24e8cc7123fdc0fee650e8ba90/nix/pkgs/ghcide.nix#L22
The version pin is trivial to maintain using
niv
, just like all of my other pinned Nix dependencies.That works great for
ghcide
because all I need from that package is theghcide
executable. But what if I wanted to use that version ofghcide
as a library dependency in my localhaskell.nix
project? I can't figure out whether there's any existing way to do that. It looked likemkCacheModule
was going to do that for me, but it appears that packages in acabalProject
'smodules
do not override the packages in thehaskell.nix
Hackage package set. In my brief testing, Cabal ignored a package override in mycabalProject.modules
and used the one inhaskell.nix
's Hackage package set, instead.Judging from a conversation on IRC, it sounds like
haskell.nix
-based projects are expected to pin things in their Cabal file usingsource-repository-package
, and while I agree that this is nice because it means that the package override will be visible to users who aren't using the Nix tooling:a) As these overrides are normally only temporary and aren't meant to be used by downstream consumers of the package, I don't particularly care that it's not visible to non-Nix users;
b) It sounds like the overridden package is built in the project's
shellFor
when you're interactively developing withcabal build
etc., even if it's available in the Nix cache (I have not yet verified this myself);c) If you're already using something like
niv
to pin dependencies in a Nix project, the Cabal pins will need to be maintained separately and will need to be manually updated; andd) If this overridden package version is needed by multiple downstream
haskell.nix
projects, each one of thosehaskell.nix
projects will need to specify that override in their Cabal file, they'll have to be manually kept in sync across projects, etc.For these reasons, I think that being able to specify Haskell package overrides in Nix is preferable to the, "do it in Cabal" approach.
So: am I missing something? Is there is a way to override dependencies a la
haskellPackages.override
innixpkgs
, or would this need to be added tohaskell.nix
?The text was updated successfully, but these errors were encountered: