mirror of
https://github.com/xddxdd/nix-cachyos-kernel.git
synced 2026-07-03 11:08:07 +02:00
Keep Makefile patch for a few kmods that want gcc
This commit is contained in:
parent
eaacd115fa
commit
de4bf344b2
10
README.md
10
README.md
@ -365,6 +365,16 @@ Additional arguments are passed through to `buildLinux` from nixpkgs. See [nixpk
|
|||||||
# Additional args are available. See kernel-cachyos/mkCachyKernel.nix
|
# Additional args are available. See kernel-cachyos/mkCachyKernel.nix
|
||||||
};
|
};
|
||||||
|
|
||||||
|
# For non-LTO kernels
|
||||||
kernelPackages = pkgs.linuxKernel.packagesFor kernel;
|
kernelPackages = pkgs.linuxKernel.packagesFor kernel;
|
||||||
|
|
||||||
|
|
||||||
|
# For LTO kernels, helpers.kernelModuleLLVMOverride fixes compilation for some
|
||||||
|
# out-of-tree modules in nixpkgs.
|
||||||
|
kernelPackagesWithLTOFix = let
|
||||||
|
# helpers.nix provides a few utilities for building kernel with LTO.
|
||||||
|
# I haven't figured out a clean way to expose it in flakes.
|
||||||
|
helpers = pkgs.callPackage "${inputs.nix-cachyos-kernel.outPath}/helpers.nix" {};
|
||||||
|
in helpers.kernelModuleLLVMOverride (pkgs.linuxKernel.packagesFor kernel);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|||||||
24
helpers.nix
24
helpers.nix
@ -55,4 +55,28 @@ rec {
|
|||||||
pkgs.patchelf
|
pkgs.patchelf
|
||||||
];
|
];
|
||||||
});
|
});
|
||||||
|
|
||||||
|
kernelModuleLLVMOverride =
|
||||||
|
kernelPackages_:
|
||||||
|
kernelPackages_.extend (
|
||||||
|
_final: prev:
|
||||||
|
lib.mapAttrs (
|
||||||
|
n: v:
|
||||||
|
if
|
||||||
|
builtins.elem "LLVM=1" kernelPackages_.kernel.commonMakeFlags
|
||||||
|
&& !(builtins.elem n [ "kernel" ])
|
||||||
|
&& lib.isDerivation v
|
||||||
|
&& ((v.overrideAttrs or null) != null)
|
||||||
|
then
|
||||||
|
v.overrideAttrs (old: {
|
||||||
|
postPatch = (if (old.postPatch or null) == null then "" else old.postPatch) + ''
|
||||||
|
if [ -f Makefile ]; then
|
||||||
|
substituteInPlace Makefile --replace "gcc" "cc"
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
})
|
||||||
|
else
|
||||||
|
v
|
||||||
|
) prev
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,12 +6,16 @@
|
|||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
helpers = callPackage ../helpers.nix { };
|
||||||
|
inherit (helpers) kernelModuleLLVMOverride;
|
||||||
|
|
||||||
kernels = lib.filterAttrs (_: lib.isDerivation) (callPackage ./. { inherit inputs; });
|
kernels = lib.filterAttrs (_: lib.isDerivation) (callPackage ./. { inherit inputs; });
|
||||||
in
|
in
|
||||||
lib.mapAttrs' (
|
lib.mapAttrs' (
|
||||||
n: v:
|
n: v:
|
||||||
let
|
let
|
||||||
packages = (linuxKernel.packagesFor v).extend (
|
packages = kernelModuleLLVMOverride (
|
||||||
|
(linuxKernel.packagesFor v).extend (
|
||||||
final: prev:
|
final: prev:
|
||||||
let
|
let
|
||||||
variant = lib.removePrefix "linux-cachyos-" v.cachyosConfigVariant;
|
variant = lib.removePrefix "linux-cachyos-" v.cachyosConfigVariant;
|
||||||
@ -21,6 +25,7 @@ lib.mapAttrs' (
|
|||||||
inherit inputs variant;
|
inherit inputs variant;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
lib.nameValuePair "linuxPackages-${lib.removePrefix "linux-" n}" packages
|
lib.nameValuePair "linuxPackages-${lib.removePrefix "linux-" n}" packages
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user