[Nix-dev] Haskell NG: Local packages

Jeffrey David Johnson jefdaj at gmail.com
Tue Apr 28 22:36:55 CEST 2015


It's not specific to Haskell (and I haven't tried haskellng at all yet) but for
personal packages I have mypkgs/<pkgname>/default.nix, and then a top-level
mypkgs/default.nix:

    let
      nixpkgs = import <nixpkgs> {};
      callPkg = nixpkgs.newScope
        (  nixpkgs
        // nixpkgs.haskellPackages
        // nixpkgs.python27Packages
        // self
        );

      self = {
        canonicalFilepath = callPkg ./canonical-filepath {} ;
        filestore         = callPkg ./filestore          {} ;
        gitit             = callPkg ./gitit              {} ;
        igv               = callPkg ./igv                {} ;
        igvtools          = callPkg ./igvtools           {} ;
        indentparser      = callPkg ./indentparser       {} ;
        jeffkb            = callPkg ./jeffkb             {} ;
        jeffwiki          = callPkg ./jeffwiki           {} ;
        ncbi-blast        = callPkg ./ncbi-blast         {} ;
        rPackages         = callPkg ./r-modules          {} ;
        scan2pdf          = callPkg ./scan2pdf           {} ;
        scripts           = callPkg ./scripts            {} ;
        tarql             = callPkg ./tarql              {} ;
        tasktree          = callPkg ./tasktree           {} ;
        tsync             = callPkg ./tsync              {} ;
      };

      in (nixpkgs // self)

I add that to my NIX_PATH so I can `import <mypkgs>` anywhere to get <nixpkgs>
overridden with the stuff I'm working on.
Jeff

On Tue, 28 Apr 2015 22:11:57 +0200
Ertugrul Söylemez <ertesx at gmx.de> wrote:

> I believe Peter's message <87mw5qvj9x.fsf at write-only.cryp.to> could
> answer my question.  I will give it a try.
> 
> > Hello fellow Haskellers,
> >
> > I have a bunch of local Haskell packages, mostly libraries.  The package
> > X lives in the directory `<ertes-src/X/main>`.  There are lots of direct
> > and indirect dependencies between them.  My current solution is ad hoc
> > and rather ugly.  I'm using the following hand-crafted `shell.nix` file
> > in every project:
> >
> >     { pkgs ? import <nixpkgs> {} }:
> >
> >     let inherit (pkgs.haskellngPackages) callPackage;
> >
> >         extPkg = path: deps:
> >             (callPackage (import path) deps).override (args: args // {
> >                 mkDerivation = expr:
> >                     args.mkDerivation (expr // {
> >                         src = pkgs.fetchdarcs { url = path; };
> >                     });
> >             });
> >
> >         thisPkg = callPackage (import ./devel.nix) {
> >             direct-dep1 = extPkg <ertes-src/dep1/main> {
> >                 indirect-dep1 = ...;
> >                 indirect-dep2 = ...;
> >             };
> >             direct-dep2 = extPkg <ertes-src/dep2/main> {};
> >         };
> >
> >     in thisPkg.env
> >
> > Do not pay too much attention to the `extPkg` function.  It just works
> > around cabal2nix' lack of support for Darcs URLs.
> >
> > My question is:  Is there a nicer and more principled way to solve this?
> > Ideally I could simply add all of my local packages in some way to my
> > `~/.nixpkgs/config.nix`.  Then they could just depend on each other
> > regularly and I wouldn't need any shell.nix hackery.  I'm guessing that
> > I need to override haskellngPackages in some way or perhaps create my
> > own using some override.
> >
> >
> > Greets,
> > Ertugrul


More information about the nix-dev mailing list