···956956 use = id;
957957 };
958958959959+ /* mkDerivedConfig : Option a -> (a -> Definition b) -> Definition b
960960+961961+ Create config definitions with the same priority as the definition of another option.
962962+ This should be used for option definitions where one option sets the value of another as a convenience.
963963+ For instance a config file could be set with a `text` or `source` option, where text translates to a `source`
964964+ value using `mkDerivedConfig options.text (pkgs.writeText "filename.conf")`.
965965+966966+ It takes care of setting the right priority using `mkOverride`.
967967+ */
968968+ # TODO: make the module system error message include information about `opt` in
969969+ # error messages about conflicts. E.g. introduce a variation of `mkOverride` which
970970+ # adds extra location context to the definition object. This will allow context to be added
971971+ # to all messages that report option locations "this value was derived from <full option name>
972972+ # which was defined in <locations>". It can provide a trace of options that contributed
973973+ # to definitions.
974974+ mkDerivedConfig = opt: f:
975975+ mkOverride
976976+ (opt.highestPrio or defaultPriority)
977977+ (f opt.value);
978978+959979 doRename = { from, to, visible, warn, use, withPriority ? true }:
960980 { config, options, ... }:
961981 let
···13001300 </listitem>
13011301 <listitem>
13021302 <para>
13031303+ <literal>nix.daemonNiceLevel</literal> and
13041304+ <literal>nix.daemonIONiceLevel</literal> have been removed in
13051305+ favour of the new options
13061306+ <link xlink:href="options.html#opt-nix.daemonCPUSchedPolicy"><literal>nix.daemonCPUSchedPolicy</literal></link>,
13071307+ <link xlink:href="options.html#opt-nix.daemonIOSchedClass"><literal>nix.daemonIOSchedClass</literal></link>
13081308+ and
13091309+ <link xlink:href="options.html#opt-nix.daemonIOSchedPriority"><literal>nix.daemonIOSchedPriority</literal></link>.
13101310+ Please refer to the options documentation and the
13111311+ <literal>sched(7)</literal> and
13121312+ <literal>ioprio_set(2)</literal> man pages for guidance on how
13131313+ to use them.
13141314+ </para>
13151315+ </listitem>
13161316+ <listitem>
13171317+ <para>
13031318 The <literal>coursier</literal> package’s binary was renamed
13041319 from <literal>coursier</literal> to <literal>cs</literal>.
13051320 Completions which haven’t worked for a while should now work
+2
nixos/doc/manual/release-notes/rl-2111.section.md
···388388389389- `boot.kernelParams` now only accepts one command line parameter per string. This change is aimed to reduce common mistakes like "param = 12", which would be parsed as 3 parameters.
390390391391+- `nix.daemonNiceLevel` and `nix.daemonIONiceLevel` have been removed in favour of the new options [`nix.daemonCPUSchedPolicy`](options.html#opt-nix.daemonCPUSchedPolicy), [`nix.daemonIOSchedClass`](options.html#opt-nix.daemonIOSchedClass) and [`nix.daemonIOSchedPriority`](options.html#opt-nix.daemonIOSchedPriority). Please refer to the options documentation and the `sched(7)` and `ioprio_set(2)` man pages for guidance on how to use them.
392392+391393- The `coursier` package's binary was renamed from `coursier` to `cs`. Completions which haven't worked for a while should now work with the renamed binary. To keep using `coursier`, you can create a shell alias.
392394393395- The `services.mosquitto` module has been rewritten to support multiple listeners and per-listener configuration.
+41-23
nixos/modules/services/misc/nix-daemon.nix
···184184 '';
185185 };
186186187187- daemonNiceLevel = mkOption {
188188- type = types.int;
189189- default = 0;
187187+ daemonCPUSchedPolicy = mkOption {
188188+ type = types.enum ["other" "batch" "idle"];
189189+ default = "other";
190190+ example = "batch";
190191 description = ''
191191- Nix daemon process priority. This priority propagates to build processes.
192192- 0 is the default Unix process priority, 19 is the lowest. Note that nix
193193- bypasses nix-daemon when running as root and this option does not have
194194- any effect in such a case.
192192+ Nix daemon process CPU scheduling policy. This policy propagates to
193193+ build processes. other is the default scheduling policy for regular
194194+ tasks. The batch policy is similar to other, but optimised for
195195+ non-interactive tasks. idle is for extremely low-priority tasks
196196+ that should only be run when no other task requires CPU time.
197197+198198+ Please note that while using the idle policy may greatly improve
199199+ responsiveness of a system performing expensive builds, it may also
200200+ slow down and potentially starve crucial configuration updates
201201+ during load.
202202+ '';
203203+ };
204204+205205+ daemonIOSchedClass = mkOption {
206206+ type = types.enum ["best-effort" "idle"];
207207+ default = "best-effort";
208208+ example = "idle";
209209+ description = ''
210210+ Nix daemon process I/O scheduling class. This class propagates to
211211+ build processes. best-effort is the default class for regular tasks.
212212+ The idle class is for extremely low-priority tasks that should only
213213+ perform I/O when no other task does.
195214196196- Please note that if used on a recent Linux kernel with group scheduling,
197197- setting the nice level will only have an effect relative to other threads
198198- in the same task group. Therefore this option is only useful if
199199- autogrouping has been disabled (see the kernel.sched_autogroup_enabled
200200- sysctl) and no systemd unit uses any of the per-service CPU accounting
201201- features of systemd. Otherwise the Nix daemon process may be placed in a
202202- separate task group and the nice level setting will have no effect.
203203- Refer to the man pages sched(7) and systemd.resource-control(5) for
204204- details.
205205- '';
215215+ Please note that while using the idle scheduling class can improve
216216+ responsiveness of a system performing expensive builds, it might also
217217+ slow down or starve crucial configuration updates during load.
218218+ '';
206219 };
207220208208- daemonIONiceLevel = mkOption {
221221+ daemonIOSchedPriority = mkOption {
209222 type = types.int;
210223 default = 0;
224224+ example = 1;
211225 description = ''
212212- Nix daemon process I/O priority. This priority propagates to build processes.
213213- 0 is the default Unix process I/O priority, 7 is the lowest.
214214- '';
226226+ Nix daemon process I/O scheduling priority. This priority propagates
227227+ to build processes. The supported priorities depend on the
228228+ scheduling policy: With idle, priorities are not used in scheduling
229229+ decisions. best-effort supports values in the range 0 (high) to 7
230230+ (low).
231231+ '';
215232 };
216233217234 buildMachines = mkOption {
···587604 unitConfig.RequiresMountsFor = "/nix/store";
588605589606 serviceConfig =
590590- { Nice = cfg.daemonNiceLevel;
591591- IOSchedulingPriority = cfg.daemonIONiceLevel;
607607+ { CPUSchedulingPolicy = cfg.daemonCPUSchedPolicy;
608608+ IOSchedulingClass = cfg.daemonIOSchedClass;
609609+ IOSchedulingPriority = cfg.daemonIOSchedPriority;
592610 LimitNOFILE = 4096;
593611 };
594612