[Nix-dev] [disnix] per-host configuration file generation

Kamil Klimkiewicz miglanz at gmail.com
Thu Mar 31 00:25:24 CEST 2011


Hi guys,

I found out about Nix/NixOS/Disnix a couple of days ago, by accident. I
have to say it's a great piece of software. It was a little tricky to
grasp the whole expression language (especially given I last used any
functional language 5+ years ago) at first, but now I think I'm slowly
getting used to it.

Anyway, I have one question about disnix. I'm trying to use it for
deployment of Django application (together with all dependent services -
PostgreSQL, pgpool, nginx, gunicorn WSGI server, etc.). The whole thing
will sit on Ubuntu server(s) - for various reasons. Everything looks
great so far.

But I got into a little problem. Let's say I have a nginx service that
sits on single machine and django/gunicorn/pgpool service that sits on a
couple of machines. How would you go about providing configuration file
for pgpool service that depends on the machine this service is running
on? Let's say I want the pgpool service to use different ports on
particular servers. My current ideas are:
- Generate configuration files for each machine in advance using pgpool
  service Nix expression - I simply store files named
  pgpool-machine1.conf, pgpool-machine2.conf, etc. in the pgpool's nix
  store. This has one major drawback - whenever I change configuration
  for single machine I have to distribute the service to all pgpool
  machines and possibly it will restart pgpool services on all machines.
- Generate configuration files in service activation script - this
  doesn't look too nix-y in my opinion.
- Create separate "subservice" for each machine.

How would you resolve this issue? What I have in mind is some kind of
map that takes a service generator function and a list of machines, but
I don't see a way to make it work. Any ideas?

-- 
Best regards,
Kamil Klimkiewicz



More information about the nix-dev mailing list