summaryrefslogtreecommitdiff
path: root/modules/system/defaults-write.nix
diff options
context:
space:
mode:
authorMalo Bourgon <mbourgon@gmail.com>2022-08-29 15:39:16 -0700
committerMalo Bourgon <mbourgon@gmail.com>2022-08-29 15:39:16 -0700
commit5fa362c32f7a20ee1fb4baf7f23dc5128da6affe (patch)
treefc666fb6e991a661b2e955c1454f7c53c74ecbbe /modules/system/defaults-write.nix
parent157a3c3c4ea482317a4eb4ea2c41db4f16c82420 (diff)
Transition to using native floats
Diffstat (limited to 'modules/system/defaults-write.nix')
-rw-r--r--modules/system/defaults-write.nix13
1 files changed, 10 insertions, 3 deletions
diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix
index 37e6760..8a6cb6e 100644
--- a/modules/system/defaults-write.nix
+++ b/modules/system/defaults-write.nix
@@ -5,14 +5,12 @@ with lib;
let
cfg = config.system.defaults;
- isFloat = x: isString x && builtins.match "^[+-]?([0-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 isFloat value then "-float ${strings.floatToString value}" else
if isString value then "-string '${value}'" else
throw "invalid value type";
@@ -48,6 +46,15 @@ in
{
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 [
alf
loginwindow