From 849ab8ad6cc25400e627d655ea270769a001f6c5 Mon Sep 17 00:00:00 2001 From: matt1432 Date: Mon, 17 Feb 2025 16:47:32 -0500 Subject: [PATCH] fix(update): use my fork of nix-update to run scripts --- apps/update-sources/src/misc.ts | 8 +++++- justfile | 2 +- overlays/misc-fixes/default.nix | 12 ++++++++- .../some-sass-language-server/default.nix | 27 +++++++------------ .../custom-sidebar/default.nix | 21 +++++---------- 5 files changed, 34 insertions(+), 36 deletions(-) diff --git a/apps/update-sources/src/misc.ts b/apps/update-sources/src/misc.ts index e96cd46b..208aab89 100644 --- a/apps/update-sources/src/misc.ts +++ b/apps/update-sources/src/misc.ts @@ -50,6 +50,8 @@ export const runNixUpdate = ( scope?: string, scopeAttr?: string, ): { stdout: string, stderr: string } => { + const getJsonArray = (jsonObj: string) => Array(JSON.parse(jsonObj))[0].slice(1).join(' '); + const realAttr = scope ? `${attr}.x86_64-linux.${scope}.${scopeAttr}` : attr; const OLD_VERSION = getAttrVersion(realAttr); @@ -60,9 +62,13 @@ export const runNixUpdate = ( ); const options = execOptions.status === 0 ? - Array(JSON.parse(execOptions.stdout.toString()))[0].slice(1).join(' ') : + execOptions.stdout.toString().startsWith('[') ? + getJsonArray(execOptions.stdout.toString()) : + '-u' : ''; + console.log(`nix-update --flake ${realAttr} ${options} --write-commit-message >(head -n 1 -) > /dev/null`); + const execution = spawnSync( `nix-update --flake ${realAttr} ${options} --write-commit-message >(head -n 1 -) > /dev/null`, [], diff --git a/justfile b/justfile index 68207219..82769b27 100644 --- a/justfile +++ b/justfile @@ -20,5 +20,5 @@ pin args: nix run "$FLAKE"#pin-inputs -- "$@" [positional-arguments] -update args: +up args: nix run "$FLAKE"#update-sources -- "$@" diff --git a/overlays/misc-fixes/default.nix b/overlays/misc-fixes/default.nix index 0e2fe68a..90a58a79 100644 --- a/overlays/misc-fixes/default.nix +++ b/overlays/misc-fixes/default.nix @@ -1 +1,11 @@ -final: prev: {} +final: prev: { + # FIXME: do some other stuff and make PR + nix-update = prev.nix-update.overrideAttrs (o: { + src = prev.fetchFromGitHub { + owner = "matt1432"; + repo = "nix-update"; + rev = "21de1ebd7e7c22de03f0a9c7e1f6cd488fa96d03"; + hash = "sha256-ukapzy0+mS4rorX3D22lRKX/D9TXmkq8W2YNDQIq7A8="; + }; + }); +} diff --git a/packages/some-sass-language-server/default.nix b/packages/some-sass-language-server/default.nix index 6f2f3538..0a555c2b 100644 --- a/packages/some-sass-language-server/default.nix +++ b/packages/some-sass-language-server/default.nix @@ -3,7 +3,6 @@ lib, buildNpmPackage, makeWrapper, - nix-update-script, writeShellApplication, # update script deps nodejs_latest, @@ -33,23 +32,15 @@ in npmDepsHash = "sha256-BRo71A07BhrioiBFisCR01OrVFTIagVTIClZ2Tpjidk="; - passthru.updateScript = let - script = writeShellApplication { - name = "update"; - runtimeInputs = [ - nodejs_latest - prefetch-npm-deps - jq - ]; - text = import ./update.nix; - }; - in - nix-update-script { - extraArgs = [ - "--version=skip" - "; ${script}" - ]; - }; + passthru.updateScript = writeShellApplication { + name = "update"; + runtimeInputs = [ + nodejs_latest + prefetch-npm-deps + jq + ]; + text = import ./update.nix; + }; meta = { mainProgram = pname; diff --git a/scopedPackages/lovelace-components/custom-sidebar/default.nix b/scopedPackages/lovelace-components/custom-sidebar/default.nix index ba6c87b5..dfba36eb 100644 --- a/scopedPackages/lovelace-components/custom-sidebar/default.nix +++ b/scopedPackages/lovelace-components/custom-sidebar/default.nix @@ -4,7 +4,6 @@ nodejs, pnpm, stdenv, - nix-update-script, ... }: let inherit (builtins) fromJSON readFile; @@ -36,18 +35,10 @@ in hash = "sha256-II8expO942jHylgbiePr5+V+t+UVh7fenffoyVFn/8k="; }; - passthru.updateScript = let - script = "${concatTextFile { - name = "update"; - files = [./update.sh]; - executable = true; - destination = "/bin/update"; - }}/bin/update"; - in - nix-update-script { - extraArgs = [ - "--version=skip" - "; ${script}" - ]; - }; + passthru.updateScript = concatTextFile { + name = "update"; + files = [./update.sh]; + executable = true; + destination = "/bin/update"; + }; })