Hi,
hledger is defined in /pkgs/development/haskell-modules/hackage-packages.nix
. I would like that Nix use the hledger git repository that I cloned on my home directory so it contains my experimental patches.
How can I override the source of an hackage package in Nix?
Thanks
1 Like
There’s a good chance that the end result is still a normal derivation created with mkDerivation
. If so, you should be able to use overrideAttrs
:
environment.systemPackages = with pkgs; [
...
(pkgs.hledger.overrideAttrs (oldAttrs: rec {
src = ...l
}))
]
3 Likes
overrideAttrs
does not work for haskellPackages
as far as I know. There is however an easy to use alternative:
environment.systemPackages = with pkgs; [
...
(pkgs.haskell.lib.overrideSrc pkgs.hledger {
src = /path/to/your/repository;
version = "unstable";
})
...
]
You could also alternatively define an overlay so the hledger
package is changed in pkgs
:
let
hledger-dev-overlay = self: super: {
hledger = self.haskell.lib.overrideSrc super.hledger {
version = "unstable";
src = /path/to/git/repo;
};
};
in
...
If you want haskellPackage
s that depend on hledger
to use the development version as well, you may need to use haskellPackages.haskellPackages.override
.
Thank you @emmanuelrosa and @sternenseemann for your help. Unfortunately, both solutions result in the same error:
Setup: No cabal file found. Please create a package description file .cabal
The hledger
repository contains multiple subdirectories for the individual packages, probably you specified the root directory which contains no .cabal
file.
1 Like
Thank you for your answer. Specifying the hdleger/ sub directory (which is the CLI executable I need) doesn’t work either because it depends on the sibling directory hledger-lib.
1 Like
Sorry for the late answer.
I guess the error is a version constraint failure? I think in that case it should be enough to override the hledger-lib
attribute in haskellPackages
as well. I’m pretty sure the hledger
package does not need to access that directory, just depends on the package which is in the other directory.
Side note: Hledger uses hpack which can catch you out when the cabal and package.yaml
files are not syncronized with each other. cabal2nix
has support for hpack
, so I’m not sure if the package.yaml
or hledger.cabal
file are used as a base in that case.