[Nix-dev] "live builds" proposal
Evgeny Egorochkin
phreedom.stdin at gmail.com
Tue Dec 21 05:25:22 CET 2010
On Sunday 01 August 2010 02:20:28 Yury G. Kudryashov wrote:
> Hi!
>
> 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:
>
> src =
> if builtins ? exec then
> # fetch to ~/.nix-checkouts/name
> builtins.exec [ "nix-prefetch-svn" .... ];
> builtins.filterSource "~/.nix-checkouts/name"
> else if pathExists "~/.nix-checkouts/name" then
> builtins.filterSource ...
> else
> fetchsvn { # url and hash for some specific revision
> };
>
> Of course, all this logic should be hidden in new fetchsvn/fetchgit etc.
> functions.
>
> The main drawback of this solution is that the result of a nix expression
> will depend on some things outside of the nix expression. That's why I
> propose to enable this builtin only if nix is called with --enable-exec: if
> you want to rebuild your system from the configuration written a year ago,
> just do not add --enable-exec.
I'm not sure I really understand the use case you are talking about, but I'll
do my best to guess and explain how my approach for live builds can be used.
I assume you want to rebuild live packages not everytime you do nixos-rebuild
and it discovers that there's another commit in the trunk, but only if there's
a commit and you feel like your live builds are getting out of date.
There are 3 approaches that I see:
* Specify revision via override and update it manually. Doesn't work well if
you have many packages you want to constantly update. This is more appropriate
to fix specific builds.
* Use nix-env and a separate profile, put all live builds in it and update
only when necessary.
* modify gitfetchrevision function proposed in my previous e-mail by replacing
dummy = builtins.currentTime with dummy = import /path/to/systemrevision. This
way, if you want your live packages to be updated, you bump
/path/to/systemrevision and do nixos-rebuild, which will trigger live rebuilds
if there are any new commits. Of course this can be automated by wrapping
nixos-rebuild in a script:
#!/bin/sh
date>/path/to/systemrevision; nixos-rebuild
The only drawback of this approach is that running garbage collector will
cause live rebuilds regardless of systemrevision bump.
--
Evgeny
More information about the nix-dev
mailing list