From 565b230f25c5e2a091824fac194c47613a1948af Mon Sep 17 00:00:00 2001 From: Lan Tian Date: Tue, 10 Feb 2026 19:17:50 -0800 Subject: [PATCH] Wrap ZFS CachyOS update script as flake app to workaround missing PATH --- .github/workflows/auto-update.yml | 4 +--- flake.nix | 19 +++++++++++++++++++ zfs-cachyos/update.py | 10 ++++++++-- 3 files changed, 28 insertions(+), 5 deletions(-) diff --git a/.github/workflows/auto-update.yml b/.github/workflows/auto-update.yml index dd0e252..01c6e59 100644 --- a/.github/workflows/auto-update.yml +++ b/.github/workflows/auto-update.yml @@ -66,9 +66,7 @@ jobs: run: | export TMPDIR=/nix/tmpdir nix flake update - - chmod +x zfs-cachyos/update.py - zfs-cachyos/update.py + nix run .#update-zfs-cachyos - name: Commit back to repository uses: stefanzweifel/git-auto-commit-action@v7 diff --git a/flake.nix b/flake.nix index b3f7b98..cd3a0a4 100644 --- a/flake.nix +++ b/flake.nix @@ -68,6 +68,25 @@ # Packages only contain linux-cachyos-* due to Flake schema requirements packages = lib.filterAttrs (_: lib.isDerivation) legacyPackages; + apps.update-zfs-cachyos = { + type = "app"; + program = + let + python = pkgs.python3.withPackages (ps: [ ps.requests ]); + script = pkgs.writeShellApplication { + name = "update-zfs-cachyos"; + runtimeInputs = [ + python + pkgs.nix-prefetch-git + ]; + text = '' + python3 ${./zfs-cachyos/update.py} + ''; + }; + in + lib.getExe script; + }; + # Allow build unfree modules such as nvidia_x11 _module.args.pkgs = lib.mkForce ( import inputs.nixpkgs { diff --git a/zfs-cachyos/update.py b/zfs-cachyos/update.py index 30e09ae..1a58f5b 100755 --- a/zfs-cachyos/update.py +++ b/zfs-cachyos/update.py @@ -99,8 +99,14 @@ def main() -> int: print("nix-prefetch-git execution failed, exiting") return 1 - script_dir = Path(__file__).parent - output_file = script_dir / "version.json" + current = Path.cwd() + while not (current / "flake.lock").exists(): + if current == current.parent: + print("Could not find flake.lock in any parent directory, exiting") + return 1 + current = current.parent + + output_file = current / "zfs-cachyos" / "version.json" save_version_info(latest_branch, prefetch_data, output_file)