{ cachyConfig, kconfigToNix, config, configfile, callPackage, lib, linuxManualConfig, stdenv, # Weird injections kernelPatches ? [ ], features ? null, randstructSeed ? "", pname ? "unknown", # For tests kernelPackages, flakes, final, }: let version = if stdenv.isAarch64 then "6.12.47" else cachyConfig.versions.linux.version; # Single-value optional attr optionalAttr = key: pred: value: if pred then { "${key}" = value; } else { }; in (linuxManualConfig { inherit pname stdenv version features randstructSeed ; inherit (configfile) src; modDirVersion = lib.versions.pad 3 "${version}${cachyConfig.versions.suffix}"; inherit config configfile; allowImportFromDerivation = false; kernelPatches = kernelPatches ++ builtins.map (filename: { name = builtins.baseNameOf filename; patch = filename; }) configfile.passthru.kernelPatches; extraMeta = { maintainers = with lib.maintainers; [ dr460nf1r3 pedrohlc ]; inherit (configfile.meta) platforms; }; }).overrideAttrs (prevAttrs: { # Apply patches with --forward (skip already-merged/reversed hunks) and # --fuzz=3 (tolerate minor context mismatches due to kernel version skew). patchPhase = '' runHook prePatch for p in $patches; do echo "applying patch $p" patch -p1 --forward --fuzz=3 < "$p" || true done runHook postPatch ''; postPatch = prevAttrs.postPatch + configfile.extraVerPatch; # bypasses https://github.com/NixOS/nixpkgs/issues/216529 passthru = prevAttrs.passthru // { inherit cachyConfig kconfigToNix; features = { efiBootStub = true; ia32Emulation = stdenv.isx86_64; netfilterRPFilter = true; }; isLTS = false; isZen = true; isHardened = cachyConfig.cpuSched == "hardened"; isLibre = false; updateScript = null; tests = null; } // optionalAttr "updateScript" (cachyConfig.withUpdateScript != null) ( callPackage ./update.nix { inherit (cachyConfig) withUpdateScript; } ); })