[Nix-dev] Re: NixOS: Introduce sub-configurations

Ludovic Courtès ludo at gnu.org
Tue May 12 11:35:16 CEST 2009


Eelco Dolstra <e.dolstra at tudelft.nl>
writes:

>   hostName = mkOption {
>     default = "nixos";
>     type = tpString;
>     description = "
>       The name of the machine.  Leave it empty if you want to obtain
>       it from a DHCP server (if using DHCP).
>     ";
>   };

[...]

> Andres and I once had a project proposal for adding a type system to Nix, the
> main goal being that configuration user interfaces could be derived
> automatically from the types of functions.  It got rejected, unfortunately...

In the same vein, Emacs Lisp may be a good source of inspiration, with
things like:

--8<---------------cut here---------------start------------->8---
(defgroup gnus-article-washing nil
  "Special commands on articles."
  :link '(custom-manual "(gnus)Article Washing")
  :group 'gnus-article)

(defcustom gnus-article-x-face-too-ugly nil
  "Regexp matching posters whose face shouldn't be shown automatically."
  :type '(choice regexp (const nil))
  :group 'gnus-article-washing)
--8<---------------cut here---------------end--------------->8---

Here, `defgroup' roughly corresponds to the proposed `mkOptionSet',
i.e., it's used mostly for presentation purposes; `defcustom'
corresponds to `mkOption'.

The `:group' option allows the option hierarchy to be described, since
options are defined via individual `defcustom' as opposed to nested
`mkOption'/`mkOptionSet'.

Thanks,
Ludo'.




More information about the nix-dev mailing list