From dc25b5b227cfe0000230c31eb817f7da76747b06 Mon Sep 17 00:00:00 2001 From: Brian Zalewski <59970525+ProfessorManhattan@users.noreply.github.com> Date: Fri, 3 May 2024 04:07:06 +0000 Subject: [PATCH] Various macOS fixes --- .config/husky/prepare-commit-msg | 4 +- .../universal/run_before_02-homebrew.sh.tmpl | 7 ++ .../universal/run_before_05-system.sh.tmpl | 65 ++++++++++++------- home/.chezmoitemplates/darwin/Brewfile | 6 +- .../Preferences/com.apple.Terminal.plist | 8 ++- home/dot_config/pip/pip.conf | 2 + home/dot_config/shell/aliases.sh.tmpl | 2 +- home/dot_config/shell/macos.sh.tmpl | 4 +- local/provision.sh | 5 ++ scripts/cloudflared-ssh.sh | 5 ++ scripts/homebrew.sh | 5 ++ scripts/partials/basic-deps | 5 ++ scripts/provision.sh | 5 ++ software.yml | 10 +-- 14 files changed, 98 insertions(+), 35 deletions(-) create mode 100644 home/dot_config/pip/pip.conf diff --git a/.config/husky/prepare-commit-msg b/.config/husky/prepare-commit-msg index caee01ec..89822f5f 100755 --- a/.config/husky/prepare-commit-msg +++ b/.config/husky/prepare-commit-msg @@ -21,12 +21,12 @@ if [ -f "$(dirname "$0")/_/husky.sh" ]; then logger info 'This git hook is configured to run even when --no-verify is used. In order to bypass this prompt, use the -n flag instead.' logger info 'Opening a `git commit` dialog' if ! type pnpx > /dev/null && type npm > /dev/null; then - npm install -g pnpm + npm install --no-progress -g pnpm elif ! type pnpx > /dev/null; then logger error '`pnpm` or `npm` must be installed' fi if ! type git-cz &> /dev/null; then - pnpm install -g commitizen + pnpm install --no-progress -g commitizen fi exec < /dev/tty && (git-cz --hook || true) fi diff --git a/home/.chezmoiscripts/universal/run_before_02-homebrew.sh.tmpl b/home/.chezmoiscripts/universal/run_before_02-homebrew.sh.tmpl index 14bfd7f6..24c89ced 100644 --- a/home/.chezmoiscripts/universal/run_before_02-homebrew.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_before_02-homebrew.sh.tmpl @@ -146,6 +146,13 @@ upgradeDarwin() { export SUDO_PASSWORD fi + ### Ensure Rosetta 2 is installed + if /usr/bin/pgrep -q oahd; then + logg info 'Rosetta 2 is already installed' + else + logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license + fi + ### Run upgrade process logg info 'Checking for available OS upgrades' UPDATE_CHECK="$(softwareupdate -l 2>&1)" diff --git a/home/.chezmoiscripts/universal/run_before_05-system.sh.tmpl b/home/.chezmoiscripts/universal/run_before_05-system.sh.tmpl index 97279999..b2afb67a 100644 --- a/home/.chezmoiscripts/universal/run_before_05-system.sh.tmpl +++ b/home/.chezmoiscripts/universal/run_before_05-system.sh.tmpl @@ -504,7 +504,7 @@ installSystemPips() { if command -v pip3 > /dev/null; then if command -v python3 > /dev/null; then if ! python3 -m certifi > /dev/null; then - pip3 install certifi + pip3 install --break-system-packages certifi else logg info 'certifi is available to python3' fi @@ -664,7 +664,7 @@ installBrewPackages() { ensureBrewPackageInstalled "volta" volta install node@latest & volta install yarn@latest & - npm install -g npm@latest & + npm install --no-progress -g npm@latest & ensureBrewPackageInstalled "pipx" pipx ensurepath & ensureBrewPackageInstalled "gh" @@ -685,6 +685,8 @@ ensureMacportsInstalled() { logg info 'Cloning source for macports to /opt/mports/macports-base' && sudo git clone --branch v2.8.0 --depth 1 https://github.com/macports/macports-base.git /opt/mports/macports-base cd /opt/mports/macports-base logg info 'Building macports' && sudo bash --noprofile --norc -c './configure --enable-readline && make && make install && make distclean' + logg info 'Adding /opt/local/bin to PATH because port is installed there' + export PATH="/opt/local/bin:$PATH" logg info 'Running sudo port selfupdate' && sudo port selfupdate fi fi @@ -731,29 +733,31 @@ rustUpInit() { } zapInstall() { - if ! command -v zap > /dev/null; then - ### Architecture - if [ -z ${ARCH+x} ]; then - MACHINE_ARCH="$(uname -m)" - if [ "$MACHINE_ARCH" = "amd64" ]; then - ARCH="amd64" - elif [ "$MACHINE_ARCH" = "x86_64" ]; then - ARCH="amd64" - elif [ "$MACHINE_ARCH" = "i386" ]; then - ARCH="386" - elif [ "$MACHINE_ARCH" = "i686" ]; then - ARCH="386" # both are 32bit, should be compatible - elif [ "$MACHINE_ARCH" = "aarch64" ]; then - ARCH="arm64" - elif [ "$MACHINE_ARCH" = "arm64" ]; then - ARCH="arm64" - elif [ "$MACHINE_ARCH" = "arm" ]; then - ARCH="arm" - fi - export ARCH + if [ ! -d /Applications ] && [ ! -d /System ]; then + if ! command -v zap > /dev/null; then + ### Architecture + if [ -z ${ARCH+x} ]; then + MACHINE_ARCH="$(uname -m)" + if [ "$MACHINE_ARCH" = "amd64" ]; then + ARCH="amd64" + elif [ "$MACHINE_ARCH" = "x86_64" ]; then + ARCH="amd64" + elif [ "$MACHINE_ARCH" = "i386" ]; then + ARCH="386" + elif [ "$MACHINE_ARCH" = "i686" ]; then + ARCH="386" # both are 32bit, should be compatible + elif [ "$MACHINE_ARCH" = "aarch64" ]; then + ARCH="arm64" + elif [ "$MACHINE_ARCH" = "arm64" ]; then + ARCH="arm64" + elif [ "$MACHINE_ARCH" = "arm" ]; then + ARCH="arm" + fi + export ARCH + fi + logg info 'Downloading zap to /usr/local/bin/zap' && sudo curl -sSL --output /usr/local/bin/zap "https://github.com/srevinsaju/zap/releases/download/continuous/zap-${ARCH}" + logg info 'Making /usr/local/bin/zap executable' && sudo chmod +x /usr/local/bin/zap fi - logg info 'Downloading zap to /usr/local/bin/zap' && sudo curl -sSL --output /usr/local/bin/zap "https://github.com/srevinsaju/zap/releases/download/continuous/zap-${ARCH}" - logg info 'Making /usr/local/bin/zap executable' && sudo chmod +x /usr/local/bin/zap fi } @@ -763,6 +767,17 @@ addFlathub() { fi } +setupLinuxHomebrewFonts() { + if [ ! -d /Applications ] && [ ! -d /System ]; then + logg info 'Tapping homebrew/linux-fonts' && brew tap homebrew/linux-fonts + logg info 'Symlinking linuxbrew/share/fonts to /usr/local/share' && sudo ln -s /home/linuxbrew/.linuxbrew/share/fonts -t /usr/local/share + if command -v fc-cache > /dev/null; then + logg info 'Running sudo fc-cache -fv' && sudo fc-cache -fv + else + logg warn 'fc-cache binary not available for setting up Linux Homebrew fonts' + fi +} + # TODO - Add install on macOS for macports if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then logg info 'The DEBUG or DEBUG_MODE environment variable is set so preliminary system tweaks will be run synchronously' @@ -787,6 +802,7 @@ if [ -n "$DEBUG" ] || [ -n "$DEBUG_MODE" ]; then setupSnap showNotificationCenter zapInstall + setupLinuxHomebrewFonts else addFlathub & allocateSwap & @@ -809,6 +825,7 @@ else setupSnap & showNotificationCenter & zapInstall & + setupLinuxHomebrewFonts & wait fi diff --git a/home/.chezmoitemplates/darwin/Brewfile b/home/.chezmoitemplates/darwin/Brewfile index 0b60dea2..b2cdee69 100644 --- a/home/.chezmoitemplates/darwin/Brewfile +++ b/home/.chezmoitemplates/darwin/Brewfile @@ -4,6 +4,9 @@ # Standard Homebrew taps tap "homebrew/cask-versions" # Initially added to support "visual-studio" cask tap "homebrew/bundle" +tap "homebrew/autoupdate" +tap "homebrew/services" +tap "homebrew/cask-fonts" if OS.mac? brew "coreutils" @@ -27,6 +30,7 @@ brew "jq" brew "moreutils" brew "node" brew "openssh" +brew "pinentry-mac" brew "pipx" brew "pkg-config" brew "progress" @@ -41,5 +45,5 @@ brew "yarn" brew "yq" brew "zx" cask "docker" -cask "java" unless system "/usr/libexec/java_home --failfast" +cask "java@beta" unless system "/usr/libexec/java_home --failfast" cask "macfuse" diff --git a/home/Library/Preferences/com.apple.Terminal.plist b/home/Library/Preferences/com.apple.Terminal.plist index ec8ccf96..c7fa3868 100644 --- a/home/Library/Preferences/com.apple.Terminal.plist +++ b/home/Library/Preferences/com.apple.Terminal.plist @@ -63,9 +63,15 @@ ProfileCurrentVersion 2.0699999999999998 SecureKeyboardEntry - + + ShowLineMarks + 0 Startup Window Settings Betelgeuse + StringEncodings + + 4 + TTAppPreferences Selected Tab 1 Window Settings diff --git a/home/dot_config/pip/pip.conf b/home/dot_config/pip/pip.conf new file mode 100644 index 00000000..9d54ef90 --- /dev/null +++ b/home/dot_config/pip/pip.conf @@ -0,0 +1,2 @@ +[global] +break-system-packages = true diff --git a/home/dot_config/shell/aliases.sh.tmpl b/home/dot_config/shell/aliases.sh.tmpl index 0c5413c4..af1766ae 100644 --- a/home/dot_config/shell/aliases.sh.tmpl +++ b/home/dot_config/shell/aliases.sh.tmpl @@ -17,7 +17,7 @@ fi # Basic command aliases for verbosity / simplicity alias cp='cp -v' -alias ln='ln -sriv' +# alias ln='ln -sriv' # ln: illegal option -- r alias mv='mv -vi' alias rm='rm -vi' diff --git a/home/dot_config/shell/macos.sh.tmpl b/home/dot_config/shell/macos.sh.tmpl index 47474fbc..afaf9b02 100644 --- a/home/dot_config/shell/macos.sh.tmpl +++ b/home/dot_config/shell/macos.sh.tmpl @@ -429,7 +429,9 @@ defaults write com.apple.dock show-recents -bool false #defaults write com.apple.dock showLaunchpadGestureEnabled -int 0 # Reset Launchpad, but keep the desktop wallpaper intact -find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete +if [ -d "${HOME}/Library/Application Support/Dock" ]; then + find "${HOME}/Library/Application Support/Dock" -name "*-*.db" -maxdepth 1 -delete +fi # Add iOS & Watch Simulator to Launchpad sudo ln -sf "/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app" "/Applications/Simulator.app" diff --git a/local/provision.sh b/local/provision.sh index a7f5a5c0..93ef46d9 100644 --- a/local/provision.sh +++ b/local/provision.sh @@ -188,6 +188,11 @@ ensureBasicDeps() { XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')" logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG" fi + if /usr/bin/pgrep -q oahd; then + logg info 'Rosetta 2 is already installed' + else + logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license + fi elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then ### Windows logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync diff --git a/scripts/cloudflared-ssh.sh b/scripts/cloudflared-ssh.sh index 9bfe0e01..e43489de 100644 --- a/scripts/cloudflared-ssh.sh +++ b/scripts/cloudflared-ssh.sh @@ -155,6 +155,11 @@ ensureBasicDeps() { XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')" logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG" fi + if /usr/bin/pgrep -q oahd; then + logg info 'Rosetta 2 is already installed' + else + logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license + fi elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then ### Windows logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync diff --git a/scripts/homebrew.sh b/scripts/homebrew.sh index 1a9f6806..c5db02dd 100644 --- a/scripts/homebrew.sh +++ b/scripts/homebrew.sh @@ -124,6 +124,11 @@ ensureBasicDeps() { XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')" logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG" fi + if /usr/bin/pgrep -q oahd; then + logg info 'Rosetta 2 is already installed' + else + logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license + fi elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then ### Windows logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync diff --git a/scripts/partials/basic-deps b/scripts/partials/basic-deps index 42cd29f6..5f8fd8be 100644 --- a/scripts/partials/basic-deps +++ b/scripts/partials/basic-deps @@ -38,6 +38,11 @@ ensureBasicDeps() { XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')" logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG" fi + if /usr/bin/pgrep -q oahd; then + logg info 'Rosetta 2 is already installed' + else + logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license + fi elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then ### Windows logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync diff --git a/scripts/provision.sh b/scripts/provision.sh index 77b4120a..03c842e0 100644 --- a/scripts/provision.sh +++ b/scripts/provision.sh @@ -188,6 +188,11 @@ ensureBasicDeps() { XCODE_PKG="$(softwareupdate -l | grep "\*.*Command Line" | tail -n 1 | sed 's/^[^C]* //')" logg info "Installing from softwareupdate" && softwareupdate -i "$XCODE_PKG" && logg success "Successfully installed $XCODE_PKG" fi + if /usr/bin/pgrep -q oahd; then + logg info 'Rosetta 2 is already installed' + else + logg info 'Ensuring Rosetta 2 is installed' && softwareupdate --install-rosetta --agree-to-license + fi elif [[ "$OSTYPE" == 'cygwin' ]] || [[ "$OSTYPE" == 'msys' ]] || [[ "$OSTYPE" == 'win32' ]]; then ### Windows logg info 'Running choco install -y curl expect git moreutils rsync' && choco install -y curl expect git moreutils rsync diff --git a/software.yml b/software.yml index 7f6a6e10..83e7d77e 100644 --- a/software.yml +++ b/software.yml @@ -12619,7 +12619,7 @@ softwarePackages: else logg info 'Installing Tabby plugins defined in '"${XDG_CONFIG_HOME:-$HOME/.config}/tabby/plugins/package.json"'' cd "${XDG_CONFIG_HOME:-$HOME/.config}/tabby/plugins" - npm install --quiet + npm install --quiet --no-progress logg success 'Finished installing Tabby plugins' fi else @@ -13558,8 +13558,8 @@ softwarePackages: # which should correlate to the Coc extensions defined in `${XDG_CONFIG_HOME:-$HOME/.config}/vim/vimrc`. installCocExtensions() { if [ -f "${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions/package.json" ]; then - logg info "Running npm i --no-package-lock in ${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions" - cd "${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions" && npm i --no-package-lock + logg info "Running npm i --no-progress --no-package-lock in ${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions" + cd "${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions" && npm i --no-progress --no-package-lock logg info "Running vim +CocUpdateSync +qall" && vim +CocUpdateSync +qall else logg info "Skipping Coc extension installation because ${XDG_CONFIG_HOME:-$HOME/.config}/coc/extensions/package.json is missing" @@ -13980,12 +13980,12 @@ softwarePackages: if sudo cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/vscode/package.json" /package.json; then logg info 'Successfully copied linter fallback configurations package.json to /package.json' logg info 'Installing system root directory node_modules' - cd / && sudo npm i --quiet --no-package-lock || EXIT_CODE=$? + cd / && sudo npm i --quiet --no-progress --no-package-lock || EXIT_CODE=$? else logg warn 'Unable to successfully copy linter fallback configurations package.json to /package.json' logg info 'Installing linter fallback configurations node_modules to home directory instead' cp -f "${XDG_DATA_HOME:-$HOME/.local/share}/vscode/package.json" "$HOME/package.json" - cd ~ && npm i --quiet --no-package-lock || EXIT_CODE=$? + cd ~ && npm i --quiet --no-progress --no-package-lock || EXIT_CODE=$? fi ### Log message if install failed if [ -n "$EXIT_CODE" ]; then