From d479bc71775c8950cd5765f444b31d47e3e77725 Mon Sep 17 00:00:00 2001 From: z0al <12673605+z0al@users.noreply.github.com> Date: Tue, 31 Dec 2024 15:23:42 +0000 Subject: [PATCH] fix(lib): correctly map `-bool` values --- lib/default.nix | 3 ++- targets/darwin.nix | 4 ++-- targets/home-manager.nix | 3 ++- tests/test-appearance.nix | 2 +- tests/test-desktop.nix | 12 ++++++------ tests/test-dock.nix | 2 +- tests/test-finder.nix | 6 +++--- tests/test-safari.nix | 2 +- tests/test-trackpad-double-tap-drag-lock.nix | 8 ++++---- tests/test-trackpad-three-finger-drag.nix | 4 ++-- tests/test-trackpad.nix | 10 +++++----- 11 files changed, 29 insertions(+), 27 deletions(-) diff --git a/lib/default.nix b/lib/default.nix index c0f679a..f2fb802 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -21,7 +21,8 @@ let quote = val: "'${lib.strings.escape [ "'" ] val}'"; in - if lib.isBool value then "-bool ${toString value}" + if value == true then "-bool true" + else if value == false then "-bool false" else if lib.isInt value then "-int ${toString value}" else if lib.isFloat value then "-float ${toString value}" else if lib.isString value then "-string ${quote (toString value)}" diff --git a/targets/darwin.nix b/targets/darwin.nix index 4e38651..fe18b2a 100644 --- a/targets/darwin.nix +++ b/targets/darwin.nix @@ -2,7 +2,7 @@ let script = pkgs.writeShellScript "plist-darwin-activate" config.plist.out; - fail = msg: "printf '\\033[0;31m${msg}\\033[0m\n' && exit 1"; + fail = msg: "(printf '\\033[0;31m${msg}\\033[0m\n' && exit 1)"; in { @@ -12,7 +12,7 @@ in system.activationScripts.postActivation.text = '' echo "Activating plistManager" - + echo "└── Using ${script}" ${script} || ${fail "Failed to run ${script}"} ''; } diff --git a/targets/home-manager.nix b/targets/home-manager.nix index 40d6e0e..350d5c1 100644 --- a/targets/home-manager.nix +++ b/targets/home-manager.nix @@ -2,7 +2,7 @@ let script = pkgs.writeShellScript "plist-home-activate" config.plist.out; - fail = msg: "printf '\\033[0;31m${msg}\\033[0m\n' && exit 1"; + fail = msg: "(printf '\\033[0;31m${msg}\\033[0m\n' && exit 1)"; in { @@ -11,6 +11,7 @@ in ]; home.activation.plistManager = lib.hm.dag.entryAfter [ "writeBoundary" ] '' + echo "└── Using ${script}" run ${script} || ${fail "Failed to run ${script}"} ''; } diff --git a/tests/test-appearance.nix b/tests/test-appearance.nix index 41538b7..28e212f 100644 --- a/tests/test-appearance.nix +++ b/tests/test-appearance.nix @@ -10,7 +10,7 @@ test = '' has "delete -g 'AppleInterfaceStyle'" - has "write -g 'AppleInterfaceStyleSwitchesAutomatically' -bool 1" + has "write -g 'AppleInterfaceStyleSwitchesAutomatically' -bool true" has "write -g 'AppleShowScrollBars' -string 'WhenScrolling'" ''; } diff --git a/tests/test-desktop.nix b/tests/test-desktop.nix index 9e4b010..70d57f7 100644 --- a/tests/test-desktop.nix +++ b/tests/test-desktop.nix @@ -13,11 +13,11 @@ }; test = '' - has "write 'com.apple.finder' 'CreateDesktop' -bool 1" - has "write 'com.apple.finder' 'ShowHardDrivesOnDesktop' -bool 1" - has "write 'com.apple.finder' 'ShowExternalHardDrivesOnDesktop' -bool 1" - has "write 'com.apple.finder' 'ShowRemovableMediaOnDesktop' -bool 1" - has "write 'com.apple.finder' '_FXSortFoldersFirstOnDesktop' -bool 1" - has "write 'com.apple.finder' 'ShowMountedServersOnDesktop' -bool 1" + has "write 'com.apple.finder' 'CreateDesktop' -bool true" + has "write 'com.apple.finder' 'ShowHardDrivesOnDesktop' -bool true" + has "write 'com.apple.finder' 'ShowExternalHardDrivesOnDesktop' -bool true" + has "write 'com.apple.finder' 'ShowRemovableMediaOnDesktop' -bool true" + has "write 'com.apple.finder' '_FXSortFoldersFirstOnDesktop' -bool true" + has "write 'com.apple.finder' 'ShowMountedServersOnDesktop' -bool true" ''; } diff --git a/tests/test-dock.nix b/tests/test-dock.nix index bd4d3e4..6e9ac6e 100644 --- a/tests/test-dock.nix +++ b/tests/test-dock.nix @@ -25,7 +25,7 @@ has "write 'com.apple.dock' 'orientation' -string 'left'" has "write 'com.apple.dock' 'tilesize' -int 24" has "write 'com.apple.dock' 'show-recents' -bool" - has "write 'com.apple.dock' 'autohide' -bool 1" + has "write 'com.apple.dock' 'autohide' -bool true" has "write 'com.apple.dock' 'autohide-delay' -float 0.500000" has "write 'com.apple.dock' 'autohide-time-modifier' -float 0.500000" has "write 'com.apple.dock' 'mineffect' -string 'scale'" diff --git a/tests/test-finder.nix b/tests/test-finder.nix index c54ee7b..f7c9bcc 100644 --- a/tests/test-finder.nix +++ b/tests/test-finder.nix @@ -10,8 +10,8 @@ }; test = '' - has "write -g 'AppleShowAllExtensions' -bool 1" - has "write 'com.apple.finder' 'AppleShowAllFiles' -bool 1" - has "write 'com.apple.finder' '_FXSortFoldersFirst' -bool 1" + has "write -g 'AppleShowAllExtensions' -bool true" + has "write 'com.apple.finder' 'AppleShowAllFiles' -bool true" + has "write 'com.apple.finder' '_FXSortFoldersFirst' -bool true" ''; } diff --git a/tests/test-safari.nix b/tests/test-safari.nix index f8f4f17..27e60e0 100644 --- a/tests/test-safari.nix +++ b/tests/test-safari.nix @@ -8,6 +8,6 @@ }; test = '' - has "write 'com.apple.Safari.SandboxBroker' 'ShowDevelopMenu' -bool 1" + has "write 'com.apple.Safari.SandboxBroker' 'ShowDevelopMenu' -bool true" ''; } diff --git a/tests/test-trackpad-double-tap-drag-lock.nix b/tests/test-trackpad-double-tap-drag-lock.nix index ece97b2..ceeb08c 100644 --- a/tests/test-trackpad-double-tap-drag-lock.nix +++ b/tests/test-trackpad-double-tap-drag-lock.nix @@ -8,10 +8,10 @@ }; test = '' - has "write 'com.apple.AppleMultitouchTrackpad' 'Dragging' -bool 1" - has "write 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'Dragging' -bool 1" - has "write 'com.apple.AppleMultitouchTrackpad' 'DragLock' -bool 1" - has "write 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'DragLock' -bool 1" + has "write 'com.apple.AppleMultitouchTrackpad' 'Dragging' -bool true" + has "write 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'Dragging' -bool true" + has "write 'com.apple.AppleMultitouchTrackpad' 'DragLock' -bool true" + has "write 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'DragLock' -bool true" has "delete 'com.apple.AppleMultitouchTrackpad' 'TrackpadThreeFingerDrag'" has "delete 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'TrackpadThreeFingerDrag'" ''; diff --git a/tests/test-trackpad-three-finger-drag.nix b/tests/test-trackpad-three-finger-drag.nix index 2405bee..4247150 100644 --- a/tests/test-trackpad-three-finger-drag.nix +++ b/tests/test-trackpad-three-finger-drag.nix @@ -12,7 +12,7 @@ has "delete 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'Dragging'" has "delete 'com.apple.AppleMultitouchTrackpad' 'DragLock'" has "delete 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'DragLock'" - has "write 'com.apple.AppleMultitouchTrackpad' 'TrackpadThreeFingerDrag' -bool 1" - has "write 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'TrackpadThreeFingerDrag' -bool 1" + has "write 'com.apple.AppleMultitouchTrackpad' 'TrackpadThreeFingerDrag' -bool true" + has "write 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'TrackpadThreeFingerDrag' -bool true" ''; } diff --git a/tests/test-trackpad.nix b/tests/test-trackpad.nix index 04482aa..3c84dec 100644 --- a/tests/test-trackpad.nix +++ b/tests/test-trackpad.nix @@ -12,13 +12,13 @@ test = '' has "write -g 'com.apple.trackpad.scaling' -int 2" - has "write 'com.apple.AppleMultitouchTrackpad' 'Clicking' -bool 1" - has "write 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'Clicking' -bool 1" - has "write -g 'com.apple.swipescrolldirection' -bool 1" + has "write 'com.apple.AppleMultitouchTrackpad' 'Clicking' -bool true" + has "write 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'Clicking' -bool true" + has "write -g 'com.apple.swipescrolldirection' -bool true" # dragging style: double-tap - has "write 'com.apple.AppleMultitouchTrackpad' 'Dragging' -bool 1" - has "write 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'Dragging' -bool 1" + has "write 'com.apple.AppleMultitouchTrackpad' 'Dragging' -bool true" + has "write 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'Dragging' -bool true" has "delete 'com.apple.AppleMultitouchTrackpad' 'DragLock'" has "delete 'com.apple.driver.AppleBluetoothMultitouch.trackpad' 'DragLock'" has "delete 'com.apple.AppleMultitouchTrackpad' 'TrackpadThreeFingerDrag'"