[Nix-dev] "live builds" proposal

Eelco Dolstra e.dolstra at tudelft.nl
Sun Aug 1 10:56:15 CEST 2010


Hi,

On 08/01/2010 01:20 AM, Yury G. Kudryashov wrote:

> I propose the following extension to the nix language that will allow native 
> support for "live scm builds" etc.
> 
> If nix is called with --enable-exec, the new function builtins.exec is 
> added. The proposed syntax is like the following:

This is already kind of possible (if I understand correctly what you want).  For
instance, to obtain the current head revision of a SVN repository:

rev = import (pkgs.runCommand "head-revision.nix"
  { buildInputs = [ pkgs.subversion ];
    dummy = builtins.currentTime;
  }
  ''
    rev=$(echo p | svn ls -v --depth empty https://svn.nixos.org/repos/nix | awk
'{ print $1 }')
    echo "[ $rev ]" > $out
  '');

So this imports a Nix expression generated by a derivation ("import (runCommand
...)").  The real trick is "dummy = builtins.currentTime;", i.e. passing the
current time as an input to the derivation, to ensure that it gets rebuilt every
time you evaluate the expression.

Needless to say that this is undocumented and unsupported ;-)

-- 
Eelco Dolstra | http://www.st.ewi.tudelft.nl/~dolstra/



More information about the nix-dev mailing list