diff options
| author | Dylan Frankland <dfrankland@users.noreply.github.com> | 2023-10-10 23:10:58 -0700 |
|---|---|---|
| committer | Dylan Frankland <dfrankland@users.noreply.github.com> | 2024-03-02 22:29:56 -0800 |
| commit | b620e32a761ef6376c1097e73b3f8283604e4982 (patch) | |
| tree | c2fcc9b112497f8750eea1a2ace73482c05a769c /modules/system | |
| parent | 8a15cb36fffa0b5fbe31ef16ede0a479bef4b365 (diff) | |
fix writing values with containers
Complex container values like `-array` have their own DSL which does not
allow specifying all data types. Instead of using the DSL use plist
fragments instead.
Diffstat (limited to 'modules/system')
| -rw-r--r-- | modules/system/defaults-write.nix | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/modules/system/defaults-write.nix b/modules/system/defaults-write.nix index 2e56d74..7e1fc44 100644 --- a/modules/system/defaults-write.nix +++ b/modules/system/defaults-write.nix @@ -5,18 +5,8 @@ with lib; let cfg = config.system.defaults; - 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 ${strings.floatToString value}" else - if isString value then "-string '${value}'" else - if isList value then "-array ${concatStringsSep " " (map (v: writeValue v)value)}" else - throw "invalid value type"; - writeDefault = domain: key: value: - "defaults write ${domain} '${key}' ${writeValue value}"; + "defaults write ${domain} '${key}' $'${strings.escape [ "'" ] (generators.toPlist { } value)}'"; defaultsToList = domain: attrs: mapAttrsToList (writeDefault domain) (filterAttrs (n: v: v != null) attrs); |
