[Nix-dev] nix configuration language
Ben Franksen
ben.franksen at online.de
Mon Apr 23 13:53:28 CEST 2012
Marc Weber wrote:
> Excerpts from Ben Franksen's message of Mon Apr 23 12:42:14 +0200 2012:
>> I don't know how I can execute a 'nix-language script'. Is there a tool
>> in the nix package that I could use for that?
> the nix suite ships with test cases. If you look at those you'll find
> that its nix-instantiate --eval-only [--strict] foo.nix which evaluates
> nix code and eventually writes .drv files or such.
Thank you, this is exactly what I needed to know. Now I can start to play
with the idea...
> nix-build basically does a nix-instantiate and the a nix-store --realise
> .drv file (maybe its hardcoded in C).
>
> If you use Vim you may want to look at vim-addon-nix which provides
> default mappings for running nix via vim-addon-actions.
> It also syntax checks the nix files on buf write.
Cool. Will look at this.
> Now it depends on which output you need and how to do what would be
> called "IO" Haskell, or which is nixos-rebuild for nixos - thus how to
> do something with your description (which might be called evaluated
> result).
Yes.
> Eg the "nix" way would be create a store paths such as
>
> $out/bin/realise
> $out/machine1/target-ssh-data
> $out/machine1/configuration.nix
>
> where the realise script tries to connect to the target machines,
> copying over the configuration then running nixos-rebuild.
We do have a self-written tool for distributing the configuration in a
quasi-immutable way, similar to nix (but a lot less elegant). The problem
with nix is that it is a bit too radical for our purposes, i.e. we do not
want it to manage binaries, only the configuration data.
> However in the real world you have to cope with state - eg do HTTP
> forwarding until domain servers caches time out if you move web sites,
> and drop that after a couple of days etc.
What we do is very different from web/cloud stuff. It /is/ a distributed
system, but rather one for which you would want to use Erlang (though we do
not, unfortunately, else we'd use that for configuration, too).
> I'm not entirely sure - maybe what you're looking for is what disnix is
> about: http://nixos.org/disnix/
I looked at disnix, and it is certainly interesting, but as it builds on nix
it is most probably overkill, even more so than nix itself is.
>> Do you think it would be very difficult to extract the language from the
>> nix source tree?
> define "very difficult".
Checking out the nix sources via git, I can't even build it:
ben at sarun[1]: .../tmp/nix > git status
# On branch master
nothing to commit (working directory clean)
ben at sarun[1]: .../tmp/nix > ./bootstrap.sh
autoreconf: Entering directory `.'
autoreconf: configure.ac: not using Gettext
autoreconf: running: aclocal --force
autoreconf: configure.ac: tracing
autoreconf: configure.ac: not using Libtool
autoreconf: running: /usr/bin/autoconf --force
configure.ac:59: error: possibly undefined macro: AC_DISABLE_SHARED
If this token and others are legitimate, please use m4_pattern_allow.
See the Autoconf documentation.
configure.ac:60: error: possibly undefined macro: AC_ENABLE_STATIC
configure.ac:85: error: possibly undefined macro: AC_DISABLE_STATIC
configure.ac:86: error: possibly undefined macro: AC_ENABLE_SHARED
configure.ac:87: error: possibly undefined macro: AC_PROG_LIBTOOL
autoreconf: /usr/bin/autoconf failed with exit status: 1
I do have autoconf, automake etc installed at version 2.68.
> Think about how to use the result. Wait for
> more replies. Think about which tool will turn your "configuration" done
> with any DSL into something "real".
There will probably have to be 'builders' of some sort or the other,
depending on the format of the output. I will play around a bit and see...
> Another nice keyword might be "chef":
> https://github.com/opscode/chef
Looking at the web-site I don't think this fits the bill at all. The output
from our configuration spec is typically a number of simple text files in
various formats not widely known outside the application area. I want a
small versatile tool, not a huge 'framework'. And open source, please ;-)
> to find related work before spending huge amounts of time this.
No fear, I really cannot invest a lot of time to do such a split/re-
factoring. But what you wrote above about nix-instantiate --eval-only sounds
promising.
> You're welcome in any case :)
Thanks!
Cheers
Ben
More information about the nix-dev
mailing list