fixed imports and added scripts

This commit is contained in:
John Lancaster
2026-03-08 14:13:52 -05:00
parent 1228151d5a
commit 3e15d03778
5 changed files with 53 additions and 10 deletions

24
scripts/switch.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/usr/bin/env bash
FLAKE_DIR="/home/john/.config/home-manager/jsl-dendritic"
is_in_array() {
local needle="$1"
shift
local arr=("$@")
[[ " ${arr[*]} " == *" ${needle} "* ]] && echo true || echo false
}
hostname_exists() {
NIX_EVAL_CMD="nix eval --json --no-warn-dirty --apply builtins.attrNames"
mapfile -t HOME_CONFIGS < <(${NIX_EVAL_CMD} ${FLAKE_DIR}#homeConfigurations | jq -r '.[]')
is_in_array "$(hostname)" "${HOME_CONFIGS[@]}"
}
HOSTNAME=$(hostname)
if [[ "$(hostname_exists)" == "true" ]]; then
home-manager switch --flake "${FLAKE_DIR}#${HOSTNAME}"
else
echo "No homeConfiguration found for hostname '${HOSTNAME}'." >&2
exit 1
fi