fix: dynamic flake path resolution and replace env-update/sys-update aliases with scripts

This commit is contained in:
Bernardo Magri
2026-04-13 13:25:54 +01:00
parent 866e556656
commit 9746e75bc5
18 changed files with 56 additions and 33 deletions

View File

@@ -23,5 +23,5 @@ fi
jq --arg pkg "$PKG_NAME" '. + [$pkg]' "$STATE_FILE" > "${STATE_FILE}.tmp" && mv "${STATE_FILE}.tmp" "$STATE_FILE"
echo "Package $PKG_NAME added declaratively to $STATE_FILE."
echo "Applying changes with env-update..."
env-update
echo "Applying changes with nomarchy-env-update..."
nomarchy-env-update

View File

@@ -23,5 +23,5 @@ fi
jq --arg pkg "$PKG_NAME" '. - [$pkg]' "$STATE_FILE" > "${STATE_FILE}.tmp" && mv "${STATE_FILE}.tmp" "$STATE_FILE"
echo "Package $PKG_NAME removed declaratively from $STATE_FILE."
echo "Applying changes with env-update..."
env-update
echo "Applying changes with nomarchy-env-update..."
nomarchy-env-update

View File

@@ -32,4 +32,4 @@ Custom)
esac
echo "DNS configured to $dns. Applying changes..."
sudo sys-update
sudo nomarchy-sys-update

View File

@@ -7,13 +7,13 @@ STATE_FILE="/etc/nixos/state.json"
if [[ "--remove" == $1 ]]; then
sudo jq '.features.fido2 = false' "$STATE_FILE" > /tmp/state.json && sudo mv /tmp/state.json "$STATE_FILE"
echo "FIDO2 support disabled. Applying changes..."
sudo sys-update
sudo nomarchy-sys-update
exit 0
fi
sudo jq '.features.fido2 = true' "$STATE_FILE" > /tmp/state.json && sudo mv /tmp/state.json "$STATE_FILE"
echo "FIDO2 support enabled. Applying changes..."
sudo sys-update
sudo nomarchy-sys-update
# Enrollment is still an imperative action
if command -v pamu2fcfg &> /dev/null; then

View File

@@ -7,13 +7,13 @@ STATE_FILE="/etc/nixos/state.json"
if [[ "--remove" == $1 ]]; then
sudo jq '.features.fingerprint = false' "$STATE_FILE" > /tmp/state.json && sudo mv /tmp/state.json "$STATE_FILE"
echo "Fingerprint support disabled. Applying changes..."
sudo sys-update
sudo nomarchy-sys-update
exit 0
fi
sudo jq '.features.fingerprint = true' "$STATE_FILE" > /tmp/state.json && sudo mv /tmp/state.json "$STATE_FILE"
echo "Fingerprint support enabled. Applying changes..."
sudo sys-update
sudo nomarchy-sys-update
# Enrollment is still an imperative action
if command -v fprintd-enroll &> /dev/null; then

View File

@@ -10,7 +10,7 @@ if [[ $(sudo jq -r '.features.hybridGPU // false' "$STATE_FILE") != "true" ]]; t
if gum confirm "Hybrid GPU support is not enabled. Enable it now? (Requires sys-update)"; then
sudo jq '.features.hybridGPU = true' "$STATE_FILE" > /tmp/state.json && sudo mv /tmp/state.json "$STATE_FILE"
echo "Hybrid GPU support enabled in configuration. Applying changes..."
sudo sys-update
sudo nomarchy-sys-update
echo "Please run this command again after the update."
exit 0
fi

View File

@@ -25,5 +25,5 @@ jq --argjson val "$NEW_VALUE" '.suspend = $val' "$STATE_FILE" > "$TMP_JSON" && m
echo "Suspend availability set to $NEW_VALUE. Updating environment..."
# Run env-update to apply changes to the menu
env-update
# Run nomarchy-env-update to apply changes to the menu
nomarchy-env-update

View File

