From b25430abc9a0b9abb1c9427340c0349114159159 Mon Sep 17 00:00:00 2001 From: Cookiez Date: Thu, 12 Mar 2026 09:39:52 +0100 Subject: [PATCH] Modifed ncli update to ask which packages to update so it is possible to only update wanted packages --- modules/ncli.nix | 65 +++++++++++++++++++++++++++++---- modules/packages/essentials.nix | 2 + 2 files changed, 60 insertions(+), 7 deletions(-) diff --git a/modules/ncli.nix b/modules/ncli.nix index e7a84b1..31ccfff 100644 --- a/modules/ncli.nix +++ b/modules/ncli.nix @@ -161,13 +161,64 @@ in echo -e "Updating flake and rebuilding system for current host: $HOST on generation: $YELLOW$geno$NOCOLOR" cd "$HOME/$PROJECT" || { echo "Error: Could not change to $HOME/$PROJECT"; exit 1; } - echo "Updating flake..." - if nix flake update; then - echo "✓ Flake updated successfully" - else - echo "✗ Flake update failed" >&2 - exit 1 - fi + # --- Selective flake update --- + read -rp "Update [a]ll inputs or [s]elect manually? (a/s): " choice + + case "$choice" in + a|A) + echo "Updating all inputs..." + if nix flake update --flake .; then + echo "✓ Flake updated successfully" + else + echo "✗ Flake update failed" >&2 + exit 1 + fi + ;; + s|S) + echo "Fetching available updates (this may take a moment)..." + TEMP_LOCK=$(mktemp) + trap 'rm -f "$TEMP_LOCK"' EXIT + + nix flake update --output-lock-file "$TEMP_LOCK" --flake . 2>/dev/null + + outdated=$(jq -r --slurpfile new "$TEMP_LOCK" ' + .nodes as $old | + $new[0].nodes as $newn | + ($old | keys[]) | + select(. != "root") | + select( + ($old[.].locked.lastModified // 0) != + ($newn[.].locked.lastModified // 0) + ) + ' flake.lock) + + if [[ -z "$outdated" ]]; then + echo "✓ All inputs are already up to date, skipping flake update." + else + echo + echo "Updates available for:" + printf '%s\n' "$outdated" + echo + echo "Tab to select, Enter to update, Esc to cancel." + selected=$(printf '%s\n' "$outdated" | fzf --multi) || { + echo "No inputs selected, skipping flake update." + selected="" + } + if [[ -n "$selected" ]]; then + if nix flake update --flake . $selected; then + echo "✓ Flake updated successfully" + else + echo "✗ Flake update failed" >&2 + exit 1 + fi + fi + fi + ;; + *) + echo "Invalid choice, skipping flake update." + ;; + esac + # --- End selective flake update --- current="" diff --git a/modules/packages/essentials.nix b/modules/packages/essentials.nix index 5940a47..0fa3b83 100644 --- a/modules/packages/essentials.nix +++ b/modules/packages/essentials.nix @@ -45,6 +45,8 @@ rocmPackages.rocm-runtime #AMD ROCm runtime ripgrep #Alternative to grep search for text in files pipewire #Multimedia handling + fzf #Needed for nix-selective update tool + jq #Needed for nix-selective update tool distrobox dbus cifs-utils