Files
Nomarchy/features/scripts/utils/nomarchy-sys-update
Bernardo Magri ac4d66e54d fix: nomarchy-sys-update targets actual hostname, not '#default'
The installer generates `nixosConfigurations.<hostname>` (see
installer/install.sh: `nixosConfigurations.$HOSTNAME`), but the system
update script was rebuilding `.#default` and using `--impure`. The
`#default` literal worked only on dev hosts that happened to be named
"default" and silently broke every toggle script on real installs.

Now resolves `$(hostname)` at runtime and aborts with a clear error if
empty. Dropped `--impure` — the flake doesn't need it.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-18 17:01:22 +01:00

35 lines
1.1 KiB
Bash

#!/usr/bin/env bash
# Nomarchy System Update Script
# 1. Applies system-wide NixOS changes
set -e
# Detect the repository location
if [ -f "/etc/nixos/flake.nix" ]; then
REPO_DIR="/etc/nixos"
elif [ -f "/etc/nomarchy/flake.nix" ]; then
REPO_DIR="/etc/nomarchy"
else
echo "Error: Nomarchy flake repository not found in /etc/nixos or /etc/nomarchy."
exit 1
fi
# The installer generates `nixosConfigurations.<hostname>` (see
# installer/install.sh: `nixosConfigurations.$HOSTNAME`), so the flake target
# must match the current host. The previous `#default` literal worked only
# for a development host that happened to be named "default" and silently
# broke every toggle script (nomarchy-tz-select, nomarchy-wifi-powersave,
# nomarchy-setup-{dns,fido2,fingerprint}, nomarchy-toggle-hybrid-gpu) on a
# real install.
HOSTNAME_ATTR=$(hostname)
if [ -z "$HOSTNAME_ATTR" ]; then
echo "Error: could not determine hostname for flake attribute." >&2
exit 1
fi
echo "Applying system-level changes from $REPO_DIR#$HOSTNAME_ATTR..."
sudo nixos-rebuild switch --flake "$REPO_DIR#$HOSTNAME_ATTR"
echo "System update complete."