Change to kernel patch for mini build

This commit is contained in:
Tristan D. 2024-07-30 21:51:34 +02:00
parent 7148614dc5
commit 84b48a9a6c
Signed by: tristan
SSH key fingerprint: SHA256:9oFM1J63hYWJjCnLG6C0fxBS15rwNcWwdQNMOHYKJ/4
3 changed files with 33 additions and 116 deletions

View file

@ -107,15 +107,32 @@
};
specialisation.linux-cachy-mini.configuration = {
boot.kernelPackages = lib.mkForce (import ./mini_kernel.nix {
inherit inputs lib;
pkgs = pkgs.pkgsAMD64Microarchs.znver4;
});
boot.kernelPatches = [
(import ./mini_kernel.nix {
inherit inputs lib;
pkgs = pkgs.pkgsAMD64Microarchs.znver4;
}).patch
];
environment.etc."specialisation".text = "linux-cachy-mini";
system.nixos.tags = [ "linux-cachy-mini" ];
};
# specialisation.linux-cachy-mini-lto.configuration = {
# boot.kernelPackages = lib.mkForce pkgs.pkgsAMD64Microarchs.znver4.linuxPackages_cachyos-lto;
# boot.kernelPatches = [
# (import ./mini_kernel.nix {
# inherit inputs lib;
# pkgs = pkgs.pkgsAMD64Microarchs.znver4;
# }).patch
# ];
# environment.etc."specialisation".text = "linux-cachy-mini-lto";
# system.nixos.tags = [ "linux-cachy-mini-lto" ];
# };
boot = {
# kernelPackages = pkgs.linuxPackages_cachyos; # bootstrap
kernelPackages = pkgs.pkgsAMD64Microarchs.znver4.linuxPackages_cachyos;

View file

@ -4,7 +4,6 @@
, ...
}:
let
mainVersions = lib.importJSON "${inputs.chaotic}/pkgs/linux-cachyos/versions.json";
mainConfig = import "${inputs.chaotic}/pkgs/linux-cachyos/config-nix/cachyos.x86_64-linux.nix";
usedModules = builtins.readFile ./modprobed.db;
toLowerParts = list: (lib.lists.unique
@ -36,12 +35,17 @@ let
})
(builtins.attrValues (builtins.mapAttrs (name: value: { inherit name value; }) mainConfig))
);
mkCachyKernel = attrs: pkgs.callPackage ./pkgs-for.nix ({ versions = mainVersions; } // attrs);
mainKernel = mkCachyKernel {
inherit inputs;
taste = "linux-cachyos";
kConfig = filteredConfig;
withUpdateScript = "stable";
patchConfigStep1 = lib.attrsets.mapAttrs ((name: value: {
${builtins.removePrefix "CONFIG_" name} = value;
})
filteredConfig);
patchConfigFinal = lib.attrsets.filterAttrs ((n: v: v == "n") patchConfigStep1);
patch = {
name = "disable-unused-kmods";
patch = null;
extraStructuredConfig = patchConfigFinal;
};
in
mainKernel
{
patch = patch;
}

View file

@ -1,104 +0,0 @@
{ stdenv
, inputs
, taste
, kConfig
, versions
, callPackage
, linuxPackages
, linuxPackagesFor
, fetchFromGitHub
, nyxUtils
, lib
, ogKernelConfigfile ? linuxPackages.kernel.passthru.configfile
, # those are set in their PKGBUILDs
kernelPatches ? { }
, basicCachy ? true
, cpuSched ? "cachyos"
, useLTO ? "none"
, ticksHz ? 500
, tickRate ? "full"
, preempt ? "full"
, hugePages ? "always"
, withDAMON ? false
, withNTSync ? true
, withHDR ? true
, withoutDebug ? false
, description ? "Linux EEVDF-BORE scheduler Kernel by CachyOS with other patches and improvements"
, withUpdateScript ? null
, packagesExtend ? null
,
}:
let
cachyConfig = {
inherit
taste
versions
basicCachy
cpuSched
useLTO
ticksHz
tickRate
preempt
hugePages
withDAMON
withNTSync
withHDR
withoutDebug
description
withUpdateScript
;
};
# The three phases of the config
# - First we apply the changes fromt their PKGBUILD using kconfig;
# - Then we NIXify it (in the update-script);
# - Last state is importing the NIXified version for building.
preparedConfigfile = callPackage "${inputs.chaotic}/pkgs/linux-cachyos/prepare.nix" {
inherit cachyConfig stdenv kernel ogKernelConfigfile;
};
kconfigToNix = callPackage "${inputs.chaotic}/pkgs/linux-cachyos/lib/kconfig-to-nix.nix" {
configfile = preparedConfigfile;
};
linuxConfigTransfomed = kConfig;
kernel = callPackage "${inputs.chaotic}/pkgs/linux-cachyos/kernel.nix" {
inherit cachyConfig stdenv kconfigToNix;
kernelPatches = [ ];
configfile = preparedConfigfile;
config = linuxConfigTransfomed;
};
# CachyOS repeating stuff.
addZFS = _finalAttrs: prevAttrs: {
kernel_configfile = prevAttrs.kernel.configfile;
zfs_cachyos = prevAttrs.zfs_unstable.overrideAttrs (prevAttrs: {
src = fetchFromGitHub {
owner = "cachyos";
repo = "zfs";
inherit (versions.zfs) rev hash;
};
meta = prevAttrs.meta // { broken = false; };
patches = [ ];
});
};
basePackages = linuxPackagesFor kernel;
packagesWithZFS = basePackages.extend addZFS;
packagesWithExtend =
if packagesExtend == null
then packagesWithZFS
else packagesWithZFS.extend (packagesExtend kernel);
packagesWithoutZFS = removeAttrs packagesWithExtend [ "zfs" "zfs_2_1" "zfs_2_2" "zfs_unstable" ];
packagesWithoutUpdateScript = nyxUtils.dropAttrsUpdateScript packagesWithoutZFS;
packagesWithRightPlatforms = nyxUtils.setAttrsPlatforms supportedPlatforms packagesWithoutUpdateScript;
supportedPlatforms = [ (with lib.systems.inspect.patterns; isx86_64 // isLinux) "x86_64-linux" ];
versionSuffix = "+C${nyxUtils.shorter versions.config.rev}+P${nyxUtils.shorter versions.patches.rev}";
in
packagesWithRightPlatforms
// {
_description = "Kernel and modules for ${description}";
_version = "${versions.linux.version}${versionSuffix}";
inherit (basePackages) kernel; # This one still has the updateScript
}