Files
Nomarchy/features/scripts/utils/nomarchy-env-update
Bernardo Magri d4f50afc62 fix(installer): start nix-daemon and trust flake repo for HM activation
HM activation inside `nixos-enter` failed with `big.lock: Permission
denied` because the chroot has no systemd and therefore no nix-daemon —
the user-level `nix run` fell back to single-user mode and couldn't
write /nix/var/nix/db. Launch nix-daemon manually for the activation
window and force NIX_REMOTE=daemon. Also mark /etc/nixos (and the
impermanence path) as a git safe.directory so HM doesn't trip over
git's dubious-ownership check on the root-owned repo. Make
nomarchy-env-update self-bootstrap via `nix run home-manager` when
home-manager isn't on PATH so the recovery hint actually works on a
freshly-installed system.

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

38 lines
1.3 KiB
Bash

#!/usr/bin/env bash
# Nomarchy Environment Update Script
# 1. Runs the pre-flight state migration
# 2. Applies user-level Home Manager changes (Standalone)
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
# Use the pre-flight migration script to ensure the state is synced before evaluation
if command -v nomarchy-preflight-migration >/dev/null 2>&1; then
nomarchy-preflight-migration
fi
# Apply Home Manager changes from the local flake (Standalone).
# On a freshly-installed system where the installer's HM activation failed,
# `home-manager` won't be on PATH yet — fall back to `nix run` so this
# script can recover the install instead of erroring on a missing binary.
echo "Applying user-level changes from $REPO_DIR#$USER..."
if command -v home-manager >/dev/null 2>&1; then
home-manager switch --flake "$REPO_DIR#$USER" --impure
else
nix --extra-experimental-features 'nix-command flakes' \
run 'home-manager/release-25.11' \
-- switch --flake "$REPO_DIR#$USER" --impure
fi
echo "Environment update complete."