diff --git a/apps/update-sources/src/app.ts b/apps/update-sources/src/app.ts index fbc0cfe4..63053dc5 100644 --- a/apps/update-sources/src/app.ts +++ b/apps/update-sources/src/app.ts @@ -125,7 +125,9 @@ const main = async() => { ): void => { const execution = runNixUpdate(attr, scope, scopeAttr); - nixUpdateOutputs += execution.stdout; + if (execution.changelog) { + nixUpdateOutputs += execution.changelog; + } console.log(execution.stderr); console.log(execution.stdout); }; @@ -168,10 +170,10 @@ const main = async() => { if (vuetorrentOutput.length > 5) { output.push(`Misc Sources:\n${indentOutput(vuetorrentOutput)}\n\n\n`); } - if (caddyPluginsOutput.length > 5) { + if (caddyPluginsOutput !== '') { output.push(`Caddy Plugins:\n${indentOutput(caddyPluginsOutput)}\n\n\n`); } - if (nixUpdateOutputs.length > 5) { + if (nixUpdateOutputs !== '') { output.push(`nix-update executions:\n${indentOutput(nixUpdateOutputs)}\n\n\n`); } diff --git a/apps/update-sources/src/caddy.ts b/apps/update-sources/src/caddy.ts index 719ca2f3..2bf4d782 100644 --- a/apps/update-sources/src/caddy.ts +++ b/apps/update-sources/src/caddy.ts @@ -34,7 +34,7 @@ ${Object.entries(plugins) } `; -export const updateCaddyPlugins = () => { +export const updateCaddyPlugins = (): string => { console.log(styleText(['magenta'], '\nUpdating caddy plugins:\n')); let updates = ''; diff --git a/apps/update-sources/src/misc.ts b/apps/update-sources/src/misc.ts index d31d39f8..acd150fc 100644 --- a/apps/update-sources/src/misc.ts +++ b/apps/update-sources/src/misc.ts @@ -52,41 +52,27 @@ export const runNixUpdate = ( attr: string, scope?: string, scopeAttr?: string, -): { stdout: string, stderr: string } => { - const getJsonArray = (jsonObj: string) => Array(JSON.parse(jsonObj))[0].slice(1).join(' '); - +): { + changelog: string | null + stdout: string + stderr: string +} => { const realAttr = scope ? `${attr}.x86_64-linux.${scope}.${scopeAttr}` : attr; + const cleanAttr = scope ? `${attr}.${scope}.${scopeAttr}` : attr; console.log(styleText(['magenta'], `\nUpdating ${realAttr}:\n`)); const OLD_VERSION = getAttrVersion(realAttr); - const execOptions = spawnSync( - `nix eval --json ${FLAKE}#${realAttr}.updateScript`, - [], - { shell: true, cwd: FLAKE }, - ); - - const options = execOptions.status === 0 ? - execOptions.stdout.toString().startsWith('[') ? - getJsonArray(execOptions.stdout.toString()) : - '-u' : - ''; - - const execution = spawnSync( - `nix-update --flake ${realAttr} ${options} --quiet --commit-message | head -n 1`, - [], - { shell: true, cwd: FLAKE }, - ); + const execution = spawnSync('nix-update', ['--flake', realAttr, '-u'], { cwd: FLAKE }); const NEW_VERSION = getAttrVersion(realAttr); return { - stdout: OLD_VERSION !== NEW_VERSION ? - scope ? - execution.stdout.toString().replaceAll(`${attr}.x86_64-linux.${scope}.`, '') : - execution.stdout.toString() : - '', + changelog: OLD_VERSION !== NEW_VERSION ? + `${cleanAttr}: ${OLD_VERSION} -> ${NEW_VERSION}\n` : + null, + stdout: execution.stdout.toString(), stderr: execution.stderr.toString(), }; }; diff --git a/modules/base/packages/default.nix b/modules/base/packages/default.nix index fe029041..85f35445 100644 --- a/modules/base/packages/default.nix +++ b/modules/base/packages/default.nix @@ -94,6 +94,7 @@ in { nix-output-monitor nix-melt nix-tree + nix-update progress tree gnugrep diff --git a/overlays/misc-fixes/default.nix b/overlays/misc-fixes/default.nix index c5977760..aef36d5b 100644 --- a/overlays/misc-fixes/default.nix +++ b/overlays/misc-fixes/default.nix @@ -1,13 +1,21 @@ final: prev: { - # FIXME: https://github.com/Mic92/nix-update/pull/330 - nix-update = prev.nix-update.overrideAttrs (o: { - version = o.version + "-mattpr"; + # FIXME: wait for next version of nix-update to reach nixpkgs (after 1.11.0) + # https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/ni/nix-update/package.nix + nix-update = prev.nix-update.overrideAttrs (o: let + inherit (builtins) fromTOML readFile substring; + + rev = "3d5866d1a8bc2f8197222e4814a8406298c36428"; src = prev.fetchFromGitHub { - owner = "matt1432"; + owner = "Mic92"; repo = "nix-update"; - rev = "30e33f8dc10b7452d6fa36f4c11cf61c2075ded6"; - hash = "sha256-Q7TJn1XEwGDaPZOvGdQ+B78e8mkZTtBrBVKngUCRABQ="; + inherit rev; + hash = "sha256-y3LY2tWDQUDjraAOjQ60tgegAws1gpb+I5u06XmQnoA="; }; + + pyproject = fromTOML (readFile "${src}/pyproject.toml"); + in { + version = "${pyproject.project.version}+${substring 0 7 rev}"; + inherit src; }); }