@@ -9,4 +9,4 @@ timezone=$(timedatectl list-timezones | gum filter --height 20 --header "Set tim
sudo jq --arg tz "$timezone" '.timezone = $tz' "$STATE_FILE" > /tmp/state.json && sudo mv /tmp/state.json "$STATE_FILE"
echo "Timezone is now set to $timezone. Applying changes..."
sudo sys-update
sudo nomarchy-sys-update

View File

@@ -1,20 +1,23 @@
#!/usr/bin/env bash
# Nomarchy Update Script
# 1. Updates the flake inputs in /etc/nixos
# 1. Updates the flake inputs in the repository
# 2. Applies system-wide NixOS changes
# 3. Applies user-level Home Manager changes
set -e
REPO_DIR="/etc/nixos"
if [ ! -d "$REPO_DIR" ]; then
echo "Error: $REPO_DIR not found. Are you running on a Nomarchy system?"
# 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
echo "--- Starting Nomarchy Update ---"
echo "--- Starting Nomarchy Update from $REPO_DIR ---"
# 1. Update Flake Lock
echo "Updating flake inputs..."

View File

@@ -14,4 +14,4 @@ esac
sudo jq --argjson val "$value" '.wifi.powersave = $val' "$STATE_FILE" > /tmp/state.json && sudo mv /tmp/state.json "$STATE_FILE"
echo "Wifi powersave set to $1. Applying changes..."
sudo sys-update
sudo nomarchy-sys-update

View File

@@ -23,4 +23,4 @@ jq --argjson val "$NEW_VALUE" '.screensaver = $val' "$STATE_FILE" > "$TMP_JSON"
echo "Screensaver state set to $NEW_VALUE. Updating environment..."
env-update
nomarchy-env-update

View File

@@ -6,13 +6,23 @@
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
echo "Applying user-level changes..."
home-manager switch --flake /etc/nixos#default --impure
echo "Applying user-level changes from $REPO_DIR..."
home-manager switch --flake "$REPO_DIR#default" --impure
echo "Environment update complete."

View File

@@ -5,8 +5,18 @@
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
# Apply NixOS changes from the local flake
echo "Applying system-level changes..."
sudo nixos-rebuild switch --flake /etc/nixos#default --impure
echo "Applying system-level changes from $REPO_DIR..."
sudo nixos-rebuild switch --flake "$REPO_DIR#default" --impure
echo "System update complete."

View File

@@ -29,7 +29,7 @@ nomarchy-theme-set "$(nomarchy-theme-list | gum filter --placeholder 'Select a t
echo "Step 2: Choose your preferred font"
nomarchy-font-set "$(nomarchy-font-list | gum filter --placeholder 'Select a font...')"
# 3. Setup Local Repo (Crucial for env-update to work)
# 3. Setup Local Repo (Crucial for nomarchy-env-update to work)
echo ""
echo "Nomarchy relies on a local git repository for declarative updates."
if [ ! -d "/etc/nixos/.git" ]; then

View File

@@ -20,7 +20,7 @@ if fc-list | grep -iq "$font_name"; then
TMP_JSON=$(mktemp)
jq --arg font "$font_name" '.font = $font' "$STATE_FILE" > "$TMP_JSON" && mv "$TMP_JSON" "$STATE_FILE"
echo "Font set to $font_name declaratively. Applying changes..."
env-update
nomarchy-env-update
# Instant feedback for certain apps via IPC
if pgrep -x kitty; then

View File

@@ -46,8 +46,8 @@ if [ -d "$BG_DIR" ]; then
fi
fi
echo "Theme set to $THEME_NAME. Applying changes with env-update..."
env-update
echo "Theme set to $THEME_NAME. Applying changes with nomarchy-env-update..."
nomarchy-env-update
nomarchy-theme-set-templates

View File

@@ -15,6 +15,6 @@ mkdir -p "$STATE_DIR"
# triggering an env-update if needed to apply the declarative changes.
if [[ $NOMARCHY_TOGGLE_SKIP_VSCODE_THEME != "true" ]]; then
# We trigger env-update to apply the new VSCode theme declaratively.
env-update
# We trigger nomarchy-env-update to apply the new VSCode theme declaratively.
nomarchy-env-update
fi

View File

@@ -26,7 +26,7 @@ let
if [ -n "$SELECTED_FONT" ]; then
TMP_JSON=$(mktemp)
jq --arg font "$SELECTED_FONT" '.font = $font' "$STATE_FILE" > "$TMP_JSON" && mv "$TMP_JSON" "$STATE_FILE"
env-update
nomarchy-env-update
fi
'';
@@ -55,7 +55,7 @@ let
TMP_JSON=$(mktemp)
jq --arg wp "$SELECTED_WP" '.wallpaper = $wp' "$STATE_FILE" > "$TMP_JSON" && mv "$TMP_JSON" "$STATE_FILE"
swww img "$SELECTED_WP" --transition-type outer --transition-pos 0.85,0.97 --transition-step 90 &
env-update
nomarchy-env-update
fi
'';
in