keylase / nvidia-patch

This patch removes restriction on maximum number of simultaneous NVENC video encoding sessions imposed by Nvidia to consumer-grade GPUs.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extrct patches from patch.sh

noonien opened this issue · comments

Hello!

I would like to add NixOS support for nvidia-patch, however, NixOS works completely differently from other OSs, the patch script would not work, even though patching the driver is very easy.

The problem is that the patch.sh has code to do more than just patch the driver, it searches for the driver, identifies versions, etc. This is not something that's needed for NixOS. All that's ended is a script that takes as arguments the version and path of the file to be patched, and patches it.

An alternative would be to also have the patches as a separate, more parseable file.

@noonien you can create another script that sources the patch.sh script and read/lookup the patch_list bash dictionary:

declare -A patch_list=(

This script for example did something similar https://github.com/arcnmx/nixexprs/blob/36583070152bb7bed68e56feeff29889a227ef01/pkgs/public/linux/default.nix#L161 (on an older version of the patch.sh script which had two dictionaries)

While this solves the issue, sourcing patch.sh will pollute the environment of the including script, it is a brittle integration which can break if patch.sh declares things that are already in the environment.

@noonien I understand your concern, in fact I too had to write ugly bash scripts for automating updating the patch.sh files.

The only reason I am not switching away to keeping the actual bytecode outside the bash script is that many people do:

curl https://raw.githubusercontent.com/keylase/nvidia-patch/master/patch.sh | sh

or similar without ever cloning the github repository.

If it becomes a big headache I might break this particular workflow, but it's workable for now.


To avoid polluting the environment you can try a multi-line grep or similar to extract only the patch_list dictionary and nothing else from patch.sh.

An alternative would be to also have the patches as a separate, more parseable file.

I think something that might work is keeping just the patch_list in a separate file - and source it in patch.sh. To avoid breaking the curl ...patch.sh | sh workflow, we can add a check that if the patch_list file is missing in the local directory then curl that too before sourcing.

Patches welcome if you want to implement something like that.