#!/bin/sh # link-machine.sh --- point this checkout's entry files at the right machine dir # # The repo holds one directory per machine (linux/, mac/) because Doom's # init.el cannot be reconciled across them: `doom!' takes a single module # list. Doom still insists on finding init.el at $DOOMDIR, so each machine # gets an untracked symlink at the repo root: # # init.el -> linux/init.el (on GNU/Linux) # init.el -> mac/init.el (on macOS) # # Those root files are gitignored on purpose: one branch is shared by both # machines, so a tracked root symlink could only ever point at one of them. # Consequence: a fresh clone has no init.el until you run this, and # `git clean -xfd' will delete the links. Re-run this script either way. # # Only files that have actually been split out are linked. config.el and # packages.el are still shared at the repo root; the day mac/config.el # appears, this script links it too, no edit needed. # # Usage: bin/link-machine.sh [linux|mac] (auto-detects via uname) set -eu root=$(cd "$(dirname "$0")/.." && pwd) if [ $# -ge 1 ]; then machine=$1 else case $(uname -s) in Darwin) machine=mac ;; Linux) machine=linux ;; *) echo "link-machine.sh: unsupported system $(uname -s); pass linux or mac" >&2 exit 1 ;; esac fi case $machine in linux|mac) ;; *) echo "link-machine.sh: unknown machine '$machine' (want linux or mac)" >&2 exit 1 ;; esac if [ ! -d "$root/$machine" ]; then echo "link-machine.sh: no $machine/ directory in $root" >&2 exit 1 fi linked=0 for f in init.el config.el packages.el; do if [ -f "$root/$machine/$f" ]; then # relative link, so the checkout can be moved without relinking ln -sfn "$machine/$f" "$root/$f" echo "linked $f -> $machine/$f" linked=$((linked + 1)) fi done if [ "$linked" -eq 0 ]; then echo "link-machine.sh: nothing to link for $machine -- no entry files in $machine/" >&2 exit 1 fi echo "done. next: doom sync"