-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathjustfile
More file actions
49 lines (43 loc) · 2.33 KB
/
justfile
File metadata and controls
49 lines (43 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# Use bash with strict error checking
set shell := ["bash", "-euo", "pipefail", "-c"]
# Allow passing arguments to recipes
set positional-arguments
hosts_dir := ".stow/hosts"
nvim_config_home := "neovim/.config"
# Show available recipes with their descriptions
default:
@just --list
# Validate the Neovim dotfiles package.
nvim-check:
@echo "==> stow dry-run"
stow -nv neovim
@echo "==> stylua"
fd -e lua . neovim/.config/nvim -x stylua --check {}
@echo "==> headless startup"
GOTELEMETRY=off XDG_CONFIG_HOME="{{nvim_config_home}}" nvim --headless '+qa'
@echo "==> diff whitespace"
git diff --check
# Install dotfiles for one host.
# Known hosts: lambda, omega
# Example: STOW_FLAGS="-nv" just install lambda
install host:
@case "{{host}}" in lambda|omega) ;; *) echo "Unknown host: {{host}}" >&2; echo "Known hosts: lambda, omega" >&2; exit 1 ;; esac; \
host_file="{{hosts_dir}}/{{host}}.packages"; \
if [ ! -f "$host_file" ]; then echo "Host file missing: $host_file" >&2; exit 1; fi; \
mapfile -t packages < <(sed -E 's/[[:space:]]*#.*$//; s/^[[:space:]]+//; s/[[:space:]]+$//; /^[[:space:]]*$/d' "$host_file"); \
if [ "${#packages[@]}" -eq 0 ]; then echo "Host {{host}} has no packages: $host_file" >&2; exit 1; fi; \
for pkg in "${packages[@]}"; do if [ ! -d "$pkg" ]; then echo "Unknown package in $host_file: $pkg" >&2; exit 1; fi; done; \
echo "Installing host '{{host}}' from $host_file"; \
stow ${STOW_FLAGS:-} "${packages[@]}"
# Remove dotfiles for one host.
# Known hosts: lambda, omega
# Example: STOW_FLAGS="-nv" just uninstall omega
uninstall host:
@case "{{host}}" in lambda|omega) ;; *) echo "Unknown host: {{host}}" >&2; echo "Known hosts: lambda, omega" >&2; exit 1 ;; esac; \
host_file="{{hosts_dir}}/{{host}}.packages"; \
if [ ! -f "$host_file" ]; then echo "Host file missing: $host_file" >&2; exit 1; fi; \
mapfile -t packages < <(sed -E 's/[[:space:]]*#.*$//; s/^[[:space:]]+//; s/[[:space:]]+$//; /^[[:space:]]*$/d' "$host_file"); \
if [ "${#packages[@]}" -eq 0 ]; then echo "Host {{host}} has no packages: $host_file" >&2; exit 1; fi; \
for pkg in "${packages[@]}"; do if [ ! -d "$pkg" ]; then echo "Unknown package in $host_file: $pkg" >&2; exit 1; fi; done; \
echo "Removing host '{{host}}' from $host_file"; \
stow -D ${STOW_FLAGS:-} "${packages[@]}"