Wrap ZFS CachyOS update script as flake app to workaround missing PATH

This commit is contained in:
Lan Tian 2026-02-10 19:17:50 -08:00
parent 197a74778b
commit 565b230f25
No known key found for this signature in database
GPG Key ID: 04E66B6B25A0862B
3 changed files with 28 additions and 5 deletions

View File

@ -66,9 +66,7 @@ jobs:
run: | run: |
export TMPDIR=/nix/tmpdir export TMPDIR=/nix/tmpdir
nix flake update nix flake update
nix run .#update-zfs-cachyos
chmod +x zfs-cachyos/update.py
zfs-cachyos/update.py
- name: Commit back to repository - name: Commit back to repository
uses: stefanzweifel/git-auto-commit-action@v7 uses: stefanzweifel/git-auto-commit-action@v7

View File

@ -68,6 +68,25 @@
# Packages only contain linux-cachyos-* due to Flake schema requirements # Packages only contain linux-cachyos-* due to Flake schema requirements
packages = lib.filterAttrs (_: lib.isDerivation) legacyPackages; 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 # Allow build unfree modules such as nvidia_x11
_module.args.pkgs = lib.mkForce ( _module.args.pkgs = lib.mkForce (
import inputs.nixpkgs { import inputs.nixpkgs {

View File

@ -99,8 +99,14 @@ def main() -> int:
print("nix-prefetch-git execution failed, exiting") print("nix-prefetch-git execution failed, exiting")
return 1 return 1
script_dir = Path(__file__).parent current = Path.cwd()
output_file = script_dir / "version.json" 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) save_version_info(latest_branch, prefetch_data, output_file)