summary refs log tree commit diff
path: root/nixos/modules/config/sysctl.nix
diff options
context:
space:
mode:
authorRicardo M. Correia <rcorreia@wizy.org>2014-04-15 21:13:34 +0200
committerRicardo M. Correia <rcorreia@wizy.org>2014-04-15 21:52:04 +0200
commitd8b21c22245af2d6a6582df3290921ac5ca26235 (patch)
tree40bfe4918d39a1c076509d20a3592d4ae72e1ec1 /nixos/modules/config/sysctl.nix
parente572b5c10444b7bb5339260359349e1069df486d (diff)
downloadnixlib-d8b21c22245af2d6a6582df3290921ac5ca26235.tar
nixlib-d8b21c22245af2d6a6582df3290921ac5ca26235.tar.gz
nixlib-d8b21c22245af2d6a6582df3290921ac5ca26235.tar.bz2
nixlib-d8b21c22245af2d6a6582df3290921ac5ca26235.tar.lz
nixlib-d8b21c22245af2d6a6582df3290921ac5ca26235.tar.xz
nixlib-d8b21c22245af2d6a6582df3290921ac5ca26235.tar.zst
nixlib-d8b21c22245af2d6a6582df3290921ac5ca26235.zip
nixos: Fix sysctl option merging
Using pkgs.lib.mkOverride in a sysctl option would throw a bogus error.

Also, if you defined a sysctl multiple times in the same configuration,
only one of the values would be picked up, while the others were silently
discarded.

This patch should fix both issues. If you define a sysctl multiple
times at your highest defined priority level, you will get a proper
error with detailed location information.
Diffstat (limited to 'nixos/modules/config/sysctl.nix')
-rw-r--r--nixos/modules/config/sysctl.nix8
1 files changed, 6 insertions, 2 deletions
diff --git a/nixos/modules/config/sysctl.nix b/nixos/modules/config/sysctl.nix
index b4cd22caa79d..7f6c965b67cb 100644
--- a/nixos/modules/config/sysctl.nix
+++ b/nixos/modules/config/sysctl.nix
@@ -6,8 +6,12 @@ let
 
   sysctlOption = mkOptionType {
     name = "sysctl option value";
-    check = x: isBool x || isString x || isInt x || isNull x;
-    merge = args: defs: (last defs).value; # FIXME: hacky way to allow overriding in configuration.nix.
+    check = val:
+      let
+        checkType = x: isBool x || isString x || isInt x || isNull x;
+      in
+        checkType val || (val._type or "" == "override" && checkType val.content);
+    merge = loc: defs: mergeOneOption loc (filterOverrides defs);
   };
 
 in