1{
2 lib,
3 stdenv,
4 fetchFromGitHub,
5 srcOnly,
6 kernel,
7 kernelModuleMakeFlags,
8 nix-update-script,
9}:
10
11stdenv.mkDerivation (finalAttrs: {
12 pname = "amneziawg";
13 version = "1.0.20240711";
14
15 src = fetchFromGitHub {
16 owner = "amnezia-vpn";
17 repo = "amneziawg-linux-kernel-module";
18 tag = "v${finalAttrs.version}";
19 hash = "sha256-WOcBTxetVz2Sr62c+2aGNyohG2ydi+R+az+4qHbKprI=";
20 };
21
22 sourceRoot = "${finalAttrs.src.name}/src";
23 hardeningDisable = [ "pic" ];
24 nativeBuildInputs = kernel.moduleBuildDependencies;
25
26 buildFlags = [
27 "apply-patches"
28 "module"
29 ];
30
31 makeFlags =
32 kernelModuleMakeFlags
33 ++ [ "KERNELDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build" ]
34 ++ lib.optional (lib.versionAtLeast kernel.version "5.6") "KERNEL_SOURCE_DIR=${srcOnly kernel}";
35
36 enableParallelBuilding = true;
37
38 installFlags = [
39 "DEPMOD=true"
40 "INSTALL_MOD_PATH=${placeholder "out"}"
41 ];
42
43 passthru.updateScript = nix-update-script { };
44
45 meta = {
46 description = "Kernel module for the AmneziaWG";
47 homepage = "https://amnezia.org";
48 license = lib.licenses.gpl2Only;
49 maintainers = with lib.maintainers; [ averyanalex ];
50 platforms = lib.platforms.linux;
51 };
52})