Comments (6)
Accidently re-opened - nothing needs to change. Thanks for the tip about applyPatches
, I will look into that!
from cabal2nix.
Totally get it, and I appreciate your help. This is unfortunately in the middle of a large commercial project and I don't have the time/energy to cut that down to a manageable chunk.
For posterity, note that I essentially can't modify the source repository here (xxx-gogol
), so checking in a cabal file isn't really an option. I have to make changes to the downloaded sources for GHC 9 compatability, thus the additional dependency I'm trying to add.
I was able to implement a solution that patches the sources first, then uses those patched sources as input to cabal2nix
. It looks something like this:
xxx-gogol-patch = stdenv.mkDerivation {
patches = ./xxx-gogol.patch;
src = sources.xxx-gogol;
name = "xxx-gogol-patch";
dontConfigure = true;
dontBuild = true;
dontInstall= true;
postPatch = ''
mkdir $out
cp -R . $out
'';
};
# Use the patched sources from above to generate nix expression for xxx-gogol,
# rather than raw sources downloade by niv. If we instead applied the ./xxx-gogol.patch
# file here (via `appendPatch` or any other mechanism), it won't have any effect, because
# cabal2nix always runs before any patching is done, and the nix expression it generates does
# not show the dependency on singletons-th.
xxx-gogol = hfinal.callCabal2nix "xxx-gogol" "${xxx-gogol-patch.out}" { };
from cabal2nix.
My guess is that you are calling appendPatch
and callCabal2nix
in the wrong order.
For instance, calling cabal2nix cabal://lua-1.0.0
is going to give an output like this:
{ mkDerivation, base, bytestring, lib, tasty, tasty-hunit }:
mkDerivation {
pname = "lua";
version = "1.0.0";
sha256 = "289d4ebb54e92d7c3955a56b1671872343d3f841c2b91abba26ad39ebc06c153";
libraryHaskellDepends = [ base bytestring ];
testHaskellDepends = [ base bytestring tasty tasty-hunit ];
homepage = "https://hslua.github.io/";
description = "Lua, an embeddable scripting language";
license = lib.licenses.mit;
}
This cabal2nix
call has already called hpack
, and read the resulting lua.cabal
file to turn it into the above Nix derivation. Your call to appendPatch
happens after this, but it is already too late. The Nix derivation has already been produced.
I think your two choices here are either to patch sources.xxx-gogol
before calling cabal2nix
, or just add the singletons-th
dependency after calling cabal2nix
. In Nixpkgs, we generally take the second approach. Here's a random example:
from cabal2nix.
Thanks for the help! How would I patch the sources before calling cabal2nix
? I suppose I'd have to create a derivation with just the sources for xxx-gogol, patch those, then call cabal2nix over that? Sounds much cleaner than below but also harder!
Regardless, addBuildDepend
pretty much did the trick. However, the cabal file still needed to get regenerated, and somehow libraryHaskellDepends
didn't have singletons-th
in it. But I was able to add the library by hand, and updated postPatch
so it would run hpack
again.
This is what I ended up with:
addBuildDepend singletons-th (overrideCabal (
appendPatch (
hfinal.callCabal2nix "xxx-gogol" sources.xxx-gogol { }
) [./xxx-gogol.patch]
) (drv: {
libraryHaskellDepends = drv.libraryHaskellDepends ++ [ singletons-th ];
postPatch = ''
hpack
'';
}));
from cabal2nix.
Without a fully reproducible example, it is hard to help you, but I thought that all you'd need would be something like this:
addBuildDepend singletons-th (hfinal.callCabal2nix "xxx-gogol" sources.xxx-gogol { })
Although I'm not sure if you have some specific hpack
-related problems to work around. You should probably be checking the xxx.gogol.cabal
file into your repo as well if you're not already: https://www.fpcomplete.com/blog/storing-generated-cabal-files/.
from cabal2nix.
How would I patch the sources before calling
cabal2nix
?
nixpkgs has a simpler function for this, called applyPatches
.
I don't see how this is a cabal2nix issue really, it behaves correctly in this example in my opinion. Can you state what you would like to change?
from cabal2nix.
Related Issues (20)
- fromCabalLicense: unknown licenseUnknownLicense "BSD-3" HOT 2
- Handle internal libraries correctly HOT 4
- Set `meta.mainProgram` HOT 1
- file:// will ignore a cabal file HOT 1
- cabal2nix tries to fetch hackage revisions even if already present in the source HOT 2
- hackage2nix: Correctly flag broken Haskell packages HOT 12
- Regression tests for fetcher-based derivations
- docs: Sidebar on left doesn't scroll HOT 1
- Enable hlint on CI
- Map `extra-libraries: FLAC` to pkgs.flac HOT 4
- latest library doesn't pull in other latest library
- do not encourage use of `nix-env` HOT 1
- hackage-db: `signatures` field in `MetaData` has the wrong type
- hackage-db: .cabal file extraction HOT 1
- Confusing output when using --subpath in conjunction with a source that needs to be unpacked
- Improve tooling for making a new release
- Add --disable-library-profiling option HOT 2
- `posix_spawnp: illegal operation` HOT 1
- Support for GitHub/GitLab PR URLs HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cabal2nix.