Extract kernel version from flake input to ensure version in sync

This commit is contained in:
Lan Tian 2026-03-04 23:39:18 -08:00
parent 8ea11ba1b5
commit e8fd643d68
No known key found for this signature in database
GPG Key ID: 04E66B6B25A0862B
2 changed files with 21 additions and 15 deletions

View File

@ -129,6 +129,8 @@
cachyosKernels = self.legacyPackages."${final.stdenv.hostPlatform.system}";
};
cachyos-kernel-input-path = inputs.cachyos-kernel.outPath;
mkCachyKernel =
{ buildLinux, pkgs, ... }@args:
(import ./kernel-cachyos/mkCachyKernel.nix) {

View File

@ -1,25 +1,29 @@
import json
from pathlib import Path
import re
import subprocess
import requests
import tempfile
def get_srctag(variant: str = "latest") -> str:
pkgbuild_path = f"linux-cachyos-{variant}" if variant != "latest" else "linux-cachyos"
url = f"https://github.com/CachyOS/linux-cachyos/raw/refs/heads/master/{pkgbuild_path}/PKGBUILD"
pkgbuild = requests.get(url).text
with tempfile.TemporaryDirectory(ignore_cleanup_errors=True) as dir:
subprocess.run(
["nix", "build", ".#cachyos-kernel-input-path", "-o", f"{dir}/result"], check=True
)
script = pkgbuild + "\necho $_srctag"
result = subprocess.run(
["bash"],
input=script,
capture_output=True,
text=True,
check=True,
)
return result.stdout.strip()
pkgbuild_path = f"linux-cachyos-{variant}" if variant != "latest" else "linux-cachyos"
with open(f"{dir}/result/{pkgbuild_path}/PKGBUILD") as f:
pkgbuild = f.read()
script = pkgbuild + "\necho $_srctag"
result = subprocess.run(
["bash"],
input=script,
capture_output=True,
text=True,
check=True,
)
return result.stdout.strip()
def nix_sha256_to_sri(hash: str) -> str: