[Nix-dev] How to convert non string options to documentation String ?

Marc Weber marco-oweber at gmx.de
Mon Mar 9 11:42:44 CET 2009


I'm working now on a more modular boot system. The boot system itself doesn't change.
The way you select the boot way changes.
Eg config.boot.ways.grub can't be serialzied to a documentation string because it
is a pointer to a script generating the boot menu and installing grub if you've
asked nixos to do so.

Another new boot way will be config.boot.ways.vSserver. See description below.

    bootWays = mkOption {
        default = [config.boot.ways.grub];
        # proposal: use somehting like this instead:
        # default = mkDocumentedVal [config.boot.ways.grub] "[config.boot.ways.grub]"
        description = "
          A list of ways to boot the system which should be created.
          <literal>[config.boot.ways.grub]</literal> installs the grub system and generates the grub menu.
          <literal>[config.boot.ways.sbinInit]</literal> creates a series of /sbin/init{,-1,2-,3-,-4} files
            you can use to make nixos boot within vservers. You switch back to previous generation
            shoutdown to repair mode and replace /sbin/init by /sbin/init-10 or such.
            This second has to be implemented (TODO)
        ";
      };

However we need a way to define a user readable descrription of that default..
One generic way to do this would be adding an indirection:

mkDocumentedVal = val ; documentation : {
  inherit val documentation;
  _type = "documented_val";
}
  
valFromDocumentedVal = x :
  if typeOf x == "documented_val"
    then x.val
    else x

or such. I think you get the idea.
Is there already a another (maybe easier solution?)

Sincerly
Marc Weber



More information about the nix-dev mailing list