Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 19 additions & 8 deletions lib/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -310,30 +310,36 @@ rec {

in opt //
{ value = addErrorContext "while evaluating the option `${showOption loc}':" value;
inherit (res.defsFinal') highestPrio;
definitions = map (def: def.value) res.defsFinal;
files = map (def: def.file) res.defsFinal;
inherit (res) isDefined;
};

# Merge definitions of a value of a given type.
mergeDefinitions = loc: type: defs: rec {
defsFinal =
defsFinal' =
let
# Process mkMerge and mkIf properties.
defs' = concatMap (m:
map (value: { inherit (m) file; inherit value; }) (dischargeProperties m.value)
) defs;

# Process mkOverride properties.
defs'' = filterOverrides defs';
defs'' = filterOverrides' defs';

# Sort mkOrder properties.
defs''' =
# Avoid sorting if we don't have to.
if any (def: def.value._type or "" == "order") defs''
then sortProperties defs''
else defs'';
in defs''';
if any (def: def.value._type or "" == "order") defs''.values
then sortProperties defs''.values
else defs''.values;
in {
values = defs''';
inherit (defs'') highestPrio;
};

defsFinal = defsFinal'.values;

# Type-check the remaining definitions, and merge them.
mergedValue = foldl' (res: def:
Expand Down Expand Up @@ -416,13 +422,18 @@ rec {

Note that "z" has the default priority 100.
*/
filterOverrides = defs:
filterOverrides = defs: (filterOverrides' defs).values;

filterOverrides' = defs:
let
defaultPrio = 100;
getPrio = def: if def.value._type or "" == "override" then def.value.priority else defaultPrio;
highestPrio = foldl' (prio: def: min (getPrio def) prio) 9999 defs;
strip = def: if def.value._type or "" == "override" then def // { value = def.value.content; } else def;
in concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
in {
values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
inherit highestPrio;
};

/* Sort a list of properties. The sort priority of a property is
1000 by default, but can be overridden by wrapping the property
Expand Down
3 changes: 3 additions & 0 deletions nixos/doc/manual/release-notes/rl-1803.xml
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,9 @@ following incompatible changes:</para>
For <literal>stateVersion = "17.09"</literal> or lower the old behavior is preserved.
</para>
<itemizedlist>
<listitem>
<literal>sound.enable</literal> now defaults to false.
</listitem>
<listitem>
<para>
<literal>matrix-synapse</literal> uses postgresql by default instead of sqlite.
Expand Down
3 changes: 3 additions & 0 deletions nixos/modules/installer/tools/nixos-generate-config.pl
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,9 @@ sub multiLineList {
# Enable CUPS to print documents.
# services.printing.enable = true;

# Enable sound.
# sound.enable = true;

# Enable the X11 windowing system.
# services.xserver.enable = true;
# services.xserver.layout = "us";
Expand Down
7 changes: 6 additions & 1 deletion nixos/modules/misc/version.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ config, lib, pkgs, ... }:
{ options, config, lib, pkgs, ... }:

with lib;

Expand Down Expand Up @@ -78,6 +78,11 @@ in

config = {

warnings = lib.optional (options.system.stateVersion.highestPrio == 1001) ''
You don't have `system.stateVersion` explicitly set. Expect things to break.
See release notes and grep for "stateVersion" in `nixpkgs/nixos` tree.
'';

system.nixos = {
# These defaults are set here rather than up there so that
# changing them would not rebuild the manual
Expand Down
3 changes: 2 additions & 1 deletion nixos/modules/services/audio/alsa.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ in

enable = mkOption {
type = types.bool;
default = true;
default = !versionAtLeast config.system.stateVersion "18.03";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about this in combination with defaultText, but this might cause a rebuild of the NixOS manual. Have you checked that?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did not check that. But if does cause a rebuild

  • it doesn't really matter, as its just a single rebuild per release,
  • its a bug that can surely be fixed.

defaultText = "!versionAtLeast system.stateVersion \"18.03\"";
description = ''
Whether to enable ALSA sound.
'';
Expand Down