[Nix-dev] Override Sets in an Environment

Oliver Dunkl oliver.dunkl at gmail.com
Thu Aug 20 09:57:20 CEST 2015


I would like to override a set of Haskell packages in a nix-shell. I
tested it in a nix-repl with

nix-repl> :l <nixpkgs>
nix-repl> hpkgs = pkgs.haskell.packages.ghc784 // { aeson = pkgs.haskell.packages.ghc784.callPackage ./aeson-0.8.0.2.nix {}; }
nix-repl> pkgs.haskell.packages.ghc784.aeson.version
"0.9.0.1"
nix-repl> hpkgs.aeson.version
"0.8.0.2"

Thats ok!

Now I have a shell.nix and want to load all that stuff into a
nix-shell. My shell.nix looks like

{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc784" }:
let
  inherit (nixpkgs) pkgs;

  hpkgs = pkgs.haskell.packages.${compiler} // { aeson = pkgs.haskell.packages.${compiler}.callPackage ./aeson-0.8.0.2.nix {}; };
  mpkgs = hpkgs.override {
    overrides = self: super: {
      my-pack = self.callPackage ./. {};
    };
  };
in if pkgs.lib.isNixShell then mpkgs.my-pack.env else mpkgs

My expectation is that I have aeson-0.8.0.2 in my environment but I
have aeson-0.9.0.1 in it.

nix-shell --command 'ghc-pkg list | grep aeson'
  aeson-0.9.0.1

Can somebody explain me that behaviour and how to configure
shell.nix that I have aeson-0.8.0.2 afterwards.

The background is that I would like to make a freeze.nix where all
libs from the constraints of `cabal freeze' are inside and like to
override my haskell-packages with that frozen libs.

Nix version 1.9.

thx
\= odi  


More information about the nix-dev mailing list