Skip to content

Commit

Permalink
fix(lib): correctly map -bool values
Browse files Browse the repository at this point in the history
  • Loading branch information
z0al committed Dec 31, 2024
1 parent 8875878 commit d479bc7
Show file tree
Hide file tree
Showing 11 changed files with 29 additions and 27 deletions.
3 changes: 2 additions & 1 deletion lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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)}"
Expand Down
4 changes: 2 additions & 2 deletions targets/darwin.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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

{
Expand All @@ -12,7 +12,7 @@ in

system.activationScripts.postActivation.text = ''
echo "Activating plistManager"
echo "└── Using ${script}"
${script} || ${fail "Failed to run ${script}"}
'';
}
3 changes: 2 additions & 1 deletion targets/home-manager.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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

{
Expand All @@ -11,6 +11,7 @@ in
];

home.activation.plistManager = lib.hm.dag.entryAfter [ "writeBoundary" ] ''
echo "└── Using ${script}"
run ${script} || ${fail "Failed to run ${script}"}
'';
}
2 changes: 1 addition & 1 deletion tests/test-appearance.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
'';
}
12 changes: 6 additions & 6 deletions tests/test-desktop.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
'';
}
2 changes: 1 addition & 1 deletion tests/test-dock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down
6 changes: 3 additions & 3 deletions tests/test-finder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
'';
}
2 changes: 1 addition & 1 deletion tests/test-safari.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
};

test = ''
has "write 'com.apple.Safari.SandboxBroker' 'ShowDevelopMenu' -bool 1"
has "write 'com.apple.Safari.SandboxBroker' 'ShowDevelopMenu' -bool true"
'';
}
8 changes: 4 additions & 4 deletions tests/test-trackpad-double-tap-drag-lock.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
'';
Expand Down
4 changes: 2 additions & 2 deletions tests/test-trackpad-three-finger-drag.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
'';
}
10 changes: 5 additions & 5 deletions tests/test-trackpad.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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'"
Expand Down

0 comments on commit d479bc7

Please sign in to comment.