add nix derivation of i915-sriov kernel module

This commit is contained in:
Julian Kuners
2025-07-15 03:36:03 +02:00
parent 70fc8beeb9
commit 702c6ec834
3 changed files with 83 additions and 0 deletions

40
default.nix Normal file
View File

@@ -0,0 +1,40 @@
{
lib,
stdenv,
nix-gitignore,
kernel
}:
let
pkgbuildLines = lib.strings.splitString "\n" (builtins.readFile ./PKGBUILD);
versionDefinition = lib.lists.findFirst (x: lib.strings.hasPrefix "pkgver=" x) "unknown" pkgbuildLines;
version = lib.strings.removePrefix "pkgver=" versionDefinition;
in
stdenv.mkDerivation rec {
inherit version;
name = "i915-sriov-module-${version}-${kernel.version}";
src = lib.cleanSource (nix-gitignore.gitignoreSourcePure [
./.gitignore
"result*"
] ./.
);
hardeningDisable = [ "pic" "format" ];
nativeBuildInputs = kernel.moduleBuildDependencies;
buildPhase = ''
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build M=$PWD
'';
installPhase = ''
install -D i915.ko $out/lib/modules/${kernel.modDirVersion}/kernel/drivers/gpu/drm/i915/i915.ko
'';
meta = {
platforms = [ "x86_64-linux" ];
description = "i915 patched with SR-IOV vGPU functionality";
homepage = "https://github.com/strongtz/i915-sriov-dkms";
};
}

27
flake.lock generated Normal file
View File

@@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1748026106,
"narHash": "sha256-6m1Y3/4pVw1RWTsrkAK2VMYSzG4MMIj7sqUy7o8th1o=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "063f43f2dbdef86376cc29ad646c45c46e93234c",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

16
flake.nix Normal file
View File

@@ -0,0 +1,16 @@
{
description = "kernel module of Linux i915 driver with SR-IOV support";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = { self, nixpkgs }: {
# include this NixOS module to include the i915-sriov kernel module as a derivation in your pkgs via an overlay
nixosModules.default = { config, ... }: {
nixpkgs.overlays = [(final: prev: {
i915-sriov = config.boot.kernelPackages.callPackage ./default.nix { };
})];
};
};
}