Dough Git

commit

Make the installer work on Arch and any distro, add git config step

commit
a12a96c8df043708aadeb13eb317933ab9f63c2c
author
Clove Twilight <[email protected]>
date
2026-11-07 13:08
- Arch: use paru/yay for AUR packages, build paru if neither is installed
- Arch: full -Syu instead of a partial -Sy, keep an existing rust package
- Retry packages one at a time when a bulk install fails
- Unknown distros skip the package step instead of exiting
- Enable services one at a time, without --now when systemd isn't running
- New install-git.sh for user.name, user.email and init.defaultBranch

diff --git a/README.md b/README.md
index faa4989..c1097a8 100644
--- a/README.md
+++ b/README.md
@@ -20,6 +20,7 @@ A swayfx desktop with a "Clockwork" theme pulled from the wallpaper: deep-space
 ## Install
 
 Clone it anywhere, then run the installer. It links everything into place.
+On Arch, packages missing from the repos come from the AUR with yay or paru (paru gets installed if you have neither).
 
 ```sh
 git clone https://github.com/doughmination/dots ~/dots
@@ -27,11 +28,12 @@ git clone https://github.com/doughmination/dots ~/dots
 ~/dots/install
 ```
 
-The installer runs four scripts, and you can run any of them on its own:
+The installer runs five scripts, and you can run any of them on its own:
 
 | Script | What it does |
 |---|---|
 | `install-deps.sh` | Installs the software (add `--no-flatpak` or `--no-services` to skip those parts) |
+| `install-git.sh` | Sets your git name, email and default branch (asks, or pass `--git-name=`, `--git-email=`, `--git-branch=`; `--defaults` uses User / [email protected] / main) |
 | `install-assets.sh` | Installs the font and the cursor |
 | `install-config.sh` | Links the configs into `~/.config` |
 | `install-scripts.sh` | Links the helper scripts into `~/.local/bin` |
diff --git a/install b/install
index ae59ad9..6cf4b31 100755
--- a/install
+++ b/install
@@ -1,28 +1,32 @@
 #!/usr/bin/env bash
 # install: full setup. Runs, in order:
 #   1. install-deps.sh    software (packages, rust + hyfetch, oh-my-posh, flatpaks, services)
-#   2. install-assets.sh  font and cursor themes
-#   3. install-config.sh  link configs into ~/.config
-#   4. install-scripts.sh link binaries/ into ~/.local/bin
+#   2. install-git.sh     git name, email and default branch
+#   3. install-assets.sh  font and cursor themes
+#   4. install-config.sh  link configs into ~/.config
+#   5. install-scripts.sh link binaries/ into ~/.local/bin
 #
 #   ./install                     everything
 #   ./install --dry-run           print every command without running anything
 #   --no-flatpak, --no-services   passed through to install-deps.sh
 #   --with-sddm                   also install the Clockwork login theme (install-sddm.sh)
 #   --with-sound                  turn on the background sound (install-config.sh)
+#   --git-name=, --git-email=, --git-branch=, --defaults
+#                                 passed through to install-git.sh
 #
 # Each script also works on its own.
 
 set -uo pipefail
 
-ALL=() DEPS=() CONFIG=() PARTS=(deps assets config scripts)
+ALL=() DEPS=() CONFIG=() GIT=() PARTS=(deps git assets config scripts)
 for arg in "$@"; do
   case $arg in
     --dry-run)                  ALL+=("$arg") ;;
     --no-flatpak|--no-services) DEPS+=("$arg") ;;
     --with-sddm)                PARTS+=(sddm) ;;
     --with-sound)               CONFIG+=("$arg") ;;
-    -h|--help) sed -n '2,14p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
+    --git-*=*|--defaults)       GIT+=("$arg") ;;
+    -h|--help) sed -n '2,17p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
     *) echo "Unknown option: $arg (try --help)"; exit 1 ;;
   esac
 done
@@ -33,6 +37,8 @@ for part in "${PARTS[@]}"; do
   printf '\n\e[1;35m######## install-%s ########\e[0m\n' "$part"
   if [ "$part" = deps ]; then
     "$REPO/install-deps.sh" "${ALL[@]}" "${DEPS[@]}" || failed+=("$part")
+  elif [ "$part" = git ]; then
+    "$REPO/install-git.sh" "${ALL[@]}" "${GIT[@]}" || failed+=("$part")
   elif [ "$part" = config ]; then
     "$REPO/install-config.sh" "${ALL[@]}" "${CONFIG[@]}" || failed+=("$part")
   else
diff --git a/install-deps.sh b/install-deps.sh
index 1a025a5..fecaef4 100755
--- a/install-deps.sh
+++ b/install-deps.sh
@@ -10,6 +10,7 @@
 #
 # Supported: Void, Arch (+ derivatives), Fedora, Debian/Ubuntu (+ derivatives), openSUSE.
 # Packages a distro doesn't carry are skipped and listed at the end, never fatal.
+# On any other distro the package step is skipped and the rest still runs.
 
 set -uo pipefail
 
@@ -51,8 +52,14 @@ for id in ${ID:-} ${ID_LIKE:-}; do
   esac
   [ -n "$FAMILY" ] && break
 done
-[ -n "$FAMILY" ] || { echo "Unsupported distro: ${PRETTY_NAME:-unknown}"; exit 1; }
-echo "Detected ${PRETTY_NAME:-$ID} (using the $FAMILY package list)"
+if [ -n "$FAMILY" ]; then
+  echo "Detected ${PRETTY_NAME:-$ID} (using the $FAMILY package list)"
+else
+  FAMILY=unknown
+  warn "Unsupported distro (${PRETTY_NAME:-unknown}): install the packages yourself; the rest still runs"
+fi
+# Never stop at a prompt, so this can run unattended
+export DEBIAN_FRONTEND=noninteractive
 [ "$DRY" = 1 ] && echo "Dry run: nothing will be installed."
 
 # ---------- package lists ----------
@@ -76,7 +83,9 @@ arch)
         brightnessctl playerctl power-profiles-daemon
         networkmanager bluez bluez-utils bluetui btop
         grim slurp wf-recorder firefox flatpak xdg-desktop-portal-wlr
-        jq curl unzip git fontconfig base-devel rustup) ;;
+        jq curl unzip git fontconfig base-devel rustup)
+  # rustup conflicts with the rust package, and --noconfirm would abort the whole install
+  if have cargo && ! have rustup; then PKGS=("${PKGS[@]/rustup}"); PKGS=(${PKGS[@]}); fi ;;
 fedora)
   PKGS=(swayfx waybar swaybg mpvpaper mpv wlsunset swayidle autotiling polkit-gnome gnome-keyring
         mako libnotify fuzzel gtklock ImageMagick kitty yazi
@@ -114,11 +123,55 @@ available() {
   esac
 }
 
+# Install a list of packages in one go. If that fails (one bad package or a
+# conflict sinks the whole transaction), retry them one at a time and record
+# the ones that still fail in MISSING.
+install_pkgs() {
+  [ $# -gt 0 ] || return 0
+  local cmd
+  case $FAMILY in
+    arch)   cmd=(pacman -S --needed --noconfirm) ;;
+    fedora) cmd=(dnf install -y) ;;
+    debian) cmd=(apt-get install -y) ;;
+    suse)   cmd=(zypper -n install) ;;
+  esac
+  run "${SUDO[@]}" "${cmd[@]}" "$@" && return 0
+  [ "$DRY" = 1 ] && return 0
+  warn "Installing everything at once failed, trying one package at a time"
+  for p in "$@"; do
+    "${SUDO[@]}" "${cmd[@]}" "$p" >/dev/null 2>&1 || { warn "Couldn't install $p"; MISSING+=("$p"); }
+  done
+}
+
+# Arch: find an AUR helper, or build paru if there isn't one.
+aur_helper() {
+  for h in paru yay; do have "$h" && { AUR=$h; return 0; }; done
+  if [ "$(id -u)" = 0 ]; then
+    warn "Running as root: makepkg won't build as root, so no AUR helper"
+    return 1
+  fi
+  step "No yay or paru found, building paru from the AUR"
+  if [ "$DRY" = 1 ]; then
+    echo "  $ git clone https://aur.archlinux.org/paru-bin.git && makepkg -si --noconfirm"
+    AUR=paru; return 0
+  fi
+  local tmp; tmp=$(mktemp -d)
+  if git clone --depth 1 https://aur.archlinux.org/paru-bin.git "$tmp/paru-bin" &&
+     (cd "$tmp/paru-bin" && makepkg -si --noconfirm); then
+    rm -rf "$tmp"; AUR=paru; return 0
+  fi
+  rm -rf "$tmp"
+  warn "Building paru failed"
+  return 1
+}
+
 # ---------- 1. distro packages ----------
