1
0
Fork 0
mirror of https://github.com/LnL7/nix-darwin.git synced 2025-03-30 19:54:43 +00:00

float type

This commit is contained in:
pjan vandaele 2017-12-31 11:44:02 +09:00
parent 6aec3fbb50
commit d7e67ce030
2 changed files with 20 additions and 17 deletions

View file

@ -6,13 +6,15 @@ let
cfg = config.system.defaults; cfg = config.system.defaults;
isFloat = x: isString x && builtins.match "^[+-]?([1-9]*[.])?[0-9]+$" x != null;
boolValue = x: if x then "YES" else "NO"; boolValue = x: if x then "YES" else "NO";
writeValue = value: writeValue = value:
if isBool value then "-bool ${boolValue value}" else if isBool value then "-bool ${boolValue value}" else
if isInt value then "-int ${toString 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 isString value then "-string '${value}'" else
if isAttrs value then "-${value.type} '${value.value}'" else
throw "invalid value type"; throw "invalid value type";
writeDefault = domain: key: value: writeDefault = domain: key: value:

View file

@ -2,7 +2,17 @@
with lib; 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 = { options = {
system.defaults.dock.autohide = mkOption { system.defaults.dock.autohide = mkOption {
@ -14,24 +24,18 @@ with lib;
}; };
system.defaults.dock.autohide-delay = mkOption { system.defaults.dock.autohide-delay = mkOption {
type = types.nullOr types.attrs; type = types.nullOr float;
default = null; default = null;
example = { example = "0.24";
type = "float";
value = "0.24";
};
description = '' description = ''
Sets the speed of the autohide delay. The default is given in the example. Sets the speed of the autohide delay. The default is given in the example.
''; '';
}; };
system.defaults.dock.autohide-time-modifier = mkOption { system.defaults.dock.autohide-time-modifier = mkOption {
type = types.nullOr types.attrs; type = types.nullOr float;
default = null; default = null;
example = { example = "1.0";
type = "float";
value = "1.0";
};
description = '' description = ''
Sets the speed of the animation when hiding/showing the Dock. The default is given in the example. 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 { system.defaults.dock.expose-animation-duration = mkOption {
type = types.nullOr types.attrs; type = types.nullOr float;
default = null; default = null;
example = { example = "1.0";
type = "float";
value = "1.0";
};
description = '' description = ''
Sets the speed of the Mission Control animations. The default is given in the example. Sets the speed of the Mission Control animations. The default is given in the example.
''; '';