[Nix-dev] throw and mkOption default attribute when building options docs

Nicolas Pierron nicolas.b.pierron at gmail.com
Mon Aug 18 16:56:32 CEST 2008


On Sun, Aug 17, 2008 at 10:57, Marc Weber <marco-oweber at gmx.de> wrote:
> Hi @ll,
>
> I've been hurt by the "you must specify the fileSystems option" or such
> message which is passed to abort if the default setting [] is not
> overridden by configuration.nix
> Now I'd like to use [] because the root filesystem is mounted
> automatically by the virtualizing software. So no need to do anything
> (but adding a customStage1 script)..
> My first attempt to fix it was allowing fileSystems = false.
> However this leads to bypassing some maps etc which is ugly.
>
> A much cleaner way would be allowing
> mkOption {
>  default = throw "you must set the xx option";
>  example = { ... };
>  description = "...";
> };
> Then you can use [], but you'll get still a fatal error if you rebuild
> nixos and don't specify the setting.
> But I fear that this makes documentation building fail as well, does it?
>
> We could catch this kind of error and show in documentation
> default: "no default value availible, this option must be set"
>
> How do you like this?

Hi Marc,

I don't know if what I am writing can help you but the merge attribute
that you can specify in mkOption argument set is used to pre-process
options even if there is only one element inside the list of elements
that have to be merged.  Default values are not pre-process (may be
this could be interpreted as a bad behaviour), so you can in some way
ensure that the user will redefine it by failing on a non-merged
value.

-- 
Nicolas Pierron
- If you are doing something twice then you should try to do it once.



More information about the nix-dev mailing list