[Nix-dev] Getting nix-shell to consider config.nix

Mateusz Kowalczyk fuuzetsu at fuuzetsu.co.uk
Tue Jun 3 16:03:36 CEST 2014


On 06/01/2014 03:53 PM, Mateusz Kowalczyk wrote:
> My ~/.nixpkgs/config.nix is as follows:
> 
> ###
> 
> { pkgs }:
> 
> { packageOverrides = self: with pkgs; rec {
> 
>   ghc = self.ghc // {
>     ghcHEAD = callPackage /home/shana/programming/ghc {};
>   };
> 
> }; }
> 
> ###
> 
> What I think it does is overrides ghcHEAD packages with the package I
> have in the specified path. In fact, nix-env -qaP | egrep -i ghcHEAD
> shows: nixpkgs.ghc.ghcHEAD ghc-7.9.20140530
> 
> This is consistent with the version in my default.nix at the specified path.
> 
> Now I want to use this in another project, through nix-shell (and
> otherwise).
> 
> At the top of it I have
> 
> ###
> 
> { haskellPackages ? (import <nixpkgs> {}).haskellPackages_ghcHEAD
> , …
> }:
> 
> ###
> 
> But that wants to pull in 7.9.20140430 which is what ghcHEAD version is
> in nixpkgs itself so clearly it's omitting my config.nix. How can I get
> nix-shell to look in my config? I tried playing with variety of --arg
> stuff but no matter what I try, it tells me that ~/.nixpkgs/config.nix
> doesn't exist so I must be using it wrong.
> 

For future reference, here's what I ended up doing: my config.nix now
contains

  haskellPackages_ghcHEAD = self.haskell.packages {
    ghcPath = /home/shana/programming/ghc;
    ghcBinary = self.haskellPackages.ghcPlain;
    prefFun = hself: hsuper: self.haskell.ghcHEADPrefs hself hsuper // {
      mtl = hself.mtl_2_2_0_1;
    };
  };

where my /home/shana/programming/ghc/default.nix is similar to the stock
one in nixpkgs. You can read it here[1] if you really want to. Then in a
separate project I use haskellPackages_ghcHEAD as I normally would such
as seen here[2].


[1]:
https://github.com/Fuuzetsu/nix-project-defaults/blob/master/ghc/default.nix
[2]:
https://github.com/Fuuzetsu/nix-project-defaults/blob/master/haddock/default.nix

-- 
Mateusz K.


More information about the nix-dev mailing list