[Nix-dev] Re: Integrating a Nix expression into the set of packages

Marc Weber marco-oweber at gmx.de
Tue Oct 16 19:05:26 CEST 2007


> My question was: could I publish such a Nix expression, yet have it
> benefit from (and refer to) packages from `all-packages.nix'?

Hopefully my answer fits your question..

all-package .nix is basically
{ <some opts> } :
rec {
  pkg1 = mkDerivation{ buildInputs=[ dep dep ]; };
  pkg2 = mkDerivation{ buildInputs=[ dep dep ]; };
  ...
  <your package>
};

Now you want to benefit from all-packages (thus using those dependencies
as arguments to your derivation without adding <your package> at the
place show above?

You can do this using the 'with' syntax
  with (import <path to all-packages.nix>) {}:
  (import <your file>) { inherit stdenv fetchurl gmp readline }

or perhaps more simple:
  let pkgs = (import <all-packages.nix>) {}; in
    (import <your file>) { inherit (pkgs) stdenv fetchurl gmp readline }

(both is untestet.. but should work.. :)

pay attention to the {} which means use default values for <some opts>.

I'm currently modyfing all-packages.nix myself and adding the
derivations there because I'm lazy and I want to commit them as soon as
they do compile..

Marc



More information about the nix-dev mailing list