[Nix-dev] [***SPAM***] Dynamic Dependency Management by Calling External Programs from Nix
Eelco Dolstra
e.dolstra at tudelft.nl
Wed Oct 26 17:14:17 CEST 2011
Hi,
On 10/25/2011 01:35 AM, Shea Levy wrote:
> So I'd really like to see one of two solutions implemented (I'll do the
> implementation myself if Eelco is willing to consider accepting these solutions)
> in nix (possibly with an explicit command-line flag or nix.config setting to
> enable them, like we have with enableParallelBuilds):
You can do what you want today, since the "import" function (as opposed to
builtins.readFile) supports importing the output of a derivation. I.e. you can do
let drv = runCommand ... "some command that generates $out/foo.nix" ...
in import "${drv}/foo.nix"
However, you don't want this most of the time, certainly not in Nixpkgs, because
it causes query operations like "nix-env -qa" to do a build. Which is a bad
thing. Actually, since "nix-env -qa" runs in read-only mode, it won't even work
(but it will work for "nix-env -i", "nix-instantiate" or "nix-build").
There are a few examples of this:
- https://nixos.org/repos/nix/nixpkgs/trunk/pkgs/build-support/vm/default.nix;
here we import the output of the functions rpmClosureGenerator and
debClosureGenerator (a derivation that builds a Nix expression containing
fetchurl calls to download the required RPMs or Debs).
- https://nixos.org/repos/nix/nixpkgs/trunk/pkgs/misc/tex/nix/default.nix; the
function to build a LaTeX document does "deps = import (pkgs.runCommand
"latex-includes" ..." to figure out the dependencies of the document (e.g.,
\input{...}) on the fly.
- https://nixos.org/repos/nix/attic/make/lib/default.nix does a similar thing to
figure out the header file dependencies of a C file.
--
Eelco Dolstra | http://www.st.ewi.tudelft.nl/~dolstra/
More information about the nix-dev
mailing list