chore: ci-update
All checks were successful
Update Nix Packages with nix-update / nix-update (push) Successful in 40m47s
All checks were successful
Update Nix Packages with nix-update / nix-update (push) Successful in 40m47s
This commit is contained in:
@@ -179,94 +179,79 @@ jobs:
|
||||
is_custom_update_script() {
|
||||
local pkg=$1
|
||||
local result
|
||||
# nix-update-script returns a list like [ "/nix/store/...-nix-update/bin/nix-update" ]
|
||||
# Custom scripts return a path like "/nix/store/.../update.sh"
|
||||
# Custom scripts (./update.sh) become store paths ending in .sh
|
||||
# nix-update-script produces a list with nix-update binary path
|
||||
result=$(nix eval --impure --raw --expr "
|
||||
let
|
||||
let
|
||||
flake = builtins.getFlake (toString ./.);
|
||||
pkg = flake.packages.\${builtins.currentSystem}.${pkg};
|
||||
script = pkg.passthru.updateScript or [];
|
||||
in
|
||||
if builtins.isPath script then
|
||||
\"custom\"
|
||||
else if builtins.isList script && builtins.length script > 0 then
|
||||
script = pkg.passthru.updateScript or null;
|
||||
in
|
||||
if script == null then \"none\"
|
||||
else if builtins.isPath script then \"custom\"
|
||||
else if builtins.isString script then
|
||||
(if builtins.match \".*\\.sh$\" script != null then \"custom\" else \"other\")
|
||||
else if builtins.isList script then
|
||||
let first = builtins.head script;
|
||||
in if builtins.isString first && builtins.match \".*/nix-update$\" first != null then
|
||||
\"nix-update-script\"
|
||||
else if builtins.isPath first then
|
||||
\"custom\"
|
||||
else
|
||||
\"other\"
|
||||
else if builtins.isAttrs script && script ? command then
|
||||
if builtins.isPath script.command then \"custom\"
|
||||
else if builtins.isList script.command && builtins.isPath (builtins.head script.command) then \"custom\"
|
||||
else \"other\"
|
||||
else
|
||||
\"other\"
|
||||
in if builtins.isString first && builtins.match \".*/nix-update$\" first != null
|
||||
then \"nix-update-script\"
|
||||
else \"custom\"
|
||||
else if builtins.isAttrs script && script ? command then \"custom\"
|
||||
else \"other\"
|
||||
" 2>/dev/null || echo "other")
|
||||
[[ "$result" == "custom" ]]
|
||||
}
|
||||
|
||||
# Run a custom update script directly (for packages like n8n)
|
||||
# Run a custom update script directly
|
||||
# Scripts must use nix-shell shebang for their own dependencies
|
||||
run_custom_update_script() {
|
||||
local pkg=$1
|
||||
local before_hash=$(git rev-parse HEAD)
|
||||
|
||||
|
||||
echo " 🔧 Detected custom update script for $pkg"
|
||||
|
||||
# Get package metadata for environment variables
|
||||
local name pname version
|
||||
name=$(nix eval --raw .#${pkg}.name 2>/dev/null || echo "$pkg")
|
||||
pname=$(nix eval --raw .#${pkg}.pname 2>/dev/null || echo "$pkg")
|
||||
version=$(nix eval --raw .#${pkg}.version 2>/dev/null || echo "unknown")
|
||||
|
||||
# Run the custom script using nix develop
|
||||
if nix develop --impure --expr "
|
||||
with builtins;
|
||||
let
|
||||
flake = getFlake (toString ./.);
|
||||
pkgs = flake.inputs.nixpkgs.legacyPackages.\${currentSystem};
|
||||
pkg' = flake.packages.\${currentSystem}.${pkg};
|
||||
script = pkg'.passthru.updateScript;
|
||||
cmd = if isAttrs script then script.command else script;
|
||||
scriptPath = if isList cmd then head cmd else cmd;
|
||||
in pkgs.mkShell {
|
||||
inputsFrom = [pkg'];
|
||||
packages = with pkgs; [ curl jq git ];
|
||||
}
|
||||
" --command bash -c "
|
||||
export UPDATE_NIX_NAME='${name}'
|
||||
export UPDATE_NIX_PNAME='${pname}'
|
||||
export UPDATE_NIX_OLD_VERSION='${version}'
|
||||
export UPDATE_NIX_ATTR_PATH='${pkg}'
|
||||
|
||||
# Get the script path and execute it
|
||||
script_path=\$(nix eval --impure --raw --expr '
|
||||
let
|
||||
flake = builtins.getFlake (toString ./.);
|
||||
pkg = flake.packages.\${builtins.currentSystem}.${pkg};
|
||||
script = pkg.passthru.updateScript;
|
||||
cmd = if builtins.isAttrs script then script.command else script;
|
||||
in if builtins.isList cmd then toString (builtins.head cmd)
|
||||
else toString cmd
|
||||
' 2>/dev/null)
|
||||
|
||||
if [ -n \"\$script_path\" ]; then
|
||||
echo \"Running: \$script_path\"
|
||||
bash \"\$script_path\"
|
||||
fi
|
||||
" 2>&1 | tee /tmp/update-${pkg}.log; then
|
||||
|
||||
# Resolve the store path of the update script
|
||||
local script_path
|
||||
script_path=$(nix eval --impure --raw --expr "
|
||||
let
|
||||
flake = builtins.getFlake (toString ./.);
|
||||
pkg = flake.packages.\${builtins.currentSystem}.${pkg};
|
||||
script = pkg.passthru.updateScript;
|
||||
cmd = if builtins.isAttrs script then script.command
|
||||
else if builtins.isList script then builtins.head script
|
||||
else script;
|
||||
in toString cmd
|
||||
" 2>/dev/null)
|
||||
|
||||
if [ -z "$script_path" ]; then
|
||||
echo "❌ Could not resolve update script path for $pkg"
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Set environment variables that nix-update would normally provide
|
||||
export UPDATE_NIX_NAME=$(nix eval --raw .#${pkg}.name 2>/dev/null || echo "$pkg")
|
||||
export UPDATE_NIX_PNAME=$(nix eval --raw .#${pkg}.pname 2>/dev/null || echo "$pkg")
|
||||
export UPDATE_NIX_OLD_VERSION=$(nix eval --raw .#${pkg}.version 2>/dev/null || echo "unknown")
|
||||
export UPDATE_NIX_ATTR_PATH="$pkg"
|
||||
|
||||
echo " Running: $script_path"
|
||||
if bash "$script_path" 2>&1 | tee /tmp/update-${pkg}.log; then
|
||||
if [ "$(check_commit "$before_hash")" = "true" ]; then
|
||||
echo "✅ Updated $pkg (via custom script)"
|
||||
return 0
|
||||
fi
|
||||
# Script succeeded but no commit — may already be up to date
|
||||
if grep -q "already at latest\|nothing to do" /tmp/update-${pkg}.log; then
|
||||
echo "✓ $pkg already up to date"
|
||||
return 1
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
# Clean up on failure
|
||||
git checkout -- . 2>/dev/null || true
|
||||
git clean -fd 2>/dev/null || true
|
||||
|
||||
if ! grep -q "already up to date\|No new version found" /tmp/update-${pkg}.log; then
|
||||
|
||||
if ! grep -q "already at latest\|nothing to do\|No new version found" /tmp/update-${pkg}.log; then
|
||||
echo "⚠️ Custom update script failed for $pkg"
|
||||
fi
|
||||
return 1
|
||||
|
||||
Reference in New Issue
Block a user