[Nix-dev] Hi nix developers!

Nicolas Pierron nicolas.b.pierron at gmail.com
Sat Apr 4 23:28:49 CEST 2009


On Sat, Apr 4, 2009 at 21:49, Marc Weber <marco-oweber at gmx.de> wrote:
>> (IMO) This way of writing is a bit annoying and we should probably
>> look at removing the "extra***" options by replacing the default
>> kernel parameters by extra options with default values.
>
> I don't think I got how it should look like. Do you think about this
> design:
>
>  boot = {
>   defaultKernelParams = mkOption {
>    ...
>   }
>
>   kernelParams = mkOption {
>    description = "
>      add additional custom kernel parameters
>    ";
>
>    mergeFun = listMerge;
>   };
>
> ... in ..
>
> { ..
>  kernelParams = cfg.defaultKernelParams; # add default kernel params to
>
> }

or

  kernelParams = mkOption {
   default = config.boot.defaultKernelParams;
   description = "
     add additional custom kernel parameters
   ";
   ...
  };

>
> Did I get your intention right? (the extra* is gone for the default user setup)

No.  I was thinking at something like:

{config, ...}:
{
  system = {
    acpi = mkOption {
      default = true;
      description "...";
    };
  };

  boot = {
    kernelParams = mkIf config.system.acpi [
      "acpi=on"
    ];
  };
}

where there no duplication of options and only one which is defined by
other settings.  We may want to add more abstraction over default
settings.

Default settings do not scale because when you want to remove one
option you have to duplicate the list of default options, which
implies that you have to copy and paste and follow NixOS modifications
to keep your system stable.

For development issue, I would prefer to have no extra prefix in front
of the name.  So we should always use config.kernelParams and never
have to concatenates the two lists in some weird locations inside the
code. (expect one)  To tackle this issue I recommend to do the
following:

  kernelParams = mkOption {
    default = [
      # non-empty list
    ];
    ...
    apply = l: l ++ config.boot.extraKernelParams;
  };

  extraKernelParams = mkOption {
    ...
    merge = ...;
  };

which implies that all references to config.boot.kernelParams will
already contains all kernel parameters (which is the meaning of the
option).

This scheme should progressively be removed by removing each element
contained inside the default value of kernelParams.  When the default
value will be an empty list, then the extraKernelParams will be a
useless extension which should be made obsolete before being removed.
Making it obsolete should be useful to warn everybody to replace each
reference of extraKernelParams by kernelParams.

The defaultKernelParams does not give any advantage compare to the
current scheme except that this awful syntax can be removed faster
from user view which are not overriding the default settings.

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron
- If you are doing something twice then you should try to do it once.



More information about the nix-dev mailing list