From ce3a100015740e591fbb72e6aa271ce42d137f38 Mon Sep 17 00:00:00 2001 From: "max." Date: Sun, 16 Aug 2026 16:21:13 +0200 Subject: [PATCH] invite the neighbours (setup stargazer / kynet) if you think i'm running out of corny home commit messages, you're sorely mistaken --- .vscode/settings.json | 3 + bootstrap.just | 56 +++++---- bootstrap.sh | 29 +++++ .../run_once_05-install-paru.sh.tmpl | 17 +++ .../run_once_50-macos-defaults.sh.tmpl | 59 ---------- .../run_onchange_11-arch-packages.sh.tmpl | 13 +++ ...pl => run_onchange_11-brew-bundle.sh.tmpl} | 3 +- config/dot_config/paru/pkglist.txt | 1 + justfile | 18 ++- system.just | 109 ++++++++++++++++++ 10 files changed, 214 insertions(+), 94 deletions(-) create mode 100644 .vscode/settings.json create mode 100755 bootstrap.sh create mode 100644 config/.chezmoiscripts/run_once_05-install-paru.sh.tmpl delete mode 100644 config/.chezmoiscripts/run_once_50-macos-defaults.sh.tmpl create mode 100644 config/.chezmoiscripts/run_onchange_11-arch-packages.sh.tmpl rename config/.chezmoiscripts/{run_once_11-brew-bundle.sh.tmpl => run_onchange_11-brew-bundle.sh.tmpl} (53%) create mode 100644 config/dot_config/paru/pkglist.txt diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..205df23 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,3 @@ +{ + "git.enabled": false +} \ No newline at end of file diff --git a/bootstrap.just b/bootstrap.just index dd26a35..f497ff9 100644 --- a/bootstrap.just +++ b/bootstrap.just @@ -1,43 +1,39 @@ -[macos] -all: timezone pam-touchid login-shell rosetta - -[linux] -all: timezone login-shell +# single-use installers -[group("all")] [macos] -timezone: - sudo systemsetup -settimezone "Europe/Berlin" +all: brew bootstrap-pkgs rosetta -[group("all")] [linux] -timezone: - timedatectl set-timezone Europe/Berlin +all: bootstrap-pkgs paru -# sets login shell for the current user to fish -[group("all")] -login-shell: - #!/bin/sh - fish=$(which fish) - grep -qx "$fish" /etc/shells || echo "$fish" | sudo tee -a /etc/shells - [ "$SHELL" = "$fish" ] || chsh -s "$fish" - -[group("all")] [macos] -pam-touchid: +brew: #!/bin/sh - sudo tee /etc/pam.d/sudo_local >/dev/null <<'EOF' - auth optional /opt/homebrew/lib/pam/pam_reattach.so - auth sufficient pam_tid.so - EOF + if [ ! -x /opt/homebrew/bin/brew ]; then + NONINTERACTIVE=1 /bin/bash -c \ + "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" + fi -[group("all")] [macos] rosetta: softwareupdate --install-rosetta --agree-to-license -# enables remote access via ssh and disables auto sleep for the machine +[linux] +bootstrap-pkgs: + #!/bin/sh + sudo pacman -S --needed --noconfirm base-devel git coreutils fish chezmoi just + [macos] -darwin-server-settings: - sudo systemsetup -setremotelogin on - sudo pmset -a sleep 0 +bootstrap-pkgs: + #!/bin/sh + command -v brew >/dev/null || eval "$(/opt/homebrew/bin/brew shellenv)" + brew install --no-ask just chezmoi + +[linux] +paru: + #!/bin/sh + command -v paru >/dev/null && exit 0 + sudo pacman -S --needed --noconfirm base-devel git + tmp=$(mktemp -d) + git clone https://aur.archlinux.org/paru-bin.git "$tmp/paru-bin" + cd "$tmp/paru-bin" && makepkg -si --noconfirm diff --git a/bootstrap.sh b/bootstrap.sh new file mode 100755 index 0000000..13ffb66 --- /dev/null +++ b/bootstrap.sh @@ -0,0 +1,29 @@ +#!/bin/sh + +# bootstrap my dotfiles: get standalone just + chezmoi (standalone binaries into a +# tempdir), clone the repo, then forward to just for setup. +# +# usage: sh -c "$(curl -fsSL https://dots.someone.ky/bootstrap)" -- [class] +# (sh -c form matters: apply prompts for the age passphrase on stdin) +set -eu + +repo="${CHEZMOI_REPO:-https://github.com/MaxNeedsSnacks/uchi.git}" +class="${1:-}" + +tmp="$(mktemp -d)" +export PATH="$tmp:$PATH" + +command -v just >/dev/null 2>&1 || + curl --proto '=https' --tlsv1.2 -sSf https://just.systems/install.sh | + bash -s -- --to "$tmp" + +command -v chezmoi >/dev/null 2>&1 || + sh -c "$(curl -fsSL get.chezmoi.io)" -- -b "$tmp" + +src="$HOME/.local/share/chezmoi" +[ -d "$src/.git" ] || chezmoi init "$repo" + +echo "setting up system with class ${class:-"none"}..." + +just --justfile "$src/justfile" setup "$class" +echo "all done! don't forget to run just system::hostname and sign in with app stores / cred helpers as necessary" diff --git a/config/.chezmoiscripts/run_once_05-install-paru.sh.tmpl b/config/.chezmoiscripts/run_once_05-install-paru.sh.tmpl new file mode 100644 index 0000000..d6cd52c --- /dev/null +++ b/config/.chezmoiscripts/run_once_05-install-paru.sh.tmpl @@ -0,0 +1,17 @@ +#!/bin/sh + +# bootstrap: ensures paru itself exists before anything pacman-touching runs +set -eu + +{{ if eq .chezmoi.os "linux" -}} + +if ! command -v paru >/dev/null 2>&1; then + echo "installing paru (will ask for sudo)..." + sudo pacman -S --needed --noconfirm base-devel git + tmp=$(mktemp -d) + git clone https://aur.archlinux.org/paru-bin.git "$tmp/paru-bin" + cd "$tmp/paru-bin" + makepkg -si --noconfirm +fi + +{{- end }} diff --git a/config/.chezmoiscripts/run_once_50-macos-defaults.sh.tmpl b/config/.chezmoiscripts/run_once_50-macos-defaults.sh.tmpl deleted file mode 100644 index 37f41aa..0000000 --- a/config/.chezmoiscripts/run_once_50-macos-defaults.sh.tmpl +++ /dev/null @@ -1,59 +0,0 @@ -#!/bin/sh - -# macOS user preferences (from my old ky/darwin/preferences.nix) -set -eu - -{{ if eq .chezmoi.os "darwin" -}} - -# keyboard & text input -defaults write -g ApplePressAndHoldEnabled -bool false # disable accent panels from holding keys -# and no autocorrect or any of that funny business either -defaults write -g NSAutomaticCapitalizationEnabled -bool false -defaults write -g NSAutomaticPeriodSubstitutionEnabled -bool false -defaults write -g NSAutomaticQuoteSubstitutionEnabled -bool false -defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false - -# panels & extensions -defaults write -g AppleShowAllExtensions -bool true -defaults write -g NSNavPanelExpandedStateForSaveMode -bool true -defaults write -g NSNavPanelExpandedStateForSaveMode2 -bool true -defaults write -g WebKitDeveloperExtras -bool true - -# dock (hot corners: 1 = disabled) -defaults write com.apple.dock autohide -bool false -defaults write com.apple.dock wvous-tl-corner -int 1 -defaults write com.apple.dock wvous-tr-corner -int 1 -defaults write com.apple.dock wvous-bl-corner -int 1 -defaults write com.apple.dock wvous-br-corner -int 1 - -# finder -defaults write com.apple.finder ShowStatusBar -bool true -defaults write com.apple.finder ShowPathbar -bool true -defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" -defaults write com.apple.finder FXPreferredViewStyle -string "icnv" -defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false -defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true -defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false -defaults write com.apple.finder ShowMountedServersOnDesktop -bool true -defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true -defaults write com.apple.finder _FXSortFoldersFirst -bool true - -# trackpad (both plists, like nix-darwin did) -for domain in com.apple.AppleMultitouchTrackpad com.apple.driver.AppleBluetoothMultitouch.trackpad; do - defaults write "$domain" Clicking -bool true - defaults write "$domain" TrackpadRightClick -bool true - defaults write "$domain" TrackpadThreeFingerDrag -bool false -done - -# misc -defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true -defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true -defaults write com.apple.AdLib allowApplePersonalizedAdvertising -bool false - -# pinentry-touchid expects these (was ky/darwin/pinentry-touchid.nix) -defaults write org.gpgtools.common DisableKeychain -bool true -defaults write org.gpgtools.common UseKeychain -bool false - -killall Dock Finder 2>/dev/null || true - -{{- end }} diff --git a/config/.chezmoiscripts/run_onchange_11-arch-packages.sh.tmpl b/config/.chezmoiscripts/run_onchange_11-arch-packages.sh.tmpl new file mode 100644 index 0000000..1b0497f --- /dev/null +++ b/config/.chezmoiscripts/run_onchange_11-arch-packages.sh.tmpl @@ -0,0 +1,13 @@ +#!/bin/sh + +# installs packages from ~/.config/paru/pkglist.txt as necessary. reruns if below changes +# pkglist hash: {{ include "dot_config/paru/pkglist.txt" | sha256sum }} +set -eu + +{{ if eq .chezmoi.os "linux" -}} + +pkgs=$(grep -vE '^\s*(#|$)' "{{ .chezmoi.sourceDir }}/dot_config/paru/pkglist.txt" || true) +[ -n "$pkgs" ] || exit 0 +printf '%s\n' "$pkgs" | paru -S --needed - + +{{- end }} diff --git a/config/.chezmoiscripts/run_once_11-brew-bundle.sh.tmpl b/config/.chezmoiscripts/run_onchange_11-brew-bundle.sh.tmpl similarity index 53% rename from config/.chezmoiscripts/run_once_11-brew-bundle.sh.tmpl rename to config/.chezmoiscripts/run_onchange_11-brew-bundle.sh.tmpl index 765c8cd..735717c 100644 --- a/config/.chezmoiscripts/run_once_11-brew-bundle.sh.tmpl +++ b/config/.chezmoiscripts/run_onchange_11-brew-bundle.sh.tmpl @@ -1,6 +1,7 @@ #!/bin/sh -# bootstrap: bundles everything from the Brewfile +# installs packages from the Brewfile as necessary. reruns if below changes +# Brewfile hash: {{ include "dot_config/homebrew/Brewfile" | sha256sum }} set -eu {{ if eq .chezmoi.os "darwin" -}} diff --git a/config/dot_config/paru/pkglist.txt b/config/dot_config/paru/pkglist.txt new file mode 100644 index 0000000..3433b26 --- /dev/null +++ b/config/dot_config/paru/pkglist.txt @@ -0,0 +1 @@ +# TODO: fill with packages diff --git a/justfile b/justfile index 99a3292..bb3e7c3 100644 --- a/justfile +++ b/justfile @@ -1,5 +1,5 @@ -# machine setup lives in modules: `just bootstrap::all` after -# `chezmoi init --apply`; `just system::…` for other systemwide settings +# machine setup lives in modules: bootstrap:: installs things (once), +# system:: configures things; `just setup ` runs both mod bootstrap mod system @@ -7,9 +7,11 @@ mod system default: @just --list --list-submodules -# quick setup for a new machine -setup: +# full setup for a machine class: laptop, server (macos) or desktop (linux) +setup class="": just bootstrap::all + chezmoi apply + @if [ -n "{{ class }}" ]; then just system::class-{{ class }}; fi # diffs installed brews and casks vs what we have in Brewfile # just in case i want to make some things i install more... permanent @@ -19,3 +21,11 @@ brew-drift: comm -13 \ <(grep -ohE '^(brew|cask) "[^"]+"' ~/.config/homebrew/Brewfile | sort) \ <({ brew leaves | sed 's/.*/brew "&"/'; brew list --cask | sed 's/.*/cask "&"/'; } | sort) + +# same idea for arch: explicitly installed packages not in the pkglist +[linux] +pacman-drift: + #!/bin/bash + comm -13 \ + <(grep -vE '^\s*(#|$)' ~/.config/paru/pkglist.txt | sort) \ + <(pacman -Qqe | sort) diff --git a/system.just b/system.just index a272162..3f21e4d 100644 --- a/system.just +++ b/system.just @@ -1,3 +1,112 @@ +# systemwide settings for different device classes + +# the classes are currently only valid for either macos or linux because i'm... +# well, too lazy to add a bunch of no-ops atm, but dw i'll get to it(tm) + +[macos] +class-laptop: base firewall-on + +[macos] +class-server: base firewall-off remote-login no-sleep + +[linux] +class-desktop: base + +[macos] +base: timezone login-shell pam-touchid darwin-defaults + +[linux] +base: timezone login-shell + +[macos] +timezone: + sudo systemsetup -settimezone "Europe/Berlin" + +[linux] +timezone: + timedatectl set-timezone Europe/Berlin + +# sets login shell for the current user to fish +login-shell: + #!/bin/sh + fish=$(which fish) + grep -qx "$fish" /etc/shells || echo "$fish" | sudo tee -a /etc/shells + [ "$SHELL" = "$fish" ] || chsh -s "$fish" + +# touch id / apple watch auth for sudo (pam_tid covers both) +[macos] +pam-touchid: + #!/bin/sh + sudo tee /etc/pam.d/sudo_local >/dev/null <<'EOF' + auth optional /opt/homebrew/lib/pam/pam_reattach.so + auth sufficient pam_tid.so + EOF + +# macOS user preferences (from my old ky/darwin/preferences.nix) +[macos] +darwin-defaults: + #!/bin/sh + set -eu + + # keyboard & text input + defaults write -g ApplePressAndHoldEnabled -bool false # disable accent panels from holding keys + # and no autocorrect or any of that funny business either + defaults write -g NSAutomaticCapitalizationEnabled -bool false + defaults write -g NSAutomaticPeriodSubstitutionEnabled -bool false + defaults write -g NSAutomaticQuoteSubstitutionEnabled -bool false + defaults write -g NSAutomaticSpellingCorrectionEnabled -bool false + + # panels & extensions + defaults write -g AppleShowAllExtensions -bool true + defaults write -g NSNavPanelExpandedStateForSaveMode -bool true + defaults write -g NSNavPanelExpandedStateForSaveMode2 -bool true + defaults write -g WebKitDeveloperExtras -bool true + + # dock (hot corners: 1 = disabled) + defaults write com.apple.dock autohide -bool false + defaults write com.apple.dock wvous-tl-corner -int 1 + defaults write com.apple.dock wvous-tr-corner -int 1 + defaults write com.apple.dock wvous-bl-corner -int 1 + defaults write com.apple.dock wvous-br-corner -int 1 + + # finder + defaults write com.apple.finder ShowStatusBar -bool true + defaults write com.apple.finder ShowPathbar -bool true + defaults write com.apple.finder FXDefaultSearchScope -string "SCcf" + defaults write com.apple.finder FXPreferredViewStyle -string "icnv" + defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false + defaults write com.apple.finder ShowExternalHardDrivesOnDesktop -bool true + defaults write com.apple.finder ShowHardDrivesOnDesktop -bool false + defaults write com.apple.finder ShowMountedServersOnDesktop -bool true + defaults write com.apple.finder ShowRemovableMediaOnDesktop -bool true + defaults write com.apple.finder _FXSortFoldersFirst -bool true + + # trackpad (both plists, like nix-darwin did) + for domain in com.apple.AppleMultitouchTrackpad com.apple.driver.AppleBluetoothMultitouch.trackpad; do + defaults write "$domain" Clicking -bool true + defaults write "$domain" TrackpadRightClick -bool true + defaults write "$domain" TrackpadThreeFingerDrag -bool false + done + + # misc + defaults write com.apple.desktopservices DSDontWriteNetworkStores -bool true + defaults write com.apple.desktopservices DSDontWriteUSBStores -bool true + defaults write com.apple.AdLib allowApplePersonalizedAdvertising -bool false + + # pinentry-touchid expects these (was ky/darwin/pinentry-touchid.nix) + defaults write org.gpgtools.common DisableKeychain -bool true + defaults write org.gpgtools.common UseKeychain -bool false + + killall Dock Finder 2>/dev/null || true + +[macos] +remote-login: + sudo systemsetup -setremotelogin on + +[macos] +no-sleep: + sudo pmset -a sleep 0 + [macos] firewall-on: #!/bin/sh -- knotmirror 0.0.1