diff options
| author | pjan vandaele <pjan.vandaele@gmail.com> | 2017-12-31 11:44:02 +0900 |
|---|---|---|
| committer | pjan vandaele <pjan.vandaele@gmail.com> | 2017-12-31 12:15:22 +0900 |
| commit | d7e67ce030e6b7ec41f5f3beb011992c698984e2 (patch) | |
| tree | bb4d92579ab82f238f4326067edf7a1cd8abc338 /modules | |
| parent | 6aec3fbb50b3c44af0899858d35fcafeb443ffb9 (diff) | |
float type
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/system/defaults-write.nix | 4 | ||||
| -rw-r--r-- | modules/system/defaults/dock.nix | 33 |
2 files changed, 20 insertions, 17 deletions
diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix index cf0a10a..d69a2c3 100644 --- a/modules/system/defaults-write.nix +++ b/modules/system/defaults-write.nix @@ -6,13 +6,15 @@ let cfg = config.system.defaults; + isFloat = x: isString x && builtins.match "^[+-]?([1-9]*[.])?[0-9]+$" x != null; + boolValue = x: if x then "YES" else "NO"; writeValue = value: if isBool value then "-bool ${boolValue value}" else if isInt value then "-int ${toString value}" else + if isFloat value then "-float ${toString value}" else if isString value then "-string '${value}'" else - if isAttrs value then "-${value.type} '${value.value}'" else throw "invalid value type"; writeDefault = domain: key: value: diff --git a/modules/system/defaults/dock.nix b/modules/system/defaults/dock.nix index 1fd97c3..378d703 100644 --- a/modules/system/defaults/dock.nix +++ b/modules/system/defaults/dock.nix @@ -2,7 +2,17 @@ with lib; -{ +let + isFloat = x: isString x && builtins.match "^[+-]?([0-9]*[.])?[0-9]+$" x != null; + + float = mkOptionType { + name = "float"; + description = "float"; + check = isFloat; + merge = options.mergeOneOption; + }; + +in { options = { system.defaults.dock.autohide = mkOption { @@ -14,24 +24,18 @@ with lib; }; system.defaults.dock.autohide-delay = mkOption { - type = types.nullOr types.attrs; + type = types.nullOr float; default = null; - example = { - type = "float"; - value = "0.24"; - }; + example = "0.24"; description = '' Sets the speed of the autohide delay. The default is given in the example. ''; }; system.defaults.dock.autohide-time-modifier = mkOption { - type = types.nullOr types.attrs; + type = types.nullOr float; default = null; - example = { - type = "float"; - value = "1.0"; - }; + example = "1.0"; description = '' Sets the speed of the animation when hiding/showing the Dock. The default is given in the example. ''; @@ -54,12 +58,9 @@ with lib; }; system.defaults.dock.expose-animation-duration = mkOption { - type = types.nullOr types.attrs; + type = types.nullOr float; default = null; - example = { - type = "float"; - value = "1.0"; - }; + example = "1.0"; description = '' Sets the speed of the Mission Control animations. The default is given in the example. ''; |
