mirror of
https://github.com/icewind1991/nvidia-patch-nixos.git
synced 2026-06-03 11:04:06 +02:00
initial version
This commit is contained in:
commit
4cb018c16d
7 changed files with 184 additions and 0 deletions
1
.envrc
Normal file
1
.envrc
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
use flake
|
||||||
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
/result
|
||||||
|
/.direnv
|
||||||
23
extract-object-list.diff
Normal file
23
extract-object-list.diff
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
diff --git a/patch-fbc.sh b/patch.sh
|
||||||
|
index 03bd467..2e78af9 100644
|
||||||
|
--- a/patch.sh
|
||||||
|
+++ b/patch.sh
|
||||||
|
@@ -406,12 +406,9 @@ list_supported_versions () {
|
||||||
|
get_supported_versions
|
||||||
|
}
|
||||||
|
|
||||||
|
-case "${opmode}" in
|
||||||
|
- patch) patch ;;
|
||||||
|
- patchrollback) rollback ;;
|
||||||
|
- patchhelp) print_usage ; exit 2 ;;
|
||||||
|
- patchcheckversion) query_version_support ;;
|
||||||
|
- patchlistversions) list_supported_versions ;;
|
||||||
|
- *) echo "Incorrect combination of flags. Use option -h to get help."
|
||||||
|
- exit 2 ;;
|
||||||
|
-esac
|
||||||
|
+for i in "${!object_list[@]}"
|
||||||
|
+do
|
||||||
|
+ echo "$i"
|
||||||
|
+ echo "${object_list[$i]}"
|
||||||
|
+done |
|
||||||
|
+jq -n -R 'reduce inputs as $i ({}; . + { ($i): (input|(tonumber? // .)) })'
|
||||||
23
extract-patch-list.diff
Normal file
23
extract-patch-list.diff
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
diff --git a/patch-fbc.sh b/patch.sh
|
||||||
|
index 03bd467..a7f52a1 100644
|
||||||
|
--- a/patch.sh
|
||||||
|
+++ b/patch.sh
|
||||||
|
@@ -406,12 +406,9 @@ list_supported_versions () {
|
||||||
|
get_supported_versions
|
||||||
|
}
|
||||||
|
|
||||||
|
-case "${opmode}" in
|
||||||
|
- patch) patch ;;
|
||||||
|
- patchrollback) rollback ;;
|
||||||
|
- patchhelp) print_usage ; exit 2 ;;
|
||||||
|
- patchcheckversion) query_version_support ;;
|
||||||
|
- patchlistversions) list_supported_versions ;;
|
||||||
|
- *) echo "Incorrect combination of flags. Use option -h to get help."
|
||||||
|
- exit 2 ;;
|
||||||
|
-esac
|
||||||
|
+for i in "${!patch_list[@]}"
|
||||||
|
+do
|
||||||
|
+ echo "$i"
|
||||||
|
+ echo "${patch_list[$i]}"
|
||||||
|
+done |
|
||||||
|
+jq -n -R 'reduce inputs as $i ({}; . + { ($i): (input|(tonumber? // .)) })'
|
||||||
47
extract.nix
Normal file
47
extract.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
||||||
|
{
|
||||||
|
stdenv,
|
||||||
|
lib,
|
||||||
|
jq,
|
||||||
|
fetchFromGitHub,
|
||||||
|
patch,
|
||||||
|
}:
|
||||||
|
rev: sha256: stdenv.mkDerivation rec {
|
||||||
|
pname = "nvidia-patch";
|
||||||
|
version = rev;
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
inherit rev sha256;
|
||||||
|
owner = "keylase";
|
||||||
|
repo = pname;
|
||||||
|
};
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
jq
|
||||||
|
patch
|
||||||
|
];
|
||||||
|
|
||||||
|
dontConfigure = true;
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
cp ${src}/patch.sh patch.sh
|
||||||
|
patch -p1 < ${./extract-patch-list.diff}
|
||||||
|
bash patch.sh > patch-list.json
|
||||||
|
|
||||||
|
cp ${src}/patch.sh patch.sh
|
||||||
|
patch -p1 < ${./extract-object-list.diff}
|
||||||
|
bash patch.sh > object-list.json
|
||||||
|
|
||||||
|
cp ${src}/patch-fbc.sh patch.sh
|
||||||
|
patch -p1 < ${./extract-patch-list.diff}
|
||||||
|
bash patch.sh > fbc-patch-list.json
|
||||||
|
|
||||||
|
cp ${src}/patch-fbc.sh patch.sh
|
||||||
|
patch -p1 < ${./extract-object-list.diff}
|
||||||
|
bash patch.sh > fbc-object-list.json
|
||||||
|
'';
|
||||||
|
|
||||||
|
installPhase = ''
|
||||||
|
mkdir -p $out
|
||||||
|
cp *.json $out
|
||||||
|
'';
|
||||||
|
}
|
||||||
42
flake.lock
generated
Normal file
42
flake.lock
generated
Normal file
|
|
@ -0,0 +1,42 @@
|
||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1672580127,
|
||||||
|
"narHash": "sha256-3lW3xZslREhJogoOkjeZtlBtvFMyxHku7I/9IVehhT8=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "0874168639713f547c05947c76124f78441ea46c",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"id": "nixpkgs",
|
||||||
|
"ref": "release-22.05",
|
||||||
|
"type": "indirect"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs",
|
||||||
|
"utils": "utils"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"utils": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1667395993,
|
||||||
|
"narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=",
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "numtide",
|
||||||
|
"repo": "flake-utils",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
46
flake.nix
Normal file
46
flake.nix
Normal file
|
|
@ -0,0 +1,46 @@
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
utils.url = "github:numtide/flake-utils";
|
||||||
|
nixpkgs.url = "nixpkgs/release-22.05";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
self,
|
||||||
|
nixpkgs,
|
||||||
|
utils,
|
||||||
|
}:
|
||||||
|
utils.lib.eachDefaultSystem (system: let
|
||||||
|
pkgs = (import nixpkgs) {
|
||||||
|
inherit system;
|
||||||
|
};
|
||||||
|
rev = "0fa9170";
|
||||||
|
hash = "sha256-+BkDUfVqqYMAG62OarNPJiNfghvHpOhhMlS5H+SV1dQ=";
|
||||||
|
in rec {
|
||||||
|
# `nix develop`
|
||||||
|
devShell = pkgs.mkShell {
|
||||||
|
nativeBuildInputs = with pkgs; [jq patch];
|
||||||
|
};
|
||||||
|
|
||||||
|
extract = pkgs.callPackage ./extract.nix {};
|
||||||
|
createPatch = prefix: driverPackage: rev: hash: driverPackage.overrideAttrs ({
|
||||||
|
version,
|
||||||
|
preFixup ? "",
|
||||||
|
...
|
||||||
|
}: let
|
||||||
|
inherit (nixpkgs.lib) importJSON traceVal;
|
||||||
|
jsons = extract rev hash;
|
||||||
|
patchList = importJSON "${jsons}/${prefix}patch-list.json";
|
||||||
|
objectList = importJSON "${jsons}/${prefix}object-list.json";
|
||||||
|
object = (traceVal objectList.${version});
|
||||||
|
patch = (traceVal patchList.${version});
|
||||||
|
in {
|
||||||
|
preFixup =
|
||||||
|
preFixup
|
||||||
|
+ ''
|
||||||
|
sed -i '${patch}' $out/lib/${object}.${version}
|
||||||
|
'';
|
||||||
|
});
|
||||||
|
patchNvenc = createPatch "";
|
||||||
|
patchFbc = createPatch "fbc-";
|
||||||
|
});
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue