mirror of
https://github.com/xddxdd/nix-cachyos-kernel.git
synced 2026-07-03 19:18:07 +02:00
parent
ec03379858
commit
d0d2a987c8
@ -1,5 +1,8 @@
|
|||||||
builds:
|
builds:
|
||||||
|
# Only build most common configs to save build minutes
|
||||||
include:
|
include:
|
||||||
- packages.x86_64-linux.*
|
- packages.x86_64-linux.linux-cachyos-latest
|
||||||
exclude:
|
- packages.x86_64-linux.linux-cachyos-latest-lto
|
||||||
- packages.x86_64-linux.zfs-cachyos
|
- packages.x86_64-linux.linux-cachyos-lts
|
||||||
|
- packages.x86_64-linux.linux-cachyos-lts-lto
|
||||||
|
exclude: []
|
||||||
|
|||||||
132
kernel-cachyos/cachySettings.nix
Normal file
132
kernel-cachyos/cachySettings.nix
Normal file
@ -0,0 +1,132 @@
|
|||||||
|
{ lib, ... }:
|
||||||
|
with lib.kernel;
|
||||||
|
# Sourced from https://github.com/CachyOS/linux-cachyos/blob/master/linux-cachyos/PKGBUILD
|
||||||
|
{
|
||||||
|
common = {
|
||||||
|
CACHY = yes;
|
||||||
|
};
|
||||||
|
|
||||||
|
cpusched = rec {
|
||||||
|
bore = {
|
||||||
|
SCHED_BORE = yes;
|
||||||
|
};
|
||||||
|
bmq = {
|
||||||
|
SCHED_ALT = yes;
|
||||||
|
SCHED_BMQ = yes;
|
||||||
|
};
|
||||||
|
eevdf = { };
|
||||||
|
rt = {
|
||||||
|
PREEMPT_RT = yes;
|
||||||
|
};
|
||||||
|
rt-bore = rt // bore;
|
||||||
|
};
|
||||||
|
|
||||||
|
kcfi = {
|
||||||
|
ARCH_SUPPORTS_CFI_CLANG = yes;
|
||||||
|
CFI_CLANG = yes;
|
||||||
|
CFI_AUTO_DEFAULT = yes;
|
||||||
|
};
|
||||||
|
|
||||||
|
hzTicks = {
|
||||||
|
"300" = {
|
||||||
|
HZ_300 = yes;
|
||||||
|
HZ = freeform "300";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
// lib.genAttrs [ "100" "250" "500" "600" "750" "1000" ] (hz: {
|
||||||
|
HZ_300 = no;
|
||||||
|
"HZ_${hz}" = yes;
|
||||||
|
HZ = freeform hz;
|
||||||
|
});
|
||||||
|
|
||||||
|
performanceGovernor = {
|
||||||
|
CPU_FREQ_DEFAULT_GOV_SCHEDUTIL = no;
|
||||||
|
CPU_FREQ_DEFAULT_GOV_PERFORMANCE = yes;
|
||||||
|
};
|
||||||
|
|
||||||
|
tickrate = {
|
||||||
|
periodic = {
|
||||||
|
NO_HZ_IDLE = no;
|
||||||
|
NO_HZ_FULL = no;
|
||||||
|
NO_HZ = no;
|
||||||
|
NO_HZ_COMMON = no;
|
||||||
|
HZ_PERIODIC = yes;
|
||||||
|
};
|
||||||
|
idle = {
|
||||||
|
HZ_PERIODIC = no;
|
||||||
|
NO_HZ_FULL = no;
|
||||||
|
NO_HZ_IDLE = yes;
|
||||||
|
NO_HZ = yes;
|
||||||
|
NO_HZ_COMMON = yes;
|
||||||
|
};
|
||||||
|
full = {
|
||||||
|
HZ_PERIODIC = no;
|
||||||
|
NO_HZ_IDLE = no;
|
||||||
|
CONTEXT_TRACKING_FORCE = no;
|
||||||
|
NO_HZ_FULL_NODEF = yes;
|
||||||
|
NO_HZ_FULL = yes;
|
||||||
|
NO_HZ = yes;
|
||||||
|
NO_HZ_COMMON = yes;
|
||||||
|
CONTEXT_TRACKING = yes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
preemptType = {
|
||||||
|
full = {
|
||||||
|
PREEMPT_DYNAMIC = yes;
|
||||||
|
PREEMPT = yes;
|
||||||
|
PREEMPT_VOLUNTARY = no;
|
||||||
|
PREEMPT_LAZY = no;
|
||||||
|
PREEMPT_NONE = no;
|
||||||
|
};
|
||||||
|
lazy = {
|
||||||
|
PREEMPT_DYNAMIC = yes;
|
||||||
|
PREEMPT = no;
|
||||||
|
PREEMPT_VOLUNTARY = no;
|
||||||
|
PREEMPT_LAZY = yes;
|
||||||
|
PREEMPT_NONE = no;
|
||||||
|
};
|
||||||
|
voluntary = {
|
||||||
|
PREEMPT_DYNAMIC = no;
|
||||||
|
PREEMPT = no;
|
||||||
|
PREEMPT_VOLUNTARY = yes;
|
||||||
|
PREEMPT_LAZY = no;
|
||||||
|
PREEMPT_NONE = no;
|
||||||
|
};
|
||||||
|
none = {
|
||||||
|
PREEMPT_DYNAMIC = no;
|
||||||
|
PREEMPT = no;
|
||||||
|
PREEMPT_VOLUNTARY = no;
|
||||||
|
PREEMPT_LAZY = no;
|
||||||
|
PREEMPT_NONE = yes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
ccHarder = {
|
||||||
|
CC_OPTIMIZE_FOR_PERFORMANCE = no;
|
||||||
|
CC_OPTIMIZE_FOR_PERFORMANCE_O3 = yes;
|
||||||
|
};
|
||||||
|
|
||||||
|
bbr3 = {
|
||||||
|
TCP_CONG_CUBIC = module;
|
||||||
|
DEFAULT_CUBIC = no;
|
||||||
|
TCP_CONG_BBR = yes;
|
||||||
|
DEFAULT_BBR = yes;
|
||||||
|
DEFAULT_TCP_CONG = freeform "bbr";
|
||||||
|
NET_SCH_FQ_CODEL = module;
|
||||||
|
NET_SCH_FQ = yes;
|
||||||
|
CONFIG_DEFAULT_FQ_CODEL = no;
|
||||||
|
CONFIG_DEFAULT_FQ = yes;
|
||||||
|
};
|
||||||
|
|
||||||
|
hugepage = {
|
||||||
|
always = {
|
||||||
|
TRANSPARENT_HUGEPAGE_MADVISE = no;
|
||||||
|
TRANSPARENT_HUGEPAGE_ALWAYS = yes;
|
||||||
|
};
|
||||||
|
madvise = {
|
||||||
|
TRANSPARENT_HUGEPAGE_ALWAYS = no;
|
||||||
|
TRANSPARENT_HUGEPAGE_MADVISE = yes;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -35,5 +35,109 @@ builtins.listToAttrs (
|
|||||||
configVariant = "linux-cachyos-lts";
|
configVariant = "linux-cachyos-lts";
|
||||||
lto = true;
|
lto = true;
|
||||||
})
|
})
|
||||||
|
|
||||||
|
# Additional CachyOS provided variants
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-bmq";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-bmq";
|
||||||
|
lto = false;
|
||||||
|
cpusched = "bmq";
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-bmq-lto";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-bmq";
|
||||||
|
lto = true;
|
||||||
|
cpusched = "bmq";
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-bore";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-bore";
|
||||||
|
lto = false;
|
||||||
|
cpusched = "bore";
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-bore-lto";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-bore";
|
||||||
|
lto = true;
|
||||||
|
cpusched = "bore";
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-deckify";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-deckify";
|
||||||
|
lto = false;
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-deckify-lto";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-deckify";
|
||||||
|
lto = true;
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-eevdf";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-eevdf";
|
||||||
|
cpusched = "eevdf";
|
||||||
|
lto = false;
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-eevdf-lto";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-eevdf";
|
||||||
|
cpusched = "eevdf";
|
||||||
|
lto = true;
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-hardened";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-hardened";
|
||||||
|
hardened = true;
|
||||||
|
lto = false;
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-hardened-lto";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-hardened";
|
||||||
|
hardened = true;
|
||||||
|
lto = true;
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-rt-bore";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-rt-bore";
|
||||||
|
rt = true;
|
||||||
|
cpusched = "bore";
|
||||||
|
lto = false;
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-rt-bore-lto";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-rt-bore";
|
||||||
|
rt = true;
|
||||||
|
cpusched = "bore";
|
||||||
|
lto = true;
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-server";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-server";
|
||||||
|
cpusched = "eevdf";
|
||||||
|
hzTicks = "300";
|
||||||
|
preemptType = "none";
|
||||||
|
lto = false;
|
||||||
|
})
|
||||||
|
(mkCachyKernel {
|
||||||
|
pname = "linux-cachyos-server-lto";
|
||||||
|
inherit (linux_latest) version src;
|
||||||
|
configVariant = "linux-cachyos-server";
|
||||||
|
cpusched = "eevdf";
|
||||||
|
hzTicks = "300";
|
||||||
|
preemptType = "none";
|
||||||
|
lto = true;
|
||||||
|
})
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|||||||
@ -25,6 +25,23 @@ lib.makeOverridable (
|
|||||||
patches ? [ ],
|
patches ? [ ],
|
||||||
postPatch ? "",
|
postPatch ? "",
|
||||||
|
|
||||||
|
# CachyOS fine tuning settings, see ./cachySettings.nix for corresponding options
|
||||||
|
# Default value sourced from https://github.com/CachyOS/linux-cachyos/blob/master/linux-cachyos/PKGBUILD
|
||||||
|
# Set to null or false to disable
|
||||||
|
cpusched ? "bore",
|
||||||
|
kcfi ? false,
|
||||||
|
hzTicks ? "1000",
|
||||||
|
performanceGovernor ? false,
|
||||||
|
tickrate ? "full",
|
||||||
|
preemptType ? "full",
|
||||||
|
ccHarder ? true,
|
||||||
|
bbr3 ? false,
|
||||||
|
hugepage ? "always",
|
||||||
|
|
||||||
|
# CachyOS additional patch settings
|
||||||
|
hardened ? false,
|
||||||
|
rt ? false,
|
||||||
|
|
||||||
# See nixpkgs/pkgs/os-specific/linux/kernel/generic.nix for additional options.
|
# See nixpkgs/pkgs/os-specific/linux/kernel/generic.nix for additional options.
|
||||||
# Additional args are passed to buildLinux.
|
# Additional args are passed to buildLinux.
|
||||||
...
|
...
|
||||||
@ -39,7 +56,13 @@ lib.makeOverridable (
|
|||||||
fullVersion = lib.versions.pad 3 ver0;
|
fullVersion = lib.versions.pad 3 ver0;
|
||||||
|
|
||||||
cachyosConfigFile = "${inputs.cachyos-kernel.outPath}/${configVariant}/config";
|
cachyosConfigFile = "${inputs.cachyos-kernel.outPath}/${configVariant}/config";
|
||||||
cachyosPatch = "${inputs.cachyos-kernel-patches.outPath}/${major}/all/0001-cachyos-base-all.patch";
|
cachyosPatches = builtins.map (p: "${inputs.cachyos-kernel-patches.outPath}/${major}/${p}") (
|
||||||
|
[ "all/0001-cachyos-base-all.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")
|
||||||
|
);
|
||||||
|
|
||||||
# buildLinux doesn't accept postPatch, so adding config file early here
|
# buildLinux doesn't accept postPatch, so adding config file early here
|
||||||
patchedSrc = stdenv.mkDerivation {
|
patchedSrc = stdenv.mkDerivation {
|
||||||
@ -48,8 +71,8 @@ lib.makeOverridable (
|
|||||||
patches = [
|
patches = [
|
||||||
kernelPatches.bridge_stp_helper.patch
|
kernelPatches.bridge_stp_helper.patch
|
||||||
kernelPatches.request_key_helper.patch
|
kernelPatches.request_key_helper.patch
|
||||||
cachyosPatch
|
|
||||||
]
|
]
|
||||||
|
++ cachyosPatches
|
||||||
++ patches;
|
++ patches;
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
install -Dm644 ${cachyosConfigFile} arch/x86/configs/cachyos_defconfig
|
install -Dm644 ${cachyosConfigFile} arch/x86/configs/cachyos_defconfig
|
||||||
@ -65,6 +88,44 @@ lib.makeOverridable (
|
|||||||
};
|
};
|
||||||
|
|
||||||
defaultLocalVersion = if lto then "-cachyos-lto" else "-cachyos";
|
defaultLocalVersion = if lto then "-cachyos-lto" else "-cachyos";
|
||||||
|
|
||||||
|
cachySettings = callPackage ./cachySettings.nix { };
|
||||||
|
structuredExtraConfig =
|
||||||
|
# Apply basic kernel options
|
||||||
|
(with lib.kernel; {
|
||||||
|
NR_CPUS = lib.mkForce (option (freeform "8192"));
|
||||||
|
LOCALVERSION = freeform defaultLocalVersion;
|
||||||
|
|
||||||
|
# Follow NixOS default config to not break etc overlay
|
||||||
|
OVERLAY_FS = module;
|
||||||
|
OVERLAY_FS_REDIRECT_DIR = no;
|
||||||
|
OVERLAY_FS_REDIRECT_ALWAYS_FOLLOW = yes;
|
||||||
|
OVERLAY_FS_INDEX = no;
|
||||||
|
OVERLAY_FS_XINO_AUTO = no;
|
||||||
|
OVERLAY_FS_METACOPY = no;
|
||||||
|
OVERLAY_FS_DEBUG = no;
|
||||||
|
})
|
||||||
|
// (lib.optionalAttrs lto {
|
||||||
|
LTO_NONE = lib.kernel.no;
|
||||||
|
LTO_CLANG_THIN = lib.kernel.yes;
|
||||||
|
})
|
||||||
|
|
||||||
|
# Apply CachyOS specific settings
|
||||||
|
// (lib.mapAttrs (_: lib.mkForce) (
|
||||||
|
cachySettings.common
|
||||||
|
// (lib.optionalAttrs (cpusched != null) cachySettings.cpusched."${cpusched}")
|
||||||
|
// (lib.optionalAttrs kcfi cachySettings.kcfi)
|
||||||
|
// (lib.optionalAttrs (hzTicks != null) cachySettings.hzTicks."${hzTicks}")
|
||||||
|
// (lib.optionalAttrs performanceGovernor cachySettings.performanceGovernor)
|
||||||
|
// (lib.optionalAttrs (tickrate != null) cachySettings.tickrate."${tickrate}")
|
||||||
|
// (lib.optionalAttrs (preemptType != null) cachySettings.preemptType."${preemptType}")
|
||||||
|
// (lib.optionalAttrs ccHarder cachySettings.ccHarder)
|
||||||
|
// (lib.optionalAttrs bbr3 cachySettings.bbr3)
|
||||||
|
// (lib.optionalAttrs (hugepage != null) cachySettings.hugepage."${hugepage}")
|
||||||
|
))
|
||||||
|
|
||||||
|
# Apply user custom settings
|
||||||
|
// (args.structuredExtraConfig or { });
|
||||||
in
|
in
|
||||||
buildLinux (
|
buildLinux (
|
||||||
(lib.removeAttrs args [
|
(lib.removeAttrs args [
|
||||||
@ -88,31 +149,10 @@ lib.makeOverridable (
|
|||||||
|
|
||||||
modDirVersion = args.modDirVersion or "${fullVersion}${defaultLocalVersion}";
|
modDirVersion = args.modDirVersion or "${fullVersion}${defaultLocalVersion}";
|
||||||
|
|
||||||
# Clang has some incompatibilities with NixOS's default kernel config
|
# CachyOS's options has some unused options for older kernel versions
|
||||||
ignoreConfigErrors = args.ignoreConfigErrors or lto;
|
ignoreConfigErrors = args.ignoreConfigErrors or true;
|
||||||
|
|
||||||
structuredExtraConfig =
|
inherit structuredExtraConfig;
|
||||||
with lib.kernel;
|
|
||||||
(
|
|
||||||
{
|
|
||||||
NR_CPUS = lib.mkForce (option (freeform "8192"));
|
|
||||||
LOCALVERSION = freeform defaultLocalVersion;
|
|
||||||
|
|
||||||
# Follow NixOS default config to not break etc overlay
|
|
||||||
OVERLAY_FS = module;
|
|
||||||
OVERLAY_FS_REDIRECT_DIR = no;
|
|
||||||
OVERLAY_FS_REDIRECT_ALWAYS_FOLLOW = yes;
|
|
||||||
OVERLAY_FS_INDEX = no;
|
|
||||||
OVERLAY_FS_XINO_AUTO = no;
|
|
||||||
OVERLAY_FS_METACOPY = no;
|
|
||||||
OVERLAY_FS_DEBUG = no;
|
|
||||||
}
|
|
||||||
// (lib.optionalAttrs lto {
|
|
||||||
LTO_NONE = no;
|
|
||||||
LTO_CLANG_THIN = yes;
|
|
||||||
})
|
|
||||||
// (args.structuredExtraConfig or { })
|
|
||||||
);
|
|
||||||
|
|
||||||
extraMeta = {
|
extraMeta = {
|
||||||
description = "Linux CachyOS Kernel" + lib.optionalString lto " with Clang+ThinLTO";
|
description = "Linux CachyOS Kernel" + lib.optionalString lto " with Clang+ThinLTO";
|
||||||
@ -121,7 +161,7 @@ lib.makeOverridable (
|
|||||||
// (args.extraMeta or { });
|
// (args.extraMeta or { });
|
||||||
|
|
||||||
extraPassthru = {
|
extraPassthru = {
|
||||||
inherit cachyosConfigFile cachyosPatch;
|
inherit cachyosConfigFile cachyosPatches;
|
||||||
}
|
}
|
||||||
// (args.extraPassthru or { });
|
// (args.extraPassthru or { });
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user