feat(update): switch to upstream nix-update with my PR merged

This commit is contained in:
matt1432 2025-04-16 10:36:19 -04:00
parent 1c59ce72e4
commit 81b61228e0
5 changed files with 32 additions and 35 deletions
apps/update-sources/src
modules/base/packages
overlays/misc-fixes

View file

@ -125,7 +125,9 @@ const main = async() => {
): void => { ): void => {
const execution = runNixUpdate(attr, scope, scopeAttr); const execution = runNixUpdate(attr, scope, scopeAttr);
nixUpdateOutputs += execution.stdout; if (execution.changelog) {
nixUpdateOutputs += execution.changelog;
}
console.log(execution.stderr); console.log(execution.stderr);
console.log(execution.stdout); console.log(execution.stdout);
}; };
@ -168,10 +170,10 @@ const main = async() => {
if (vuetorrentOutput.length > 5) { if (vuetorrentOutput.length > 5) {
output.push(`Misc Sources:\n${indentOutput(vuetorrentOutput)}\n\n\n`); 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`); 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`); output.push(`nix-update executions:\n${indentOutput(nixUpdateOutputs)}\n\n\n`);
} }

View file

@ -34,7 +34,7 @@ ${Object.entries(plugins)
} }
`; `;
export const updateCaddyPlugins = () => { export const updateCaddyPlugins = (): string => {
console.log(styleText(['magenta'], '\nUpdating caddy plugins:\n')); console.log(styleText(['magenta'], '\nUpdating caddy plugins:\n'));
let updates = ''; let updates = '';

View file

@ -52,41 +52,27 @@ export const runNixUpdate = (
attr: string, attr: string,
scope?: string, scope?: string,
scopeAttr?: 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 realAttr = scope ? `${attr}.x86_64-linux.${scope}.${scopeAttr}` : attr;
const cleanAttr = scope ? `${attr}.${scope}.${scopeAttr}` : attr;
console.log(styleText(['magenta'], `\nUpdating ${realAttr}:\n`)); console.log(styleText(['magenta'], `\nUpdating ${realAttr}:\n`));
const OLD_VERSION = getAttrVersion(realAttr); const OLD_VERSION = getAttrVersion(realAttr);
const execOptions = spawnSync( const execution = spawnSync('nix-update', ['--flake', realAttr, '-u'], { cwd: FLAKE });
`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 NEW_VERSION = getAttrVersion(realAttr); const NEW_VERSION = getAttrVersion(realAttr);
return { return {
stdout: OLD_VERSION !== NEW_VERSION ? changelog: OLD_VERSION !== NEW_VERSION ?
scope ? `${cleanAttr}: ${OLD_VERSION} -> ${NEW_VERSION}\n` :
execution.stdout.toString().replaceAll(`${attr}.x86_64-linux.${scope}.`, '') : null,
execution.stdout.toString() : stdout: execution.stdout.toString(),
'',
stderr: execution.stderr.toString(), stderr: execution.stderr.toString(),
}; };
}; };

View file

@ -94,6 +94,7 @@ in {
nix-output-monitor nix-output-monitor
nix-melt nix-melt
nix-tree nix-tree
nix-update
progress progress
tree tree
gnugrep gnugrep

View file

@ -1,13 +1,21 @@
final: prev: { final: prev: {
# FIXME: https://github.com/Mic92/nix-update/pull/330 # FIXME: wait for next version of nix-update to reach nixpkgs (after 1.11.0)
nix-update = prev.nix-update.overrideAttrs (o: { # https://github.com/NixOS/nixpkgs/blob/master/pkgs/by-name/ni/nix-update/package.nix
version = o.version + "-mattpr"; nix-update = prev.nix-update.overrideAttrs (o: let
inherit (builtins) fromTOML readFile substring;
rev = "3d5866d1a8bc2f8197222e4814a8406298c36428";
src = prev.fetchFromGitHub { src = prev.fetchFromGitHub {
owner = "matt1432"; owner = "Mic92";
repo = "nix-update"; repo = "nix-update";
rev = "30e33f8dc10b7452d6fa36f4c11cf61c2075ded6"; inherit rev;
hash = "sha256-Q7TJn1XEwGDaPZOvGdQ+B78e8mkZTtBrBVKngUCRABQ="; hash = "sha256-y3LY2tWDQUDjraAOjQ60tgegAws1gpb+I5u06XmQnoA=";
}; };
pyproject = fromTOML (readFile "${src}/pyproject.toml");
in {
version = "${pyproject.project.version}+${substring 0 7 rev}";
inherit src;
}); });
} }