Modifed ncli update to ask which packages to update so it is possible to only update wanted packages

This commit is contained in:
2026-03-12 09:39:52 +01:00
parent c6862c78db
commit b25430abc9
2 changed files with 60 additions and 7 deletions

View File

@ -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=""

View File

@ -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