Skip to content

Commit

Permalink
fix: correctly enumerate available logical CPUs on darwin when switching
Browse files Browse the repository at this point in the history
  • Loading branch information
flexiondotorg committed Oct 2, 2024
1 parent 5a0443f commit ee6b4f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion darwin/_mixins/scripts/switch-host/switch-host.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env bash

if [ -e "${HOME}/Zero/nix-config" ]; then
all_cores=$(nproc)
all_cores=$(sysctl -n hw.logicalcpu)
build_cores=$(printf "%.0f" "$(echo "${all_cores} * 0.75" | bc)")
echo "Switch nix-darwin ❄️ with ${build_cores} cores"
nix run nix-darwin -- switch --flake "${HOME}/Zero/nix-config" --cores "${build_cores}" -L
Expand Down
5 changes: 4 additions & 1 deletion home-manager/_mixins/scripts/nh-home/nh-home.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ fi
# Proceed if the nix-config directory exists
if [ -e "${HOME}/Zero/nix-config" ]; then
# Get the number of processing units
all_cores=$(nproc)
case "$(uname -s)" in
Linux) all_cores=$(nproc);;
Darwin) all_cores=$(sysctl -n hw.logicalcpu);;
esac
# Calculate 75% of the number of processing units
build_cores=$(printf "%.0f" "$(echo "${all_cores} * 0.75" | bc)")

Expand Down

0 comments on commit ee6b4f1

Please sign in to comment.