mirror of
https://github.com/LnL7/nix-darwin.git
synced 2024-09-11 12:49:18 +03:00
Transition to using native floats
This commit is contained in:
parent
157a3c3c4e
commit
5fa362c32f
@ -37,7 +37,7 @@ let
|
|||||||
if v == null then ""
|
if v == null then ""
|
||||||
else if isInt v then toString v
|
else if isInt v then toString v
|
||||||
else if isBool v then boolToString v
|
else if isBool v then boolToString v
|
||||||
else if isFloat v then floatToString v
|
else if isFloat v then strings.floatToString v
|
||||||
else if isList v then toString v
|
else if isList v then toString v
|
||||||
else if isDerivation v then toString v
|
else if isDerivation v then toString v
|
||||||
else if builtins.isPath v then toString v
|
else if builtins.isPath v then toString v
|
||||||
|
@ -5,14 +5,12 @@ with lib;
|
|||||||
let
|
let
|
||||||
cfg = config.system.defaults;
|
cfg = config.system.defaults;
|
||||||
|
|
||||||
isFloat = x: isString x && builtins.match "^[+-]?([0-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 isFloat value then "-float ${strings.floatToString value}" else
|
||||||
if isString value then "-string '${value}'" else
|
if isString value then "-string '${value}'" else
|
||||||
throw "invalid value type";
|
throw "invalid value type";
|
||||||
|
|
||||||
@ -48,6 +46,15 @@ in
|
|||||||
{
|
{
|
||||||
config = {
|
config = {
|
||||||
|
|
||||||
|
# Type used for `system.defaults.<domain>.*` options that previously accepted float values as a
|
||||||
|
# string.
|
||||||
|
lib.defaults.types.floatWithDeprecationError = types.float // {
|
||||||
|
check = x:
|
||||||
|
if isString x && builtins.match "^[+-]?([0-9]*[.])?[0-9]+$" x != null
|
||||||
|
then throw "Using strings for `system.defaults.<domain>.*' options of type float is no longer permitted, use native float values instead."
|
||||||
|
else types.float.check x;
|
||||||
|
};
|
||||||
|
|
||||||
system.activationScripts.defaults.text = mkIfAttrs [
|
system.activationScripts.defaults.text = mkIfAttrs [
|
||||||
alf
|
alf
|
||||||
loginwindow
|
loginwindow
|
||||||
|
@ -3,15 +3,8 @@
|
|||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
isFloat = x: isString x && builtins.match "^[+-]?([0-9]*[.])?[0-9]+$" x != null;
|
# Should only be used with options that previously used floats defined as strings.
|
||||||
|
inherit (config.lib.defaults.types) floatWithDeprecationError;
|
||||||
float = mkOptionType {
|
|
||||||
name = "float";
|
|
||||||
description = "float";
|
|
||||||
check = isFloat;
|
|
||||||
merge = options.mergeOneOption;
|
|
||||||
};
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
@ -208,9 +201,9 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
system.defaults.NSGlobalDomain.NSWindowResizeTime = mkOption {
|
system.defaults.NSGlobalDomain.NSWindowResizeTime = mkOption {
|
||||||
type = types.nullOr float;
|
type = types.nullOr floatWithDeprecationError;
|
||||||
default = null;
|
default = null;
|
||||||
example = "0.20";
|
example = 0.20;
|
||||||
description = ''
|
description = ''
|
||||||
Sets the speed speed of window resizing. The default is given in the example.
|
Sets the speed speed of window resizing. The default is given in the example.
|
||||||
'';
|
'';
|
||||||
@ -273,14 +266,16 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
system.defaults.NSGlobalDomain."com.apple.sound.beep.volume" = mkOption {
|
system.defaults.NSGlobalDomain."com.apple.sound.beep.volume" = mkOption {
|
||||||
type = types.nullOr float;
|
type = types.nullOr floatWithDeprecationError;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
# Apple menu > System Preferences > Sound
|
# Apple menu > System Preferences > Sound
|
||||||
Sets the beep/alert volume level from 0.000 (muted) to 1.000 (100% volume).
|
Sets the beep/alert volume level from 0.000 (muted) to 1.000 (100% volume).
|
||||||
|
|
||||||
75% = 0.7788008
|
75% = 0.7788008
|
||||||
|
|
||||||
50% = 0.6065307
|
50% = 0.6065307
|
||||||
|
|
||||||
25% = 0.4723665
|
25% = 0.4723665
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
@ -312,7 +307,7 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
system.defaults.NSGlobalDomain."com.apple.trackpad.scaling" = mkOption {
|
system.defaults.NSGlobalDomain."com.apple.trackpad.scaling" = mkOption {
|
||||||
type = types.nullOr float;
|
type = types.nullOr floatWithDeprecationError;
|
||||||
default = null;
|
default = null;
|
||||||
description = ''
|
description = ''
|
||||||
Configures the trackpad tracking speed (0 to 3). The default is "1".
|
Configures the trackpad tracking speed (0 to 3). The default is "1".
|
||||||
@ -328,9 +323,9 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
system.defaults.NSGlobalDomain."com.apple.springing.delay" = mkOption {
|
system.defaults.NSGlobalDomain."com.apple.springing.delay" = mkOption {
|
||||||
type = types.nullOr float;
|
type = types.nullOr floatWithDeprecationError;
|
||||||
default = null;
|
default = null;
|
||||||
example = "1.0";
|
example = 1.0;
|
||||||
description = ''
|
description = ''
|
||||||
Set the spring loading delay for directories. The default is given in the example.
|
Set the spring loading delay for directories. The default is given in the example.
|
||||||
'';
|
'';
|
||||||
|
@ -3,15 +3,8 @@
|
|||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
isFloat = x: isString x && builtins.match "^[+-]?([0-9]*[.])?[0-9]+$" x != null;
|
# Should only be used with options that previously used floats defined as strings.
|
||||||
|
inherit (config.lib.defaults.types) floatWithDeprecationError;
|
||||||
float = mkOptionType {
|
|
||||||
name = "float";
|
|
||||||
description = "float";
|
|
||||||
check = isFloat;
|
|
||||||
merge = options.mergeOneOption;
|
|
||||||
};
|
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
|
|
||||||
@ -32,18 +25,18 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
system.defaults.dock.autohide-delay = mkOption {
|
system.defaults.dock.autohide-delay = mkOption {
|
||||||
type = types.nullOr float;
|
type = types.nullOr floatWithDeprecationError;
|
||||||
default = null;
|
default = null;
|
||||||
example = "0.24";
|
example = 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 float;
|
type = types.nullOr floatWithDeprecationError;
|
||||||
default = null;
|
default = null;
|
||||||
example = "1.0";
|
example = 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.
|
||||||
'';
|
'';
|
||||||
@ -66,9 +59,9 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
system.defaults.dock.expose-animation-duration = mkOption {
|
system.defaults.dock.expose-animation-duration = mkOption {
|
||||||
type = types.nullOr float;
|
type = types.nullOr floatWithDeprecationError;
|
||||||
default = null;
|
default = null;
|
||||||
example = "1.0";
|
example = 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.
|
||||||
'';
|
'';
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
system.defaults.NSGlobalDomain.NSTextShowsControlCharacters = true;
|
system.defaults.NSGlobalDomain.NSTextShowsControlCharacters = true;
|
||||||
system.defaults.NSGlobalDomain.NSUseAnimatedFocusRing = false;
|
system.defaults.NSGlobalDomain.NSUseAnimatedFocusRing = false;
|
||||||
system.defaults.NSGlobalDomain.NSScrollAnimationEnabled = true;
|
system.defaults.NSGlobalDomain.NSScrollAnimationEnabled = true;
|
||||||
system.defaults.NSGlobalDomain.NSWindowResizeTime = "0.01";
|
system.defaults.NSGlobalDomain.NSWindowResizeTime = 0.01;
|
||||||
system.defaults.NSGlobalDomain.InitialKeyRepeat = 10;
|
system.defaults.NSGlobalDomain.InitialKeyRepeat = 10;
|
||||||
system.defaults.NSGlobalDomain.KeyRepeat = 1;
|
system.defaults.NSGlobalDomain.KeyRepeat = 1;
|
||||||
system.defaults.NSGlobalDomain.PMPrintingExpandedStateForPrint = true;
|
system.defaults.NSGlobalDomain.PMPrintingExpandedStateForPrint = true;
|
||||||
@ -33,11 +33,11 @@
|
|||||||
system.defaults.NSGlobalDomain."com.apple.trackpad.enableSecondaryClick" = true;
|
system.defaults.NSGlobalDomain."com.apple.trackpad.enableSecondaryClick" = true;
|
||||||
system.defaults.NSGlobalDomain."com.apple.trackpad.trackpadCornerClickBehavior" = 1;
|
system.defaults.NSGlobalDomain."com.apple.trackpad.trackpadCornerClickBehavior" = 1;
|
||||||
system.defaults.NSGlobalDomain."com.apple.springing.enabled" = true;
|
system.defaults.NSGlobalDomain."com.apple.springing.enabled" = true;
|
||||||
system.defaults.NSGlobalDomain."com.apple.springing.delay" = "0.0";
|
system.defaults.NSGlobalDomain."com.apple.springing.delay" = 0.0;
|
||||||
system.defaults.NSGlobalDomain."com.apple.swipescrolldirection" = true;
|
system.defaults.NSGlobalDomain."com.apple.swipescrolldirection" = true;
|
||||||
system.defaults.".GlobalPreferences"."com.apple.sound.beep.sound" = "/System/Library/Sounds/Funk.aiff";
|
system.defaults.".GlobalPreferences"."com.apple.sound.beep.sound" = "/System/Library/Sounds/Funk.aiff";
|
||||||
system.defaults.dock.appswitcher-all-displays = false;
|
system.defaults.dock.appswitcher-all-displays = false;
|
||||||
system.defaults.dock.autohide-delay = "0.24";
|
system.defaults.dock.autohide-delay = 0.24;
|
||||||
system.defaults.dock.orientation = "left";
|
system.defaults.dock.orientation = "left";
|
||||||
system.defaults.screencapture.location = "/tmp";
|
system.defaults.screencapture.location = "/tmp";
|
||||||
system.defaults.smb.NetBIOSName = "IMAC-000000";
|
system.defaults.smb.NetBIOSName = "IMAC-000000";
|
||||||
|
Loading…
Reference in New Issue
Block a user