Skip to content

Commit

Permalink
nvchecker works
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiskae committed Nov 1, 2023
1 parent b477d66 commit dcc530c
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 93 deletions.
46 changes: 26 additions & 20 deletions dev/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion dev/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
description = "nvidia.nix dev flake";

inputs = {
flake.url = "path:../";
flake.follows = "blank";

nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable-small";

blank.url = "github:divnix/blank";

treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";

Expand Down
192 changes: 120 additions & 72 deletions dev/updater/module.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,95 +8,143 @@
config,
...
}: {
flake-root.projectRootFile = "pkgs/overlay.nix";
flake-root.projectRootFile = ".git/config";

devShells.update = let
inherit (pkgs) lib python3 formats;
inherit (pkgs) writeText lib formats;

pytools = python3.withPackages (ps: [
ps.nvchecker
ps.lxml
]);
versions = pkgs.callPackage "${inputs.flake}/pkgs/nvidia-driver/versions" {};

extra_sources = lib.fileset.toSource {
root = ./.;
fileset = ./nvchecker_source;
};
nvchecker = let
nvchecker_config = {
"__config__" = {
# todo: derive from versions directory
"oldver" = "\${FLAKE_ROOT}/pkgs/nvidia-driver/versions/refs.json";
"newver" = "\${SCRATCHDIR}/current-versions.json";
};

configFormat = formats.toml {};
configFile = configFormat.generate "nvchecker.toml" {
"__config__" = {
"oldver" = "\${FLAKE_ROOT}/pkgs/refs.json";
#"newver" = "\${FLAKE_ROOT}/dev/current-versions.json";
};
"driver.vulkan-dev" = {
source = "htmlparser";
prefix = "Linux ";
include_regex = "^Linux [.0-9]+$";
url = "https://developer.nvidia.com/vulkan-driver";
xpath = ''//*[@id="content"]/div/section/h3'';
};
"driver.display" = {
source = "unix_drivers";
known = lib.mapAttrsToList (match: data:
{
inherit match;
}
// data) {
"Production Branch Version" = {
maturity = "long-lived-branch-release";
};
"New Feature Branch Version" = {};
"Beta Version" = {
maturity = "beta";
};
"Legacy GPU version (470.xx series)" = {
branch = "R470_00";
};
"Legacy GPU version (390.xx series)" = {
branch = "R390_00";
};
"Legacy GPU version (340.xx series)" = {
branch = "R340_00";
};
"Legacy GPU version (304.xx series)" = {
branch = "R304_00";
};
"Legacy GPU Version (71.86.xx series)" = {
branch = "L7160";
};
"Legacy GPU Version (96.43.xx series)" = {
branch = "L9622";
};
"Legacy GPU Version (173.14.xx series)" = {
branch = "R173_14";
"vulkan-dev" = {
source = "htmlparser";
prefix = "Linux ";
include_regex = "^Linux [.0-9]+$";
url = "https://developer.nvidia.com/vulkan-driver";
xpath = ''//*[@id="content"]/div/section/h3'';
};

"geforce" = {
source = "unix_drivers";

# branch/maturity mapping based on
# https://github.com/aaronp24/nvidia-versions
known = lib.mapAttrsToList (match: data:
{
inherit match;
}
// data) {
"Production Branch Version" = {
maturity = "long-lived-branch-release";
};
"New Feature Branch Version" = {};
"Beta Version" = {
maturity = "beta";
};
"Legacy GPU version (470.xx series)" = {
branch = "R470_00";
};
"Legacy GPU version (390.xx series)" = {
branch = "R390_00";
};
"Legacy GPU version (340.xx series)" = {
branch = "R340_00";
};
"Legacy GPU version (304.xx series)" = {
branch = "R304_00";
};
"Legacy GPU Version (71.86.xx series)" = {
branch = "L7160";
};
"Legacy GPU Version (96.43.xx series)" = {
branch = "L9622";
};
"Legacy GPU Version (173.14.xx series)" = {
branch = "R173_14";
};
};
};

"tesla" = {
source = "tesla_releases";
url = "https://docs.nvidia.com/datacenter/tesla/drivers/releases.json";

# tesla versions prepend date, so newer releases supercede
from_pattern = ''(?:[^-]+-)*(.+)'';
to_pattern = ''\1'';
};
};
"driver.tesla" = {
source = "tesla_releases";
url = "https://docs.nvidia.com/datacenter/tesla/drivers/releases.json";
from_pattern = ''(?:[^-]+-)*(.+)'';
to_pattern = ''\1'';

nvchecker_extra = lib.fileset.toSource {
root = ./.;
fileset = ./nvchecker_source;
};
};

configFormat = formats.toml {};
configFile = configFormat.generate "nvchecker.toml" nvchecker_config;

packageOverrides = self: super: {
nvchecker = super.nvchecker.overridePythonAttrs (old: {
propagatedBuildInputs = old.propagatedBuildInputs ++ [self.lxml];
makeWrapperArgs = [
''--append-flags "-c ${configFile}"''
''--prefix PYTHONPATH : ${nvchecker_extra}''
];
});
};
python = pkgs.python3.override {
inherit packageOverrides;
self = python;
};
in
python.withPackages (ps: [ps.nvchecker]);

jqHandleArray = writeText "map-arr.jq" ''
.[] | [
.name,
.newver
] | @tsv
'';
in
pkgs.mkShell {
packages = [pytools pkgs.jq];
packages = [nvchecker pkgs.jq];

inputsFrom = [config.flake-root.devShell];

env = {
PYTHONPATH = toString extra_sources;
NVCHECKER_CONFIG = toString configFile;
};

shellHook = ''
export SCRATCHDIR=$(mktemp -d)
handleNewVersion() {
local name="$1"
local version="$2"
nvchecker -c ''${NVCHECKER_CONFIG}
case "$name" in
driver.vulkan-dev)
echo "VULKAN"
;;
driver.display.*)
echo "DISPLAY"
;;
driver.tesla.*)
echo "TESLA"
;;
*)
echo "WHAT"
;;
esac
echo "$name => $version"
}
export SCRATCHDIR=$(mktemp -d)
trap 'rm -rf -- "$SCRATCHDIR"' EXIT
exit
exec nvchecker
'';
};
};
Expand Down
3 changes: 3 additions & 0 deletions pkgs/nvidia-driver/versions/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
_: {
test = "hello";
}
23 changes: 23 additions & 0 deletions pkgs/nvidia-driver/versions/refs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"geforce.L7160.official": "71.86.15",
"geforce.L9622.official": "96.43.23",
"geforce.R173_14.official": "173.14.39",
"geforce.R304_00.official": "304.137",
"geforce.R340_00.official": "340.108",
"geforce.R390_00.official": "390.157",
"geforce.R470_00.official": "470.223.02",
"geforce.current.beta": "545.23.06",
"geforce.current.long-lived-branch-release": "535.129.03",
"geforce.current.official": "545.29.02",
"tesla.r450": "450.248.02",
"tesla.r460": "460.106.00",
"tesla.r465": "465.24.02",
"tesla.r470": "470.223.02",
"tesla.r495": "495.44",
"tesla.r510": "510.108.03",
"tesla.r515": "515.105.01",
"tesla.r520": "520.56.06",
"tesla.r525": "525.147.05",
"tesla.r535": "535.129.03",
"vulkan-dev": "535.43.15"
}

0 comments on commit dcc530c

Please sign in to comment.