mirror of
https://github.com/xddxdd/nix-cachyos-kernel.git
synced 2026-07-03 11:08:07 +02:00
Use prepatched kernel source code from github.com/CachyOS/linux/releases
This commit is contained in:
parent
30dccb243a
commit
a3da912207
1
.github/workflows/auto-update.yml
vendored
1
.github/workflows/auto-update.yml
vendored
@ -66,6 +66,7 @@ jobs:
|
||||
run: |
|
||||
export TMPDIR=/nix/tmpdir
|
||||
nix flake update
|
||||
nix run .#update-kernel-cachyos
|
||||
nix run .#update-zfs-cachyos
|
||||
|
||||
- name: Commit back to repository
|
||||
|
||||
17
flake.nix
17
flake.nix
@ -80,23 +80,30 @@
|
||||
# Packages only contain linux-cachyos-* due to Flake schema requirements
|
||||
packages = lib.filterAttrs (_: lib.isDerivation) legacyPackages;
|
||||
|
||||
apps.update-zfs-cachyos = {
|
||||
apps =
|
||||
let
|
||||
mkApp = name: script: {
|
||||
type = "app";
|
||||
program =
|
||||
let
|
||||
python = pkgs.python3.withPackages (ps: [ ps.requests ]);
|
||||
script = pkgs.writeShellApplication {
|
||||
name = "update-zfs-cachyos";
|
||||
app = pkgs.writeShellApplication {
|
||||
inherit name;
|
||||
runtimeInputs = [
|
||||
python
|
||||
pkgs.nix-prefetch-git
|
||||
];
|
||||
text = ''
|
||||
python3 ${./zfs-cachyos/update.py}
|
||||
python3 ${script}
|
||||
'';
|
||||
};
|
||||
in
|
||||
lib.getExe script;
|
||||
lib.getExe app;
|
||||
};
|
||||
in
|
||||
{
|
||||
update-kernel-cachyos = mkApp "update-lernel-cachyos" ./kernel-cachyos/update.py;
|
||||
update-zfs-cachyos = mkApp "update-zfs-cachyos" ./zfs-cachyos/update.py;
|
||||
};
|
||||
|
||||
# Allow build unfree modules such as nvidia_x11
|
||||
|
||||
@ -2,76 +2,81 @@
|
||||
inputs,
|
||||
callPackage,
|
||||
lib,
|
||||
linux_latest,
|
||||
linux_testing,
|
||||
linux,
|
||||
fetchurl,
|
||||
...
|
||||
}:
|
||||
let
|
||||
mkCachyKernel = callPackage ./mkCachyKernel.nix { inherit inputs; };
|
||||
|
||||
linuxSources = lib.mapAttrs (_: v: {
|
||||
inherit (v) version;
|
||||
src = fetchurl {
|
||||
inherit (v) url hash;
|
||||
};
|
||||
}) (lib.importJSON ./version.json);
|
||||
in
|
||||
builtins.listToAttrs (
|
||||
builtins.map (v: lib.nameValuePair v.pname v) [
|
||||
# Latest kernel, provide all LTO/CPU arch variants
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-latest";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-latest-x86_64-v2";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos";
|
||||
processorOpt = "x86_64-v2";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-latest-x86_64-v3";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos";
|
||||
processorOpt = "x86_64-v3";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-latest-x86_64-v4";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos";
|
||||
processorOpt = "x86_64-v4";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-latest-zen4";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos";
|
||||
processorOpt = "zen4";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-latest-lto";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos";
|
||||
lto = "thin";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-latest-lto-x86_64-v2";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos";
|
||||
lto = "thin";
|
||||
processorOpt = "x86_64-v2";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-latest-lto-x86_64-v3";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos";
|
||||
lto = "thin";
|
||||
processorOpt = "x86_64-v3";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-latest-lto-x86_64-v4";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos";
|
||||
lto = "thin";
|
||||
processorOpt = "x86_64-v4";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-latest-lto-zen4";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos";
|
||||
lto = "thin";
|
||||
processorOpt = "zen4";
|
||||
@ -80,63 +85,63 @@ builtins.listToAttrs (
|
||||
# LTS kernel
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-lts";
|
||||
inherit (linux) version src;
|
||||
inherit (linuxSources.lts) version src;
|
||||
configVariant = "linux-cachyos-lts";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-lts-x86_64-v2";
|
||||
inherit (linux) version src;
|
||||
inherit (linuxSources.lts) version src;
|
||||
configVariant = "linux-cachyos-lts";
|
||||
processorOpt = "x86_64-v2";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-lts-x86_64-v3";
|
||||
inherit (linux) version src;
|
||||
inherit (linuxSources.lts) version src;
|
||||
configVariant = "linux-cachyos-lts";
|
||||
processorOpt = "x86_64-v3";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-lts-x86_64-v4";
|
||||
inherit (linux) version src;
|
||||
inherit (linuxSources.lts) version src;
|
||||
configVariant = "linux-cachyos-lts";
|
||||
processorOpt = "x86_64-v4";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-lts-zen4";
|
||||
inherit (linux) version src;
|
||||
inherit (linuxSources.lts) version src;
|
||||
configVariant = "linux-cachyos-lts";
|
||||
processorOpt = "zen4";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-lts-lto";
|
||||
inherit (linux) version src;
|
||||
inherit (linuxSources.lts) version src;
|
||||
configVariant = "linux-cachyos-lts";
|
||||
lto = "thin";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-lts-lto-x86_64-v2";
|
||||
inherit (linux) version src;
|
||||
inherit (linuxSources.lts) version src;
|
||||
configVariant = "linux-cachyos-lts";
|
||||
lto = "thin";
|
||||
processorOpt = "x86_64-v2";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-lts-lto-x86_64-v3";
|
||||
inherit (linux) version src;
|
||||
inherit (linuxSources.lts) version src;
|
||||
configVariant = "linux-cachyos-lts";
|
||||
lto = "thin";
|
||||
processorOpt = "x86_64-v3";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-lts-lto-x86_64-v4";
|
||||
inherit (linux) version src;
|
||||
inherit (linuxSources.lts) version src;
|
||||
configVariant = "linux-cachyos-lts";
|
||||
lto = "thin";
|
||||
processorOpt = "x86_64-v4";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-lts-lto-zen4";
|
||||
inherit (linux) version src;
|
||||
inherit (linuxSources.lts) version src;
|
||||
configVariant = "linux-cachyos-lts";
|
||||
lto = "thin";
|
||||
processorOpt = "zen4";
|
||||
@ -145,40 +150,40 @@ builtins.listToAttrs (
|
||||
# Additional CachyOS provided variants
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-bmq";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-bmq";
|
||||
cpusched = "bmq";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-bmq-lto";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-bmq";
|
||||
lto = "thin";
|
||||
cpusched = "bmq";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-bore";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-bore";
|
||||
cpusched = "bore";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-bore-lto";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-bore";
|
||||
lto = "thin";
|
||||
cpusched = "bore";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-deckify";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-deckify";
|
||||
acpiCall = true;
|
||||
handheld = true;
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-deckify-lto";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-deckify";
|
||||
lto = "thin";
|
||||
acpiCall = true;
|
||||
@ -186,51 +191,51 @@ builtins.listToAttrs (
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-eevdf";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-eevdf";
|
||||
cpusched = "eevdf";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-eevdf-lto";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-eevdf";
|
||||
cpusched = "eevdf";
|
||||
lto = "thin";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-hardened";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-hardened";
|
||||
hardened = true;
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-hardened-lto";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-hardened";
|
||||
hardened = true;
|
||||
lto = "thin";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-rc";
|
||||
inherit (linux_testing) version src;
|
||||
inherit (linuxSources.rc) version src;
|
||||
configVariant = "linux-cachyos-rc";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-rc-lto";
|
||||
inherit (linux_testing) version src;
|
||||
inherit (linuxSources.rc) version src;
|
||||
configVariant = "linux-cachyos-rc";
|
||||
lto = "thin";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-rt-bore";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-rt-bore";
|
||||
rt = true;
|
||||
cpusched = "bore";
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-rt-bore-lto";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-rt-bore";
|
||||
rt = true;
|
||||
cpusched = "bore";
|
||||
@ -238,7 +243,7 @@ builtins.listToAttrs (
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-server";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-server";
|
||||
cpusched = "eevdf";
|
||||
hzTicks = "300";
|
||||
@ -246,7 +251,7 @@ builtins.listToAttrs (
|
||||
})
|
||||
(mkCachyKernel {
|
||||
pname = "linux-cachyos-server-lto";
|
||||
inherit (linux_latest) version src;
|
||||
inherit (linuxSources.latest) version src;
|
||||
configVariant = "linux-cachyos-server";
|
||||
cpusched = "eevdf";
|
||||
hzTicks = "300";
|
||||
|
||||
@ -83,8 +83,7 @@ lib.makeOverridable (
|
||||
|
||||
cachyosConfigFile = "${inputs.cachyos-kernel.outPath}/${configVariant}/config";
|
||||
cachyosPatches = builtins.map (p: "${inputs.cachyos-kernel-patches.outPath}/${patchVersion}/${p}") (
|
||||
[ "all/0001-cachyos-base-all.patch" ]
|
||||
++ (lib.optional (cpusched == "bore") "sched/0001-bore-cachy.patch")
|
||||
(lib.optional (cpusched == "bore") "sched/0001-bore-cachy.patch")
|
||||
++ (lib.optional (cpusched == "bmq") "sched/0001-prjc-cachy.patch")
|
||||
++ (lib.optional hardened "misc/0001-hardened.patch")
|
||||
++ (lib.optional rt "misc/0001-rt-i915.patch")
|
||||
|
||||
84
kernel-cachyos/update.py
Normal file
84
kernel-cachyos/update.py
Normal file
@ -0,0 +1,84 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
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
|
||||
|
||||
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:
|
||||
cmd = ["nix", "hash", "convert", "--hash-algo", "sha256", "--to", "sri", hash]
|
||||
|
||||
print(f"Running command: {' '.join(cmd)}")
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
|
||||
|
||||
if result.returncode != 0:
|
||||
raise RuntimeError(f"nix hash command failed with return code: {result.returncode}")
|
||||
|
||||
output = result.stdout.strip()
|
||||
if not output:
|
||||
raise RuntimeError("nix hash output is empty")
|
||||
|
||||
return output
|
||||
|
||||
|
||||
def run_nix_prefetch_url(url: str) -> str:
|
||||
cmd = ["nix-prefetch-url", url]
|
||||
|
||||
print(f"Running command: {' '.join(cmd)}")
|
||||
result = subprocess.run(cmd, capture_output=True, text=True, timeout=300)
|
||||
|
||||
if result.returncode != 0:
|
||||
raise RuntimeError(f"nix-prefetch-url command failed with return code: {result.returncode}")
|
||||
|
||||
output = result.stdout.strip()
|
||||
if not output:
|
||||
raise RuntimeError("nix-prefetch-url output is empty")
|
||||
|
||||
return output
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
versions = {}
|
||||
for variant in ["latest", "lts", "rc"]:
|
||||
print(f"{variant=}")
|
||||
srctag = get_srctag(variant)
|
||||
real_version = "-".join(srctag.split("-")[1:-1])
|
||||
print(f"{srctag=} {real_version=}")
|
||||
|
||||
url = f"https://github.com/CachyOS/linux/releases/download/{srctag}/{srctag}.tar.gz"
|
||||
print(f"{url=}")
|
||||
hash = run_nix_prefetch_url(url)
|
||||
hash = nix_sha256_to_sri(hash)
|
||||
print(f"{hash=}")
|
||||
versions[variant] = {
|
||||
"version": real_version,
|
||||
"url": url,
|
||||
"hash": hash,
|
||||
}
|
||||
|
||||
current = Path.cwd()
|
||||
while not (current / "flake.lock").exists():
|
||||
if current == current.parent:
|
||||
raise RuntimeError("Could not find flake.lock in any parent directory, exiting")
|
||||
current = current.parent
|
||||
|
||||
output_file = current / "kernel-cachyos" / "version.json"
|
||||
with open(output_file, "w", encoding="utf-8") as f:
|
||||
json.dump(versions, f, indent=2)
|
||||
17
kernel-cachyos/version.json
Normal file
17
kernel-cachyos/version.json
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
"latest": {
|
||||
"version": "6.19.5",
|
||||
"url": "https://github.com/CachyOS/linux/releases/download/cachyos-6.19.5-2/cachyos-6.19.5-2.tar.gz",
|
||||
"hash": "sha256-KgOZl6MTmH4IvuopKArhK2fMzM1E+4zOeq9HeWUPmYY="
|
||||
},
|
||||
"lts": {
|
||||
"version": "6.18.15",
|
||||
"url": "https://github.com/CachyOS/linux/releases/download/cachyos-6.18.15-2/cachyos-6.18.15-2.tar.gz",
|
||||
"hash": "sha256-WpGH+tHh6vipOwqg1ZupEL40KF9FliYVwuOiykEj0Gc="
|
||||
},
|
||||
"rc": {
|
||||
"version": "7.0-rc1",
|
||||
"url": "https://github.com/CachyOS/linux/releases/download/cachyos-7.0-rc1-2/cachyos-7.0-rc1-2.tar.gz",
|
||||
"hash": "sha256-BxeMq0M0C98Wcc9d+GxYVzPNdw6hK4kmj+xW9Ck3mgg="
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user