git.iko.soy/typeable/cabal2nix
on master help sign in
Update user-guide.md
commitbd88230a2d57cb66aa63d4c9d6077958951c9195 authorNicolas Rolland <nrolland@users.noreply.github.com> dateTue 2 Jun 2015, 17:22 (11 years ago) parent0ca0e55
1 file changed+48
doc/user-guide.md+48
doc/user-guide.md+48
@@ -316,6 +316,54 @@ convert those automatically into build instructions for Nix using the
316316`cabal2nix` utility, which you can install into your profile by running
317317`nix-env -i cabal2nix`.
318318
319+## How to override a cabal package version for a specific compiler version
320+
321+Say the default version of ghc-events is 0.4.4.0 and does not work with ghc784
322+We can override this by
323+
324+ $ mkdir .nixpkgs/haskell/ && cd .nixpkgs/haskell/
325+ $ cabal get ghc-events-0.4.3.0 && cd ghc-events-0.4.3.0 && cabal2nix --no-check ghc-events.cabal > default.nix
326+
327+in the config.nix we then override the packages
328+
329+ #overrides for every compiler versions
330+ myHaskellPackages = hp : hp.override {
331+ overrides = self: super: with pkgs.haskell.lib; {
332+ ...
333+ };
334+ };
335+ myHaskellPackages784 = hp : hp.override {
336+ overrides = self: super: with pkgs.haskell.lib; {
337+ ...
338+ ghc-events = dontCheck (pkgs.haskell.packages.ghc784.callPackage ./haskell/ghc-events-0.4.3.0 {});
339+ ...
340+ };
341+ };
342+ haskellngPackages = myHaskellPackages super.haskellPackages;
343+ haskell784Packages = myHaskellPackages784(myHaskellPackages super.haskell.packages.ghc784);
344+
345+We can then use those packages to build environments which will pick up the desired version
346+
347+ hs784 = haskell784Packages.ghcWithPackages (p: with p;
348+ [
349+ ghc-events
350+ ...
351+ ]
352+ );
353+
354+ hs7101 = haskellngPackages.ghcWithPackages (p: with p;
355+ [
356+ ghc-events
357+ ...
358+ ]
359+
360+as can be verified by
361+
362+ nix-store -qR $(nix-instantiate '<nixpkgs>' -A pkgs.hs784 ) | grep ghc-events
363+ nix-store -qR $(nix-instantiate '<nixpkgs>' -A pkgs.hs7101) | grep ghc-events
364+
365+
366+
319367## How to build a stand-alone project
320368
321369For example, let's assume that you're working on a private project called