[Nix-dev] Re: [Nix-commits] SVN commit: nix - 18401 - raskin - nixos/trunk/modules/services/monitoring

Nicolas Pierron nicolas.b.pierron at gmail.com
Wed Nov 18 17:46:56 CET 2009


2009/11/18 Michael Raskin <7c6f434c at mail.ru>:
> Nicolas Pierron wrote:
>>> I was being stupid anyway (/etc entry). Does my next commit fix my mistake?
>>
>> Yes because you have put the mkIf on top of the "jobs" attribute, and
>> also because this avoid creating additional configuration files if you
>> don't enable on monit.
>
> I understood the second part on my own, that's why I made the commit. I
> tangentially understood the first part, and you clarified it well,
> thanks. I am just asking whether there are other catches
>

Except errors due to the strictness of isType functions, I am not aware of.

By the way you can remove the duplicated startOn & stopOn introduced
in your expression.  The is now possible because "jobs" contains
attribute sets.  Thus you have to named each job, and all definition
of jobs with the same name are merged.  So this functionnality is
similar to:

mkOverride 50 {
  jobs.monit.startOn = "...";
}

This have many advantage:
- This avoid duplication of options with identical definition.
- This keep job related content inside the "jobs" option.

even if:
- You force the user to be aware of the job name.

To inform the user, you can add such information in option
descriptions and you can ease such things by using mkDefaultValue on
top of the startOn & stopOn defined in your original nix expression

{
  config = mkIf cfg.enable {
    jobs.monit = {
      startOn = mkDefaultValue "...";
      ...
    };
  };
}

which allows the user to override your option definition without using
mkOverride in his own configuration.nix file:

{
  jobs.monit.startOn = "...";
}

-- 
Nicolas Pierron
http://www.linkedin.com/in/nicolasbpierron - http://nbp.name/
Donald Knuth - I can't go to a restaurant because I keep looking at
the fonts on the menu.



More information about the nix-dev mailing list