From 988bf19f2cae199f133475a403ab8b909bbae3d0 Mon Sep 17 00:00:00 2001 From: Dmitriy Kholkin Date: Mon, 29 Jul 2024 10:56:29 +0300 Subject: [PATCH] linux-packages: fix argsOverride --- pkgs/os-specific/linux/kernel/linux-libre.nix | 4 +- pkgs/os-specific/linux/kernel/update-zen.py | 12 ++--- .../linux/kernel/xanmod-kernels.nix | 28 +++++----- pkgs/os-specific/linux/kernel/zen-kernels.nix | 35 ++++++------ pkgs/top-level/linux-kernels.nix | 53 ++++++++++++------- 5 files changed, 71 insertions(+), 61 deletions(-) diff --git a/pkgs/os-specific/linux/kernel/linux-libre.nix b/pkgs/os-specific/linux/kernel/linux-libre.nix index cc422ba5a59f..46b412c30226 100644 --- a/pkgs/os-specific/linux/kernel/linux-libre.nix +++ b/pkgs/os-specific/linux/kernel/linux-libre.nix @@ -5,7 +5,7 @@ sha256 = "0q3kg7dqvsiar3m70mvmn6bkkm4k1zn4fbh5r8ynib753wlhf504"; } , ... -}: +} @ args: let majorMinor = lib.versions.majorMinor linux.modDirVersion; @@ -45,4 +45,4 @@ in linux.override { maintainers = with lib.maintainers; [ qyliss ]; }; -} +} // (args.argsOverride or { }) diff --git a/pkgs/os-specific/linux/kernel/update-zen.py b/pkgs/os-specific/linux/kernel/update-zen.py index 3c51f806d8f8..a8a363761b10 100755 --- a/pkgs/os-specific/linux/kernel/update-zen.py +++ b/pkgs/os-specific/linux/kernel/update-zen.py @@ -64,16 +64,16 @@ def update_file(relpath, variant, version, suffix, sha256): for line in f: result = line result = re.sub( - fr'^ version = ".+"; #{variant}', - f' version = "{version}"; #{variant}', + fr'^ version = ".+"; #{variant}', + f' version = "{version}"; #{variant}', result) result = re.sub( - fr'^ suffix = ".+"; #{variant}', - f' suffix = "{suffix}"; #{variant}', + fr'^ suffix = ".+"; #{variant}', + f' suffix = "{suffix}"; #{variant}', result) result = re.sub( - fr'^ sha256 = ".+"; #{variant}', - f' sha256 = "{sha256}"; #{variant}', + fr'^ sha256 = ".+"; #{variant}', + f' sha256 = "{sha256}"; #{variant}', result) print(result, end='') diff --git a/pkgs/os-specific/linux/kernel/xanmod-kernels.nix b/pkgs/os-specific/linux/kernel/xanmod-kernels.nix index d0889e283d44..f2efaf762779 100644 --- a/pkgs/os-specific/linux/kernel/xanmod-kernels.nix +++ b/pkgs/os-specific/linux/kernel/xanmod-kernels.nix @@ -1,23 +1,22 @@ -{ lib, stdenv, fetchFromGitHub, buildLinux, ... } @ args: +{ lib, stdenv, fetchFromGitHub, buildLinux, variant, ... } @ args: let # These names are how they are designated in https://xanmod.org. # NOTE: When updating these, please also take a look at the changes done to # kernel config in the xanmod version commit - ltsVariant = { - version = "6.6.46"; - hash = "sha256-ZtXFIHRM5YCb+5Ry3zcQt44OBqfhCI/Ig32jETUBrJo="; - variant = "lts"; + variants = { + lts = { + version = "6.6.46"; + hash = "sha256-ZtXFIHRM5YCb+5Ry3zcQt44OBqfhCI/Ig32jETUBrJo="; + }; + main = { + version = "6.10.5"; + hash = "sha256-tETGtCNNgYj1IUNuI/Am5kimFndUC4O+cZwZzlPitFA="; + }; }; - mainVariant = { - version = "6.10.5"; - hash = "sha256-tETGtCNNgYj1IUNuI/Am5kimFndUC4O+cZwZzlPitFA="; - variant = "main"; - }; - - xanmodKernelFor = { version, suffix ? "xanmod1", hash, variant }: buildLinux (args // rec { + xanmodKernelFor = { version, suffix ? "xanmod1", hash }: buildLinux (args // rec { inherit version; pname = "linux-xanmod"; modDirVersion = lib.versions.pad 3 "${version}-${suffix}"; @@ -64,7 +63,4 @@ let }; } // (args.argsOverride or { })); in -{ - lts = xanmodKernelFor ltsVariant; - main = xanmodKernelFor mainVariant; -} +xanmodKernelFor variants.${variant} diff --git a/pkgs/os-specific/linux/kernel/zen-kernels.nix b/pkgs/os-specific/linux/kernel/zen-kernels.nix index 06fbfbd37d13..6c9d2da1e9db 100644 --- a/pkgs/os-specific/linux/kernel/zen-kernels.nix +++ b/pkgs/os-specific/linux/kernel/zen-kernels.nix @@ -1,20 +1,22 @@ -{ lib, stdenv, fetchFromGitHub, buildLinux, ... } @ args: +{ lib, stdenv, fetchFromGitHub, buildLinux, variant, ... } @ args: let # comments with variant added for update script - # ./update-zen.py zen - zenVariant = { - version = "6.10.5"; #zen - suffix = "zen1"; #zen - sha256 = "08ibz7560xsmlnrm8j13hxf8hjjcxfmnjdrwffqc81g9g6rvpqra"; #zen - isLqx = false; - }; - # ./update-zen.py lqx - lqxVariant = { - version = "6.10.5"; #lqx - suffix = "lqx1"; #lqx - sha256 = "09rscj20j94qkmvk0hlpjm6v1n1ndnkv2vl035gsp5lwggws2jqm"; #lqx - isLqx = true; + variants = { + # ./update-zen.py zen + zen = { + version = "6.10.5"; #zen + suffix = "zen1"; #zen + sha256 = "08ibz7560xsmlnrm8j13hxf8hjjcxfmnjdrwffqc81g9g6rvpqra"; #zen + isLqx = false; + }; + # ./update-zen.py lqx + lqx = { + version = "6.10.5"; #lqx + suffix = "lqx1"; #lqx + sha256 = "09rscj20j94qkmvk0hlpjm6v1n1ndnkv2vl035gsp5lwggws2jqm"; #lqx + isLqx = true; + }; }; zenKernelsFor = { version, suffix, sha256, isLqx }: buildLinux (args // { inherit version; @@ -123,7 +125,4 @@ let } // (args.argsOverride or { })); in -{ - zen = zenKernelsFor zenVariant; - lqx = zenKernelsFor lqxVariant; -} +zenKernelsFor variants.${variant} diff --git a/pkgs/top-level/linux-kernels.nix b/pkgs/top-level/linux-kernels.nix index 4688e25586ac..d5bd0f19bac2 100644 --- a/pkgs/top-level/linux-kernels.nix +++ b/pkgs/top-level/linux-kernels.nix @@ -213,31 +213,46 @@ in { # https://github.com/NixOS/nixpkgs/pull/161773#discussion_r820134708 zenKernels = callPackage ../os-specific/linux/kernel/zen-kernels.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 the variants of the XanMod kernel - xanmodKernels = callPackage ../os-specific/linux/kernel/xanmod-kernels.nix { + linux_zen = zenKernels { + variant = "zen"; kernelPatches = [ kernelPatches.bridge_stp_helper kernelPatches.request_key_helper ]; }; - linux_xanmod = xanmodKernels.lts; - linux_xanmod_stable = xanmodKernels.main; - linux_xanmod_latest = xanmodKernels.main; + linux_lqx = zenKernels { + variant = "lqx"; + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + + # This contains the variants of the XanMod kernel + xanmodKernels = callPackage ../os-specific/linux/kernel/xanmod-kernels.nix; + + linux_xanmod = xanmodKernels { + variant = "lts"; + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + linux_xanmod_stable = xanmodKernels { + variant = "main"; + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; + linux_xanmod_latest = xanmodKernels { + variant = "main"; + kernelPatches = [ + kernelPatches.bridge_stp_helper + kernelPatches.request_key_helper + ]; + }; linux_libre = deblobKernel packageAliases.linux_default.kernel;