diff options
| author | Gregor Kleen <gkleen@yggdrasil.li> | 2025-06-24 08:56:15 +0200 |
|---|---|---|
| committer | Gregor Kleen <gkleen@yggdrasil.li> | 2025-06-24 08:56:15 +0200 |
| commit | 80f4eda582aa6a1baf35398b34ee5e5d8da7f1ed (patch) | |
| tree | 03f4c7b4e50383cf0d6d18ef61fab9e2b68c6171 /modules | |
| parent | eace3120ad5e1d2f9d56c93a6e649ded32809284 (diff) | |
| download | nixos-80f4eda582aa6a1baf35398b34ee5e5d8da7f1ed.tar nixos-80f4eda582aa6a1baf35398b34ee5e5d8da7f1ed.tar.gz nixos-80f4eda582aa6a1baf35398b34ee5e5d8da7f1ed.tar.bz2 nixos-80f4eda582aa6a1baf35398b34ee5e5d8da7f1ed.tar.xz nixos-80f4eda582aa6a1baf35398b34ee5e5d8da7f1ed.zip | |
...
Diffstat (limited to 'modules')
| -rw-r--r-- | modules/llvm_kernel.nix | 59 |
1 files changed, 0 insertions, 59 deletions
diff --git a/modules/llvm_kernel.nix b/modules/llvm_kernel.nix deleted file mode 100644 index 42b8bf95..00000000 --- a/modules/llvm_kernel.nix +++ /dev/null | |||
| @@ -1,59 +0,0 @@ | |||
| 1 | { config, pkgs, lib, ... }: | ||
| 2 | let | ||
| 3 | cfg = config.boot.kernel.llvm; | ||
| 4 | in { | ||
| 5 | options = { | ||
| 6 | boot.kernel.llvm = { | ||
| 7 | enable = lib.mkEnableOption "building linux kernel with clang/LLVM" // { | ||
| 8 | default = true; | ||
| 9 | }; | ||
| 10 | |||
| 11 | kernel = lib.mkPackageOption pkgs [ "linuxKernel" "kernels" "linux_default" ] {}; | ||
| 12 | }; | ||
| 13 | }; | ||
| 14 | |||
| 15 | config = lib.mkIf cfg.enable { | ||
| 16 | boot.kernelPackages = | ||
| 17 | with pkgs; # Cut down on repeated `pkgs.` declarations | ||
| 18 | let | ||
| 19 | # Choose whichever LLVM version you please. `llvmPackages` is the | ||
| 20 | # default version, `llvmPackages_latest` is the latest (at the time of | ||
| 21 | # writing, LLVM 17.0.6 and 18.1.8 respectively). | ||
| 22 | llvm = llvmPackages_latest; | ||
| 23 | # Same deal as LLVM; choose whichever kernel version you like. | ||
| 24 | # `linux` is the latest LTS, `linux_latest` is the latest stable. | ||
| 25 | inherit (cfg) kernel; | ||
| 26 | in | ||
| 27 | # Generate kernel modules for our custom kernel. | ||
| 28 | linuxPackagesFor ( | ||
| 29 | # Override our chosen kernel version with our custom settings. | ||
| 30 | (kernel.override { | ||
| 31 | # Set our chosen version of LLVM as our standard environment. | ||
| 32 | stdenv = overrideCC llvm.stdenv ( | ||
| 33 | # Tell our C compiler (Clang) to use LLVM bintools--normally GNU | ||
| 34 | # binutils are used even with Clang as the compiler. | ||
| 35 | llvm.stdenv.cc.override { | ||
| 36 | bintools = llvm.bintools; | ||
| 37 | } | ||
| 38 | ); | ||
| 39 | |||
| 40 | # Tell Linux that we're compiling with Clang and LLVM. | ||
| 41 | extraMakeFlags = [ "LLVM=1" ]; | ||
| 42 | |||
| 43 | # If you'd like to edit your kernel configuration, use | ||
| 44 | # `structuredExtraConfig`. For example, some options available to us | ||
| 45 | # when compiling with Clang and linking with LLD: | ||
| 46 | structuredExtraConfig = { | ||
| 47 | # CFI_CLANG = lib.kernel.yes; | ||
| 48 | # LTO_CLANG_THIN = lib.kernel.yes; | ||
| 49 | }; | ||
| 50 | } | ||
| 51 | ).overrideAttrs | ||
| 52 | # Work around another NixOS specific issue where builds with WERROR=y | ||
| 53 | # are stopped by a benign error. See reference 1 below for details. | ||
| 54 | # Technically, this fix is only necessary with WERROR=y but the issue | ||
| 55 | # still causes a warning on builds where WERROR is unset. | ||
| 56 | { env.NIX_CFLAGS_COMPILE = "-Wno-unused-command-line-argument"; } | ||
| 57 | ); | ||
| 58 | }; | ||
| 59 | } | ||
