[Nix-dev] nix configuration language
Marc Weber
marco-oweber at gmx.de
Mon Apr 23 13:03:31 CEST 2012
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.
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.
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).
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.
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.
I'm not entirely sure - maybe what you're looking for is what disnix is
about: http://nixos.org/disnix/
> Do you think it would be very difficult to extract the language from the nix
> source tree?
define "very difficult". 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".
Get nix code. its not that hard to get an overview.
Another nice keyword might be "chef":
https://github.com/opscode/chef
to find related work before spending huge amounts of time this.
You're welcome in any case :)
Marc Weber
More information about the nix-dev
mailing list