1{ lib, stdenv, fetchFromGitHub, kernel }:
2
3stdenv.mkDerivation rec {
4 version = "2.12.0";
5 name = "ena-${version}-${kernel.version}";
6
7 src = fetchFromGitHub {
8 owner = "amzn";
9 repo = "amzn-drivers";
10 rev = "ena_linux_${version}";
11 hash = "sha256-Z/eeIUY7Yl2l/IqK3Z2nxPhn+JLvP976IZ9ZXPBqoSo=";
12 };
13
14 hardeningDisable = [ "pic" ];
15
16 nativeBuildInputs = kernel.moduleBuildDependencies;
17 makeFlags = kernel.makeFlags;
18
19 # linux 3.12
20 env.NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration";
21
22 patches = [
23 # Use kernel version checks instead of API feature detection
24 # See https://github.com/NixOS/nixpkgs/pull/310680
25 ./override-features-api-detection.patch
26 ];
27
28 configurePhase = ''
29 runHook preConfigure
30 cd kernel/linux/ena
31 export ENA_PHC_INCLUDE=1
32 substituteInPlace Makefile --replace '/lib/modules/$(BUILD_KERNEL)' ${kernel.dev}/lib/modules/${kernel.modDirVersion}
33 runHook postConfigure
34 '';
35
36 installPhase = ''
37 runHook preInstall
38 $STRIP -S ena.ko
39 dest=$out/lib/modules/${kernel.modDirVersion}/misc
40 mkdir -p $dest
41 cp ena.ko $dest/
42 xz $dest/ena.ko
43 runHook postInstall
44 '';
45
46 meta = with lib; {
47 description = "Amazon Elastic Network Adapter (ENA) driver for Linux";
48 homepage = "https://github.com/amzn/amzn-drivers";
49 license = licenses.gpl2Only;
50 maintainers = with maintainers; [ eelco sielicki ];
51 platforms = platforms.linux;
52 };
53}