This repository has been archived on 2024-08-18. You can view files and clone it, but cannot push or open issues or pull requests.
linux-hardened/linux-hardened.nix

70 lines
1.6 KiB
Nix
Raw Normal View History

2024-08-12 21:12:18 +02:00
pkgs: { arch, config, firmware }:
2024-07-31 11:00:49 +02:00
let
2024-08-03 10:28:48 +02:00
inherit (pkgs)
lib
2024-08-06 22:55:23 +02:00
buildEnv
2024-08-03 10:28:48 +02:00
buildLinux
fetchFromGitHub
gccStdenv
2024-08-12 21:12:18 +02:00
runCommand;
2024-07-31 11:00:49 +02:00
2024-08-12 21:12:18 +02:00
kernel = let
args = {
inherit (pkgs) lib hostPlatform;
};
2024-08-02 22:14:55 +02:00
2024-08-12 21:12:18 +02:00
firmwareEnv = buildEnv {
name = "linux-firmware";
pathsToLink = [ "/lib/firmware" ];
paths = with pkgs; [
linux-firmware
sof-firmware
wireless-regdb
];
};
in buildLinux rec {
2024-08-03 10:28:48 +02:00
pname = "linux-hardened";
2024-08-12 14:57:54 +02:00
version = "6.10.4-hardened1";
2024-08-02 22:14:55 +02:00
2024-08-03 10:28:48 +02:00
src = fetchFromGitHub {
owner = "anthraxx";
repo = pname;
rev = "v${version}";
2024-08-12 14:57:54 +02:00
hash = "sha256-qq2vmrUIYUuXEwuZoXrXbZY/li+ReFNuqhsy1R0yx0s=";
2024-08-03 10:28:48 +02:00
};
2024-08-02 22:14:55 +02:00
2024-08-03 10:28:48 +02:00
defconfig = "allnoconfig";
extraMakeFlags = [ "KCFLAGS=-march=${arch}" ];
enableCommonConfig = false;
2024-08-02 22:14:55 +02:00
2024-08-03 10:28:48 +02:00
structuredExtraConfig =
2024-08-12 21:12:18 +02:00
(import ./base.nix args) //
(import config args) //
lib.optionalAttrs (firmware != [ ]) {
2024-08-03 10:28:48 +02:00
EXTRA_FIRMWARE = lib.kernel.freeform (toString firmware);
2024-08-06 22:55:23 +02:00
EXTRA_FIRMWARE_DIR = lib.kernel.freeform "${firmwareEnv}/lib/firmware";
2024-08-03 10:28:48 +02:00
};
2024-08-02 22:14:55 +02:00
2024-08-03 10:28:48 +02:00
features = {
efiBootStub = true;
};
2024-08-12 21:12:18 +02:00
2024-08-03 10:28:48 +02:00
isHardened = true;
stdenv = gccStdenv;
};
2024-08-12 21:12:18 +02:00
in kernel.overrideAttrs (base: {
2024-08-03 10:28:48 +02:00
installFlags = base.installFlags or [ ] ++ [ "INSTALL_MOD_PATH=$(out)" ];
2024-07-31 11:00:49 +02:00
postInstall = ''
if [ -z "''${dontStrip-}" ]; then
installFlagsArray+=( "INSTALL_MOD_STRIP=1" )
fi
make modules_install $makeFlags "''${makeFlagsArray[@]}" \
$installFlags "''${installFlagsArray[@]}"
depmod -b $out ${base.version}
touch $out/lib/modules/${base.version}/modules.order
'';
})