nix: add tui lockfile update script

This commit is contained in:
Ari Lotter 2026-04-10 00:46:37 -04:00
parent 8c1ba639c6
commit 658cd2dd4c
6 changed files with 818 additions and 27 deletions

2
.envrc
View file

@ -1,5 +1,5 @@
watch_file pyproject.toml uv.lock watch_file pyproject.toml uv.lock
watch_file ui-tui/package-lock.json ui-tui/package.json watch_file ui-tui/package-lock.json ui-tui/package.json
watch_file nix/ watch_file flake.nix flake.lock nix/devShell.nix nix/tui.nix nix/package.nix nix/python.nix
use flake use flake

21
flake.lock generated
View file

@ -36,6 +36,26 @@
"type": "github" "type": "github"
} }
}, },
"npm-lockfile-fix": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1734767823,
"narHash": "sha256-UHVfdyuOdGEDRPkoSJRsX7HhN8oL/g903QUlzhBTadI=",
"owner": "jeslie0",
"repo": "npm-lockfile-fix",
"rev": "193e463bf27a36f85775eddde7189f93a493d2b3",
"type": "github"
},
"original": {
"owner": "jeslie0",
"repo": "npm-lockfile-fix",
"type": "github"
}
},
"pyproject-build-systems": { "pyproject-build-systems": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -124,6 +144,7 @@
"inputs": { "inputs": {
"flake-parts": "flake-parts", "flake-parts": "flake-parts",
"nixpkgs": "nixpkgs", "nixpkgs": "nixpkgs",
"npm-lockfile-fix": "npm-lockfile-fix",
"pyproject-build-systems": "pyproject-build-systems", "pyproject-build-systems": "pyproject-build-systems",
"pyproject-nix": "pyproject-nix_2", "pyproject-nix": "pyproject-nix_2",
"uv2nix": "uv2nix_2" "uv2nix": "uv2nix_2"

View file

@ -19,11 +19,20 @@
url = "github:pyproject-nix/build-system-pkgs"; url = "github:pyproject-nix/build-system-pkgs";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
}; };
npm-lockfile-fix = {
url = "github:jeslie0/npm-lockfile-fix";
inputs.nixpkgs.follows = "nixpkgs";
};
}; };
outputs = inputs: outputs =
inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } { inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "aarch64-darwin" ]; systems = [
"x86_64-linux"
"aarch64-linux"
"aarch64-darwin"
];
imports = [ imports = [
./nix/packages.nix ./nix/packages.nix

View file

@ -2,13 +2,15 @@
{ inputs, ... }: { inputs, ... }:
{ {
perSystem = perSystem =
{ pkgs, ... }: { pkgs, inputs', ... }:
let let
hermesVenv = pkgs.callPackage ./python.nix { hermesVenv = pkgs.callPackage ./python.nix {
inherit (inputs) uv2nix pyproject-nix pyproject-build-systems; inherit (inputs) uv2nix pyproject-nix pyproject-build-systems;
}; };
hermesTui = pkgs.callPackage ./tui.nix { }; hermesTui = pkgs.callPackage ./tui.nix {
npm-lockfile-fix = inputs'.npm-lockfile-fix.packages.default;
};
# Import bundled skills, excluding runtime caches # Import bundled skills, excluding runtime caches
bundledSkills = pkgs.lib.cleanSourceWith { bundledSkills = pkgs.lib.cleanSourceWith {
@ -57,11 +59,11 @@
${pkgs.lib.concatMapStringsSep "\n" ${pkgs.lib.concatMapStringsSep "\n"
(name: '' (name: ''
makeWrapper ${hermesVenv}/bin/${name} $out/bin/${name} \ makeWrapper ${hermesVenv}/bin/${name} $out/bin/${name} \
--suffix PATH : "${runtimePath}" \ --suffix PATH : "${runtimePath}" \
--set HERMES_BUNDLED_SKILLS $out/share/hermes-agent/skills \ --set HERMES_BUNDLED_SKILLS $out/share/hermes-agent/skills \
--set HERMES_TUI_DIR $out/ui-tui \ --set HERMES_TUI_DIR $out/ui-tui \
--set HERMES_PYTHON ${hermesVenv}/bin/python3 --set HERMES_PYTHON ${hermesVenv}/bin/python3
'') '')
[ [
"hermes" "hermes"

View file

@ -1,10 +1,10 @@
# nix/tui.nix — Hermes TUI (Ink/React) compiled with tsc and bundled # nix/tui.nix — Hermes TUI (Ink/React) compiled with tsc and bundled
{ pkgs, ... }: { pkgs, npm-lockfile-fix, ... }:
let let
src = ../ui-tui; src = ../ui-tui;
npmDeps = pkgs.fetchNpmDeps { npmDeps = pkgs.fetchNpmDeps {
inherit src; inherit src;
hash = "sha256-iz6TrWec4MpfDLZR48V6XHoKnZkEn9x2t97YOqWZt5k="; hash = "sha256-tlQ43Dv5S2p5Aw6ChSTvPXcI5/kkXHoeZsTlSLm75eM=";
}; };
packageJson = builtins.fromJSON (builtins.readFile (src + "/package.json")); packageJson = builtins.fromJSON (builtins.readFile (src + "/package.json"));
@ -34,6 +34,29 @@ pkgs.buildNpmPackage {
runHook postInstall runHook postInstall
''; '';
nativeBuildInputs = [
(pkgs.writeShellScriptBin "update_tui_lockfile" ''
set -euo pipefail
# get root of repo
REPO_ROOT=$(git rev-parse --show-toplevel)
# cd into ui-tui and reinstall
cd "$REPO_ROOT/ui-tui"
rm -rf node_modules/
npm install --package-lock-only
${pkgs.lib.getExe' npm-lockfile-fix "npm-lockfile-fix"} ./package-lock.json
# compute the new hash
sed -i "s/hash = \"[^\"]*\";/hash = \"\";/" "$REPO_ROOT/nix/tui.nix"
NIX_OUTPUT=$(nix build .#tui 2>&1 || true)
NEW_HASH=$(echo "$NIX_OUTPUT" | grep 'got:' | awk '{print $2}')
echo got new hash $NEW_HASH
sed -i "s|hash = \"[^\"]*\";|hash = \"$NEW_HASH\";|" "$REPO_ROOT/nix/tui.nix"
echo "Updated npm hash in $NIX_FILE to $NEW_HASH"
'')
];
passthru.devShellHook = '' passthru.devShellHook = ''
STAMP=".nix-stamps/hermes-tui" STAMP=".nix-stamps/hermes-tui"
STAMP_VALUE="${npmLockHash}" STAMP_VALUE="${npmLockHash}"

764
ui-tui/package-lock.json generated

File diff suppressed because it is too large Load diff