mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-12-01 19:33:03 +00:00
Merge pull request #161773 from psydvl/kernel/zen+lqx
`linux_zen` & `linux_lqx`: unify, add `updateScript` & `linux_lqx` -> 5.18.7
This commit is contained in:
commit
1cd3bf8234
@ -1,26 +0,0 @@
|
||||
{ lib, fetchFromGitHub, buildLinux, linux_zen, ... } @ args:
|
||||
|
||||
let
|
||||
version = "5.15.16";
|
||||
suffix = "lqx2";
|
||||
in
|
||||
|
||||
buildLinux (args // {
|
||||
modDirVersion = "${version}-${suffix}";
|
||||
inherit version;
|
||||
isZen = true;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "zen-kernel";
|
||||
repo = "zen-kernel";
|
||||
rev = "v${version}-${suffix}";
|
||||
sha256 = "sha256-kdT/hiASZ72pkS0Igta0KT0GWTgDRjxBnd5CQ0eonfg=";
|
||||
};
|
||||
|
||||
extraMeta = {
|
||||
branch = "5.14/master";
|
||||
maintainers = with lib.maintainers; [ atemu ];
|
||||
description = linux_zen.meta.description + " (Same as linux_zen but less aggressive release schedule)";
|
||||
};
|
||||
|
||||
} // (args.argsOverride or { }))
|
@ -1,39 +0,0 @@
|
||||
{ lib, fetchFromGitHub, buildLinux, ... } @ args:
|
||||
|
||||
let
|
||||
# having the full version string here makes it easier to update
|
||||
modDirVersion = "5.18.5-zen1";
|
||||
parts = lib.splitString "-" modDirVersion;
|
||||
version = lib.elemAt parts 0;
|
||||
suffix = lib.elemAt parts 1;
|
||||
|
||||
numbers = lib.splitString "." version;
|
||||
branch = "${lib.elemAt numbers 0}.${lib.elemAt numbers 1}";
|
||||
rev = if ((lib.elemAt numbers 2) == "0") then "v${branch}-${suffix}" else "v${modDirVersion}";
|
||||
in
|
||||
|
||||
buildLinux (args // {
|
||||
inherit version modDirVersion;
|
||||
isZen = true;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "zen-kernel";
|
||||
repo = "zen-kernel";
|
||||
inherit rev;
|
||||
sha256 = "sha256-q6a8Wyzs6GNQ39mV+q/9N6yo/kXS9ZH+QTfGka42gk4=";
|
||||
};
|
||||
|
||||
structuredExtraConfig = with lib.kernel; {
|
||||
ZEN_INTERACTIVE = yes;
|
||||
# TODO: Remove once #175433 reaches master
|
||||
# https://nixpk.gs/pr-tracker.html?pr=175433
|
||||
WERROR = no;
|
||||
};
|
||||
|
||||
extraMeta = {
|
||||
inherit branch;
|
||||
maintainers = with lib.maintainers; [ atemu andresilva ];
|
||||
description = "Built using the best configuration and kernel sources for desktop, multimedia, and gaming workloads.";
|
||||
};
|
||||
|
||||
} // (args.argsOverride or { }))
|
97
pkgs/os-specific/linux/kernel/update-zen.py
Executable file
97
pkgs/os-specific/linux/kernel/update-zen.py
Executable file
@ -0,0 +1,97 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -i python3 -p python3 nix nix-prefetch-git
|
||||
|
||||
import fileinput
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
import re
|
||||
import subprocess
|
||||
|
||||
from datetime import datetime
|
||||
from urllib.request import urlopen, Request
|
||||
|
||||
|
||||
def panic(exc):
|
||||
raise Exception(exc)
|
||||
|
||||
|
||||
DIR = os.path.dirname(os.path.abspath(__file__))
|
||||
HEADERS = {'Accept': 'application/vnd.github.v3+json'}
|
||||
|
||||
|
||||
def github_api_request(endpoint):
|
||||
base_url = 'https://api.github.com/'
|
||||
request = Request(base_url + endpoint, headers=HEADERS)
|
||||
with urlopen(request) as http_response:
|
||||
return json.loads(http_response.read().decode('utf-8'))
|
||||
|
||||
|
||||
def get_commit_date(repo, sha):
|
||||
url = f'https://api.github.com/repos/{repo}/commits/{sha}'
|
||||
request = Request(url, headers=HEADERS)
|
||||
with urlopen(request) as http_response:
|
||||
commit = json.loads(http_response.read().decode())
|
||||
date = commit['commit']['committer']['date'].rstrip('Z')
|
||||
date = datetime.fromisoformat(date).date().isoformat()
|
||||
return 'unstable-' + date
|
||||
|
||||
|
||||
def nix_prefetch_git(url, rev):
|
||||
"""Prefetches the requested Git revision (incl. submodules) of the given repository URL."""
|
||||
print(f'nix-prefetch-git {url} {rev}')
|
||||
out = subprocess.check_output([
|
||||
'nix-prefetch-git', '--quiet',
|
||||
'--url', url,
|
||||
'--rev', rev,
|
||||
'--fetch-submodules'])
|
||||
return json.loads(out)['sha256']
|
||||
|
||||
|
||||
def nix_prefetch_url(url, unpack=False):
|
||||
"""Prefetches the content of the given URL."""
|
||||
print(f'nix-prefetch-url {url}')
|
||||
options = ['--type', 'sha256']
|
||||
if unpack:
|
||||
options += ['--unpack']
|
||||
out = subprocess.check_output(['nix-prefetch-url'] + options + [url])
|
||||
return out.decode('utf-8').rstrip()
|
||||
|
||||
|
||||
def update_file(relpath, variant, version, suffix, sha256):
|
||||
file_path = os.path.join(DIR, relpath)
|
||||
with fileinput.FileInput(file_path, inplace=True) as f:
|
||||
for line in f:
|
||||
result = line
|
||||
result = re.sub(
|
||||
fr'^ version = ".+"; #{variant}',
|
||||
f' version = "{version}"; #{variant}',
|
||||
result)
|
||||
result = re.sub(
|
||||
fr'^ suffix = ".+"; #{variant}',
|
||||
f' suffix = "{suffix}"; #{variant}',
|
||||
result)
|
||||
result = re.sub(
|
||||
fr'^ sha256 = ".+"; #{variant}',
|
||||
f' sha256 = "{sha256}"; #{variant}',
|
||||
result)
|
||||
print(result, end='')
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) == 1:
|
||||
panic("Update variant expected")
|
||||
variant = sys.argv[1]
|
||||
if variant not in ("zen", "lqx"):
|
||||
panic(f"Unexepected variant instead of 'zen' or 'lqx': {sys.argv[1]}")
|
||||
pattern = re.compile(fr"v(\d+\.\d+\.?\d*)-({variant}\d+)")
|
||||
zen_tags = github_api_request('repos/zen-kernel/zen-kernel/releases')
|
||||
for tag in zen_tags:
|
||||
zen_match = pattern.match(tag['tag_name'])
|
||||
if zen_match:
|
||||
zen_tag = zen_match.group(0)
|
||||
zen_version = zen_match.group(1)
|
||||
zen_suffix = zen_match.group(2)
|
||||
break
|
||||
zen_hash = nix_prefetch_git('https://github.com/zen-kernel/zen-kernel.git', zen_tag)
|
||||
update_file('zen-kernels.nix', variant, zen_version, zen_suffix, zen_hash)
|
@ -1,23 +0,0 @@
|
||||
#! /usr/bin/env nix-shell
|
||||
#! nix-shell -I nixpkgs=../../../.. -i bash -p nix-prefetch git gnused gnugrep nix curl
|
||||
set -euo pipefail -x
|
||||
|
||||
nixpkgs="$(git rev-parse --show-toplevel)"
|
||||
old=$(nix-instantiate --eval -A linuxPackages_zen.kernel.modDirVersion "$nixpkgs")
|
||||
old="${old%\"}"
|
||||
old="${old#\"}"
|
||||
new=$(curl https://github.com/zen-kernel/zen-kernel/releases.atom | grep -m1 -o -E '[0-9.]+-zen[0-9]+')
|
||||
# add ".0" patch to modDirVersion when minor only
|
||||
new=$(echo "$new" | sed -E 's/^([0-9]+)\.([0-9]+)-(\w+)$/\1.\2.0-\3/')
|
||||
if [[ "$new" == "$old" ]]; then
|
||||
echo "already up-to-date"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
path="$nixpkgs/pkgs/os-specific/linux/kernel/linux-zen.nix"
|
||||
|
||||
sed -i -e "s!modDirVersion = \".*\"!modDirVersion = \"${new}\"!" "$path"
|
||||
checksum=$(nix-prefetch "(import ${nixpkgs} {}).linuxPackages_zen.kernel")
|
||||
sed -i -e "s!sha256 = \".*\"!sha256 = \"${checksum}\"!" "$path"
|
||||
|
||||
git commit -m "linuxKernel.kernels.linux_zen: ${old} -> ${new}" $path
|
45
pkgs/os-specific/linux/kernel/zen-kernels.nix
Normal file
45
pkgs/os-specific/linux/kernel/zen-kernels.nix
Normal file
@ -0,0 +1,45 @@
|
||||
{ lib, fetchFromGitHub, buildLinux, ... } @ args:
|
||||
|
||||
let
|
||||
# comments with variant added for update script
|
||||
# ./update-zen.py zen
|
||||
zenVariant = {
|
||||
version = "5.18.7"; #zen
|
||||
suffix = "zen1"; #zen
|
||||
sha256 = "1dxiwrbf15njqcq2kxbsg22hllpcvdwjhdf0gs3xx0xyjbwjyd26"; #zen
|
||||
isLqx = false;
|
||||
};
|
||||
# ./update-zen.py lqx
|
||||
lqxVariant = {
|
||||
version = "5.18.7"; #lqx
|
||||
suffix = "lqx1"; #lqx
|
||||
sha256 = "0gyp4x8rlsg5bjr9c8qq0mk3wckyg0navc1sripkj8hrl51vm28c"; #lqx
|
||||
isLqx = true;
|
||||
};
|
||||
zenKernelsFor = { version, suffix, sha256, isLqx }: buildLinux (args // {
|
||||
inherit version;
|
||||
modDirVersion = "${lib.concatStringsSep "." (lib.take 3 (lib.splitVersion version ++ [ "0" "0" ]))}-${suffix}";
|
||||
isZen = true;
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "zen-kernel";
|
||||
repo = "zen-kernel";
|
||||
rev = "v${version}-${suffix}";
|
||||
inherit sha256;
|
||||
};
|
||||
|
||||
passthru.updateScript = [ ./update-zen.py (if isLqx then "lqx" else "zen") ];
|
||||
|
||||
extraMeta = {
|
||||
branch = lib.versions.majorMinor version + "/master";
|
||||
maintainers = with lib.maintainers; [ atemu andresilva psydvl ];
|
||||
description = "Built using the best configuration and kernel sources for desktop, multimedia, and gaming workloads." +
|
||||
lib.optionalString isLqx " (Same as linux_zen but less aggressive release schedule)";
|
||||
};
|
||||
|
||||
} // (args.argsOverride or { }));
|
||||
in
|
||||
{
|
||||
zen = zenKernelsFor zenVariant;
|
||||
lqx = zenKernelsFor lqxVariant;
|
||||
}
|
@ -196,19 +196,23 @@ in {
|
||||
];
|
||||
};
|
||||
|
||||
linux_zen = callPackage ../os-specific/linux/kernel/linux-zen.nix {
|
||||
kernelPatches = [
|
||||
kernelPatches.bridge_stp_helper
|
||||
kernelPatches.request_key_helper
|
||||
];
|
||||
};
|
||||
# Using zenKernels like this due lqx&zen came from one source, but may have different base kernel version
|
||||
# https://github.com/NixOS/nixpkgs/pull/161773#discussion_r820134708
|
||||
zenKernels = callPackage ../os-specific/linux/kernel/zen-kernels.nix;
|
||||
|
||||
linux_lqx = callPackage ../os-specific/linux/kernel/linux-lqx.nix {
|
||||
linux_zen = (zenKernels {
|
||||
kernelPatches = [
|
||||
kernelPatches.bridge_stp_helper
|
||||
kernelPatches.request_key_helper
|
||||
];
|
||||
};
|
||||
}).zen;
|
||||
|
||||
linux_lqx = (zenKernels {
|
||||
kernelPatches = [
|
||||
kernelPatches.bridge_stp_helper
|
||||
kernelPatches.request_key_helper
|
||||
];
|
||||
}).lqx;
|
||||
|
||||
# This contains both the STABLE and EDGE variants of the XanMod kernel
|
||||
xanmodKernels = callPackage ../os-specific/linux/kernel/xanmod-kernels.nix;
|
||||
|
Loading…
Reference in New Issue
Block a user