+if [ "$FAMILY" != unknown ]; then
 step "Refreshing package lists"
 case $FAMILY in
   void)   run "${SUDO[@]}" xbps-install -S ;;
-  arch)   run "${SUDO[@]}" pacman -Sy ;;
+  # -Syu, not -Sy: installing after a bare -Sy is a partial upgrade, which Arch doesn't support
+  arch)   run "${SUDO[@]}" pacman -Syu --noconfirm ;;
   fedora)
     # swayfx lives in its own COPR on Fedora
     run "${SUDO[@]}" dnf install -y dnf-plugins-core
@@ -137,34 +190,47 @@ echo "  ${#INSTALL[@]} found, ${#MISSING[@]} not in your repos"
 step "Installing packages"
 case $FAMILY in
   void)   run "${SUDO[@]}" xbps-install -y "${INSTALL[@]}" ;;
-  arch)   run "${SUDO[@]}" pacman -S --needed --noconfirm "${INSTALL[@]}" ;;
-  fedora) run "${SUDO[@]}" dnf install -y "${INSTALL[@]}" ;;
-  debian) run "${SUDO[@]}" apt-get install -y "${INSTALL[@]}" ;;
-  suse)   run "${SUDO[@]}" zypper -n install "${INSTALL[@]}" ;;
+  arch|fedora|debian|suse) install_pkgs "${INSTALL[@]}" ;;
 esac
 
 # Arch: whatever pacman lacked, try the AUR
 if [ "$FAMILY" = arch ] && [ ${#MISSING[@]} -gt 0 ]; then
   AUR=""
-  for h in paru yay; do have "$h" && { AUR=$h; break; }; done
-  if [ -n "$AUR" ]; then
+  if aur_helper; then
     step "Installing from the AUR with $AUR: ${MISSING[*]}"
-    run "$AUR" -S --needed --noconfirm "${MISSING[@]}" && MISSING=()
+    # Skip the PKGBUILD review/diff prompts so it can run unattended
+    case $AUR in
+      paru) AUR_CMD=(paru -S --needed --noconfirm --skipreview) ;;
+      yay)  AUR_CMD=(yay -S --needed --noconfirm --answerdiff None --answerclean None) ;;
+    esac
+    # swayfx replaces sway, and --noconfirm answers "no" to removing it
+    if printf '%s\n' "${MISSING[@]}" | grep -qx swayfx &&
+       pacman -Qq sway >/dev/null 2>&1 && ! pacman -Qq swayfx >/dev/null 2>&1; then
+      warn "Plain sway is installed and conflicts with swayfx. Replace it with: $AUR -S swayfx"
+    fi
+    STILL=()
+    for p in "${MISSING[@]}"; do
+      run "${AUR_CMD[@]}" "$p" || STILL+=("$p")
+    done
+    MISSING=("${STILL[@]}")
   else
-    warn "No AUR helper (paru or yay) found, so these were skipped: ${MISSING[*]}"
+    warn "No AUR helper available, so these were skipped: ${MISSING[*]}"
   fi
 fi
+fi # FAMILY != unknown
 
 # ---------- 2. Rust toolchain + hyfetch ----------
 step "Rust toolchain (rustup, stable)"
 export PATH="$HOME/.cargo/bin:$PATH"
-if ! have rustup; then
+if ! have rustup && have cargo; then
+  echo "  using the cargo already on this system ($(command -v cargo))"
+elif ! have rustup; then
   warn "rustup isn't packaged here, using the official installer"
   if [ "$DRY" = 1 ]; then echo "  $ curl https://sh.rustup.rs | sh -s -- -y --no-modify-path"
   else curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path
   fi
 fi
-run rustup default stable
+have rustup || [ "$DRY" = 1 ] && run rustup default stable
 
 step "hyfetch (cargo)"
 run cargo install hyfetch
@@ -204,7 +270,16 @@ if [ "$SERVICES" = 1 ]; then
       fi
     done
   elif have systemctl; then
-    run "${SUDO[@]}" systemctl enable --now NetworkManager bluetooth power-profiles-daemon
+    # One at a time so a missing unit doesn't stop the others. Without a running
+    # systemd (chroot, container) just enable them for the next boot.
+    now=(--now); [ -d /run/systemd/system ] || now=()
+    for unit in NetworkManager bluetooth power-profiles-daemon; do
+      if systemctl list-unit-files "$unit.service" 2>/dev/null | grep -q "^$unit\.service" || [ "$DRY" = 1 ]; then
+        run "${SUDO[@]}" systemctl enable "${now[@]}" "$unit" || warn "Couldn't enable $unit"
+      else
+        warn "No systemd unit named $unit"
+      fi
+    done
   else
     warn "Unknown init system; enable NetworkManager, bluetooth and power-profiles-daemon yourself"
   fi
diff --git a/install-git.sh b/install-git.sh
new file mode 100755
index 0000000..8ca06a9
--- /dev/null
+++ b/install-git.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+# install-git.sh: set your git name, email and default branch (git config --global).
+#
+#   ./install-git.sh                       ask for each one (Enter keeps the default)
+#   ./install-git.sh --dry-run             print the commands without running them
+#   ./install-git.sh --git-name="Jo Doe" [email protected] --git-branch=main
+#   ./install-git.sh --defaults            don't ask, use the defaults
+#
+# Defaults: your current git setting if you have one, otherwise
+# User / [email protected] / main. Without a terminal (an unattended run) it
+# never asks, and only fills in settings that aren't set yet.
+
+set -uo pipefail
+
+DRY=0 ASK=1 NAME="" EMAIL="" BRANCH=""
+for arg in "$@"; do
+  case $arg in
+    --dry-run)      DRY=1 ;;
+    --defaults)     ASK=0 ;;
+    --git-name=*)   NAME=${arg#*=} ;;
+    --git-email=*)  EMAIL=${arg#*=} ;;
+    --git-branch=*) BRANCH=${arg#*=} ;;
+    -h|--help) sed -n '2,11p' "$0" | sed 's/^# \{0,1\}//'; exit 0 ;;
+    *) echo "Unknown option: $arg (try --help)"; exit 1 ;;
+  esac
+done
+
+c_head=$'\e[1;36m' c_warn=$'\e[1;33m' c_off=$'\e[0m'
+step() { printf '\n%s==> %s%s\n' "$c_head" "$*" "$c_off"; }
+warn() { printf '%s  ! %s%s\n' "$c_warn" "$*" "$c_off"; }
+run()  { printf '  $ %s\n' "$*"; [ "$DRY" = 1 ] || "$@"; }
+
+command -v git >/dev/null || { warn "git isn't installed; run install-deps.sh first"; exit 1; }
+[ "$DRY" = 1 ] && echo "Dry run: nothing will be changed."
+[ -t 0 ] || ASK=0
+
+step "Git identity"
+
+# setting <key> <value from flag> <fallback default> <question>
+setting() {
+  local key=$1 value=$2 fallback=$3 question=$4 current
+  current=$(git config --global --get "$key" 2>/dev/null)
+  if [ -z "$value" ]; then
+    if [ "$ASK" = 1 ]; then
+      read -r -p "  $question [${current:-$fallback}]: " value
+    elif [ -n "$current" ]; then
+      echo "  $key already set to $current"
+      return
+    fi
+    value=${value:-${current:-$fallback}}
+  fi
+  if [ "$value" = "$current" ]; then
+    echo "  $key already set to $current"
+  else
+    run git config --global "$key" "$value"
+  fi
+}
+
+setting user.name          "$NAME"   "User"             "Your name"
+setting user.email         "$EMAIL"  "[email protected]" "Your email"
+setting init.defaultBranch "$BRANCH" "main"             "Default branch for new repos"
+
+step "Done"