From d3c0ecb5d46fd78125157bca756e724be3ebc874 Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Mon, 8 Jun 2026 14:45:17 +0200 Subject: [PATCH 1/2] feat: auto update frontend flake hash --- container/flake.lock | 6 ++--- devenv.lock | 64 ++++++++++++++++++++++++++++++++++++++++++-- flake.nix | 11 ++++---- justfile | 29 +++++++++++++++++++- 4 files changed, 98 insertions(+), 12 deletions(-) diff --git a/container/flake.lock b/container/flake.lock index d81bd13..d315022 100644 --- a/container/flake.lock +++ b/container/flake.lock @@ -2,11 +2,11 @@ "nodes": { "nixpkgs": { "locked": { - "lastModified": 1779467186, - "narHash": "sha256-nOesoDCiXcUftqbRBMz9tt4blI5PvljMWbm3kuCA+0s=", + "lastModified": 1780511130, + "narHash": "sha256-2v9lT4ya59Lh1FqPeLnz1MoX9y/wz2huqfe9RtQZITk=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b77b3de8775677f84492abe84635f87b0e153f0f", + "rev": "535f3e6942cb1cead3929c604320d3db54b542b9", "type": "github" }, "original": { diff --git a/devenv.lock b/devenv.lock index e6e8ef6..3f0905b 100644 --- a/devenv.lock +++ b/devenv.lock @@ -17,6 +17,62 @@ "type": "github" } }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1767039857, + "owner": "NixOS", + "repo": "flake-compat", + "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "flake-compat", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1778507602, + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "61ab0e80d9c7ab14c256b5b453d8b3fb0189ba0a", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1762808025, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "cb5e3fdca1de58ccbc3ef53de65bd372b48f567c", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1779102034, @@ -52,11 +108,15 @@ "root": { "inputs": { "devenv": "devenv", + "git-hooks": "git-hooks", "nixpkgs": "nixpkgs", - "nixpkgs-cmake3": "nixpkgs-cmake3" + "nixpkgs-cmake3": "nixpkgs-cmake3", + "pre-commit-hooks": [ + "git-hooks" + ] } } }, "root": "root", "version": 7 -} \ No newline at end of file +} diff --git a/flake.nix b/flake.nix index a256857..91e1038 100644 --- a/flake.nix +++ b/flake.nix @@ -36,6 +36,11 @@ cargo = rustToolchain; rustc = rustToolchain; }; + frontendCargoDeps = rustPlatform.fetchCargoVendor { + src = ./.; + name = "trictrac-frontend-vendor"; + hash = "sha256-XBxdRT/f69GDfVc18/DnnAiY1vjMGMWfcYot0K0jevg="; + }; # Must match the wasm-bindgen version in Cargo.lock wasm-bindgen-version = "0.2.118"; # wasm-bindgen-version = "0.2.121"; @@ -52,12 +57,6 @@ # hash = "sha256-DPdCDPTAPBrbqLUqnCwQu1dePs9lGg85JCJOCIr9qjU="; # }; # }; - - frontendCargoDeps = rustPlatform.fetchCargoVendor { - src = ./.; - name = "trictrac-frontend-vendor"; - hash = "sha256-R75zHXKhv0nkBv6U24ZCAtwp1yaSbr0bFywWQHwhSkM="; - }; in final.stdenv.mkDerivation { name = "trictrac-front"; diff --git a/justfile b/justfile index 3ae77d1..6f39fa5 100644 --- a/justfile +++ b/justfile @@ -9,9 +9,36 @@ bump version: git flow release start {{version}} sed -i '/^\[workspace\.package\]/,/^\[/{s/^version = ".*"/version = "{{version}}"/}' Cargo.toml sed -i 's/version = "[0-9.]*"; # trictrac-version/version = "{{version}}"; # trictrac-version/' flake.nix + just frontend-flake-hash git add Cargo.toml flake.nix git commit -m "chore: bump version to {{version}}" - @echo "Done. Finish with: git flow release finish {{version}}" + @echo "Done. Finish with: `git flow release finish {{version}}`" + +# Get new trictrac front-end nix package hash and update flake.nix with it +frontend-flake-hash: + #!/usr/bin/env bash + set -euo pipefail + FAKE_HASH="sha256-AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=" + # Match only non-commented hash lines (i.e. lines where 'hash' is the first non-space token) + CURRENT_HASH=$(grep -P '^\s+hash = "' flake.nix | grep -oP 'sha256-[^"]+' | head -1) + echo "Current hash: $CURRENT_HASH" + sed -i "s|$CURRENT_HASH|$FAKE_HASH|" flake.nix + set +e + OUTPUT=$(nix build .#trictrac-front --no-link 2>&1) + set -e + NEW_HASH=$(echo "$OUTPUT" | grep -oP 'got:\s+\Ksha256-\S+' || true) + if [ -n "$NEW_HASH" ]; then + sed -i "s|$FAKE_HASH|$NEW_HASH|" flake.nix + if [ "$NEW_HASH" = "$CURRENT_HASH" ]; then + echo "Hash already up to date: $CURRENT_HASH" + else + echo "Updated: $CURRENT_HASH → $NEW_HASH" + fi + else + sed -i "s|$FAKE_HASH|$CURRENT_HASH|" flake.nix + printf "Unexpected build output (no hash mismatch found):\n%s\n" "$OUTPUT" >&2 + exit 1 + fi # Sync pages content to production server pages-deploy: From 8cf10b1b62321938d5310cd71c6909d4ff0df0f0 Mon Sep 17 00:00:00 2001 From: Henri Bourcereau Date: Mon, 8 Jun 2026 14:45:35 +0200 Subject: [PATCH 2/2] chore: bump version to 0.2.17 --- Cargo.toml | 2 +- flake.nix | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 52537ac..7897d03 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,5 +1,5 @@ [workspace.package] -version = "0.2.16" +version = "0.2.17" [workspace] resolver = "2" diff --git a/flake.nix b/flake.nix index 91e1038..89d3586 100644 --- a/flake.nix +++ b/flake.nix @@ -102,7 +102,7 @@ trictrac = with final; rustPlatform.buildRustPackage { pname = "trictrac"; - version = "0.2.16"; # trictrac-version + version = "0.2.17"; # trictrac-version src = ./.; nativeBuildInputs = [ pkg-config ];