mirror of
https://github.com/strongtz/i915-sriov-dkms.git
synced 2026-05-06 13:42:34 +08:00
update flake to support xe module, fix nixos tests and update readme
This commit is contained in:
37
.github/workflows/test.yml
vendored
37
.github/workflows/test.yml
vendored
@@ -4,6 +4,7 @@ on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
|
||||
|
||||
jobs:
|
||||
test-ubuntu-plucky:
|
||||
runs-on: ubuntu-24.04
|
||||
@@ -24,7 +25,7 @@ jobs:
|
||||
KERNEL_SOURCE_DIR=$(dpkg -L $(dpkg -s linux-headers-generic | grep "Depends: " | cut -d " " -f2) | grep -m 1 -Eo ".*/lib/modules/[^/]+/build")
|
||||
KERNELRELEASE=$(echo -n "$KERNEL_SOURCE_DIR" | sed 's/.*\/lib\/modules\///g;s/\/build//')
|
||||
make -j$(nproc) KERNELRELEASE=$KERNELRELEASE -C $KERNEL_SOURCE_DIR M=$(pwd)
|
||||
|
||||
|
||||
test-proxmox-trixie:
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
@@ -70,7 +71,7 @@ jobs:
|
||||
KERNEL_SOURCE_DIR=$(pacman -Qql linux-headers | grep -m 1 -Eo ".*/lib/modules/[^/]+/build")
|
||||
KERNELRELEASE=$(echo -n "$KERNEL_SOURCE_DIR" | sed 's/.*\/lib\/modules\///g;s/\/build//')
|
||||
sudo make -j$(nproc) KERNELRELEASE=$KERNELRELEASE -C $KERNEL_SOURCE_DIR M=$(pwd)
|
||||
|
||||
|
||||
test-archlinux-lts:
|
||||
runs-on: ubuntu-24.04
|
||||
container:
|
||||
@@ -116,19 +117,19 @@ jobs:
|
||||
KERNELRELEASE=$(echo -n "$KERNEL_SOURCE_DIR" | sed 's/.*\/lib\/modules\///g;s/\/build//')
|
||||
sudo make -j$(nproc) KERNELRELEASE=$KERNELRELEASE -C $KERNEL_SOURCE_DIR M=$(pwd)
|
||||
|
||||
# test-nixos:
|
||||
# runs-on: ubuntu-24.04
|
||||
# steps:
|
||||
# - name: 'Install Nix'
|
||||
# uses: cachix/install-nix-action@v31.5.1
|
||||
# - name: Checkout
|
||||
# uses: actions/checkout@v4
|
||||
# with:
|
||||
# path: i915-sriov-dkms
|
||||
# - name: Build i915-sriov kernel module for NixOS
|
||||
# working-directory: i915-sriov-dkms
|
||||
# env:
|
||||
# GC_DONT_GC: '1'
|
||||
# run: |
|
||||
# nix --version
|
||||
# nix flake check
|
||||
test-nixos:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: 'Install Nix'
|
||||
uses: cachix/install-nix-action@v31.5.1
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
path: i915-sriov-dkms
|
||||
- name: Build i915-sriov kernel module for NixOS
|
||||
working-directory: i915-sriov-dkms
|
||||
env:
|
||||
GC_DONT_GC: '1'
|
||||
run: |
|
||||
nix --version
|
||||
nix flake check
|
||||
|
||||
@@ -52,6 +52,10 @@ You can create up to 7 VFs on Intel UHD Graphics
|
||||
For Arch Linux users, it is available in AUR. [i915-sriov-dkms](https://aur.archlinux.org/packages/i915-sriov-dkms)
|
||||
You also can download the package from the [releases page](https://github.com/strongtz/i915-sriov-dkms/releases) and install it with `pacman -U`.
|
||||
|
||||
## NixOS Linux Installation Steps (Tested Kernel 6.17)
|
||||
|
||||
For NixOS users, the i915-sriov kernel module can be directly included in your NixOS configuration without the use of DKMS. In particular, the kernel module is provided as a NixOS module that must be included in your NixOS configuration. This NixOS module places the i915-sriov kernel module via an overlay in your `pkgs` attribute set with the attribute name `i915-sriov`. This kernel module can then be included in your configuration by declaring `boot.extraModulePackages = [ pkgs.i915-sriov ];` The same applies also to `xe-sriov`. It is recommened to set `inputs.nixpkgs.follows = "nixpkgs"` to avoid version mismatch.
|
||||
|
||||
## PVE Host Installation Steps (PVE 9 with Kernel 6.14)
|
||||
1. Install build tools: `apt install build-* dkms`
|
||||
1. Install the kernel and headers for desired version: `apt install proxmox-headers-6.14 proxmox-kernel-6.14` (for unsigned kernel).
|
||||
|
||||
40
default.nix
40
default.nix
@@ -1,40 +0,0 @@
|
||||
{
|
||||
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";
|
||||
};
|
||||
}
|
||||
6
flake.lock
generated
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1748026106,
|
||||
"narHash": "sha256-6m1Y3/4pVw1RWTsrkAK2VMYSzG4MMIj7sqUy7o8th1o=",
|
||||
"lastModified": 1760038930,
|
||||
"narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "063f43f2dbdef86376cc29ad646c45c46e93234c",
|
||||
"rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
182
flake.nix
182
flake.nix
@@ -5,42 +5,158 @@
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
# dummy NixOS configuration with the i915-sriov driver
|
||||
testNixosConfiguration = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [(
|
||||
{ pkgs, modulesPath, ... }: {
|
||||
imports = [
|
||||
"${modulesPath}/profiles/minimal.nix" # reduce NixOS system size
|
||||
self.nixosModules.default # include i915-sriov kernel module in pkgs
|
||||
outputs =
|
||||
{ self, nixpkgs }:
|
||||
let
|
||||
lib = nixpkgs.lib;
|
||||
|
||||
pkgbuildLines = lib.strings.splitString "\n" (builtins.readFile ./PKGBUILD);
|
||||
versionDefinition = lib.lists.findFirst (
|
||||
line: lib.strings.hasPrefix "pkgver=" line
|
||||
) "unknown" pkgbuildLines;
|
||||
version = lib.strings.removePrefix "pkgver=" versionDefinition;
|
||||
|
||||
i915Module =
|
||||
{
|
||||
stdenv,
|
||||
nix-gitignore,
|
||||
kernel,
|
||||
}:
|
||||
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;
|
||||
|
||||
# reduce NixOS system size
|
||||
nix.enable = false;
|
||||
system.switch.enable = false;
|
||||
buildPhase = ''
|
||||
make -C ${kernel.dev}/lib/modules/${kernel.modDirVersion}/build \
|
||||
M=$PWD \
|
||||
drivers/gpu/drm/i915/i915.ko \
|
||||
compat/intel_sriov_compat.ko
|
||||
'';
|
||||
|
||||
# required for dummy system
|
||||
fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; };
|
||||
boot.loader.systemd-boot.enable = true;
|
||||
system.stateVersion = "25.11"; # do not change, see https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion
|
||||
installPhase = ''
|
||||
install -D drivers/gpu/drm/i915/i915.ko \
|
||||
$out/lib/modules/${kernel.modDirVersion}/kernel/drivers/gpu/drm/i915/i915.ko
|
||||
install -D compat/intel_sriov_compat.ko \
|
||||
$out/lib/modules/${kernel.modDirVersion}/kernel/compat/gpu/drm/i915/intel_sriov_compat.ko
|
||||
'';
|
||||
|
||||
# build and use i915-sriov kernel module
|
||||
boot.extraModulePackages = [ pkgs.i915-sriov ];
|
||||
}
|
||||
)];
|
||||
meta = {
|
||||
platforms = [ "x86_64-linux" ];
|
||||
description = "Intel i915 driver patched with SR-IOV vGPU functionality";
|
||||
homepage = "https://github.com/strongtz/i915-sriov-dkms";
|
||||
};
|
||||
};
|
||||
|
||||
xeModule =
|
||||
{
|
||||
stdenv,
|
||||
nix-gitignore,
|
||||
kernel,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
inherit version;
|
||||
name = "xe-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 \
|
||||
compat/intel_sriov_compat.ko \
|
||||
drivers/gpu/drm/xe/xe.ko
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
install -D drivers/gpu/drm/xe/xe.ko \
|
||||
$out/lib/modules/${kernel.modDirVersion}/kernel/drivers/gpu/drm/xe/xe.ko
|
||||
install -D compat/intel_sriov_compat.ko \
|
||||
$out/lib/modules/${kernel.modDirVersion}/kernel/compat/gpu/drm/xe/intel_sriov_compat.ko
|
||||
'';
|
||||
|
||||
meta = {
|
||||
platforms = [ "x86_64-linux" ];
|
||||
description = "Intel xe driver patched with SR-IOV vGPU functionality";
|
||||
homepage = "https://github.com/strongtz/i915-sriov-dkms";
|
||||
};
|
||||
};
|
||||
|
||||
# dummy NixOS configuration with the SR-IOV drivers
|
||||
testNixosConfiguration = nixpkgs.lib.nixosSystem {
|
||||
system = "x86_64-linux";
|
||||
modules = [
|
||||
(
|
||||
{ pkgs, modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
"${modulesPath}/profiles/minimal.nix" # reduce NixOS system size
|
||||
self.nixosModules.default # include the SR-IOV kernel modules in pkgs
|
||||
];
|
||||
|
||||
# reduce NixOS system size
|
||||
nix.enable = false;
|
||||
system.switch.enable = false;
|
||||
|
||||
# required for dummy system
|
||||
fileSystems."/" = {
|
||||
device = "/dev/sda1";
|
||||
fsType = "ext4";
|
||||
};
|
||||
boot = {
|
||||
loader.systemd-boot.enable = true;
|
||||
kernelPackages = pkgs.linuxPackages_latest;
|
||||
};
|
||||
|
||||
system.stateVersion = "25.11"; # do not change, see https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion
|
||||
|
||||
# build and use both SR-IOV kernel modules
|
||||
boot.extraModulePackages = [
|
||||
pkgs.i915-sriov
|
||||
pkgs.xe-sriov
|
||||
];
|
||||
}
|
||||
)
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
# builds the SR-IOV drivers
|
||||
# this requires a dummy NixOS configuration due to the driver build environment depending on the specific kernel that is used
|
||||
checks.x86_64-linux.build-i915-sriov = testNixosConfiguration.config.system.build.toplevel;
|
||||
|
||||
# include this NixOS module to include the SR-IOV kernel modules as derivations in your pkgs via an overlay
|
||||
nixosModules.default =
|
||||
{ config, ... }:
|
||||
{
|
||||
nixpkgs.overlays = [
|
||||
(final: prev: {
|
||||
i915-sriov = config.boot.kernelPackages.callPackage i915Module { };
|
||||
xe-sriov = config.boot.kernelPackages.callPackage xeModule { };
|
||||
})
|
||||
];
|
||||
};
|
||||
};
|
||||
in {
|
||||
# builds the i915-sriov driver
|
||||
# this requires a dummy NixOS configuration due to the driver build environment depending on the specific kernel that is used
|
||||
checks.x86_64-linux.build-i915-sriov = testNixosConfiguration.config.system.build.toplevel;
|
||||
|
||||
# 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 { };
|
||||
})];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user