Hi!
I have a working kernel module derivation (see below) for the Intel SGX driver (it’s a secure enclave driver). I would like to contribute it upstream so that other users just need to add something as simple as isgx = true
in their configuration.nix
to use it. The question is how do I convert the stuff I came up with below into a pull request to nixpkgs
. Thanks in advance for suggestions.
/etc/nixos/isgx.nix
:
{ stdenv, fetchFromGitHub, kernel, kmod }:
stdenv.mkDerivation rec {
name = "isgx-${version}-${kernel.version}";
version = "2.11";
src = fetchFromGitHub {
owner = "intel";
repo = "linux-sgx-driver";
rev = "sgx_driver_2.11";
sha256 = "0z3czwxa0gs1h3hyg0bpxziyizzfnv9x6gglka6v1p3s5j00b7fd";
};
sourceRoot = "source";
hardeningDisable = [ "pic" "format" ];
nativeBuildInputs = kernel.moduleBuildDependencies;
patches = [ ./0001-NixOS.patch ];
makeFlags = [
"KDIR=${kernel.dev}/lib/modules/${kernel.modDirVersion}/build"
"INSTALL_MOD_PATH=$(out)"
];
meta = with stdenv.lib; {
description = "A kernel module to create Intel SGX driver";
homepage = "https://github.com/intel/linux-sgx-driver";
license = licenses.bsd3;
maintainers = [ maintainers.adaszko ];
platforms = platforms.linux;
};
}
/etc/nixos/0001-NixOS.patch
:
From 3161a383f0e795e73c8b5c72c408d4f36f16087d Mon Sep 17 00:00:00 2001
From: Adam Szkoda <foo@bar.com>
Date: Mon, 18 Jan 2021 09:43:03 +0100
Subject: [PATCH] NixOS patches
---
Makefile | 2 --
1 file changed, 2 deletions(-)
diff --git a/Makefile b/Makefile
index c0963fc..a4f9605 100644
--- a/Makefile
+++ b/Makefile
@@ -17,8 +17,6 @@ default:
install: default
$(MAKE) INSTALL_MOD_DIR=kernel/drivers/intel/sgx -C $(KDIR) M=$(PWD) modules_install
- depmod -A
- sh -c "cat /etc/modules | grep -Fxq isgx || echo isgx >> /etc/modules"
endif
--
2.29.2
In /etc/nixos/configuration.nix
:
{ config, pkgs, ... }:
let isgx = config.boot.kernelPackages.callPackage ./isgx.nix { };
in {
...
boot.extraModulePackages = [ isgx ];
...
}