From 84b48a9a6c1132b43dbdd20ae90a76eccbcd4f9c Mon Sep 17 00:00:00 2001 From: Tristan Druyen Date: Tue, 30 Jul 2024 21:51:34 +0200 Subject: [PATCH] Change to kernel patch for mini build --- systems/nixos-fw16/default.nix | 25 +++++-- systems/nixos-fw16/mini_kernel.nix | 20 +++--- systems/nixos-fw16/pkgs-for.nix | 104 ----------------------------- 3 files changed, 33 insertions(+), 116 deletions(-) delete mode 100644 systems/nixos-fw16/pkgs-for.nix diff --git a/systems/nixos-fw16/default.nix b/systems/nixos-fw16/default.nix index 7f360ff..7ee777b 100644 --- a/systems/nixos-fw16/default.nix +++ b/systems/nixos-fw16/default.nix @@ -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; diff --git a/systems/nixos-fw16/mini_kernel.nix b/systems/nixos-fw16/mini_kernel.nix index 17cfe32..283bfcc 100644 --- a/systems/nixos-fw16/mini_kernel.nix +++ b/systems/nixos-fw16/mini_kernel.nix @@ -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; +} diff --git a/systems/nixos-fw16/pkgs-for.nix b/systems/nixos-fw16/pkgs-for.nix deleted file mode 100644 index adca4e7..0000000 --- a/systems/nixos-fw16/pkgs-for.nix +++ /dev/null @@ -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 -}