diff --git a/dev/flake.lock b/dev/flake.lock index 8e3720b..e7daf6b 100644 --- a/dev/flake.lock +++ b/dev/flake.lock @@ -1,15 +1,18 @@ { "nodes": { - "flake": { + "blank": { "locked": { - "lastModified": 0, - "narHash": "sha256-jyyAhyStjFcaG9VOipFdN0Souk/fzgTD3uQjT/I2z3w=", - "path": "../", - "type": "path" + "lastModified": 1625557891, + "narHash": "sha256-O8/MWsPBGhhyPoPLHZAuoZiiHo9q6FLlEeIDEXuj6T4=", + "owner": "divnix", + "repo": "blank", + "rev": "5a5d2684073d9f563072ed07c871d577a6c614a8", + "type": "github" }, "original": { - "path": "../", - "type": "path" + "owner": "divnix", + "repo": "blank", + "type": "github" } }, "flake-parts": { @@ -17,11 +20,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1693611461, - "narHash": "sha256-aPODl8vAgGQ0ZYFIRisxYG5MOGSkIczvu2Cd8Gb9+1Y=", + "lastModified": 1698579227, + "narHash": "sha256-KVWjFZky+gRuWennKsbo6cWyo7c/z/VgCte5pR9pEKg=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "7f53fdb7bdc5bb237da7fefef12d099e4fd611ca", + "rev": "f76e870d64779109e41370848074ac4eaa1606ec", "type": "github" }, "original": { @@ -47,11 +50,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1695962284, - "narHash": "sha256-vygWW+zz/5NHWpH7nIfNFlKiJChp6kVRXkzAcPK08hY=", + "lastModified": 1698800439, + "narHash": "sha256-SrAwRi266j7U9XqCl0qPwsvcFiQ55iPXEK36ZX6QPjE=", "owner": "nixos", "repo": "nixpkgs", - "rev": "cdd726e1deb44c031ee8975528d6b283ed8cf021", + "rev": "0ac7840a74c53b62f124e86fcde8cdd45f2bc131", "type": "github" }, "original": { @@ -64,11 +67,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1693471703, - "narHash": "sha256-0l03ZBL8P1P6z8MaSDS/MvuU8E75rVxe5eE1N6gxeTo=", + "lastModified": 1696019113, + "narHash": "sha256-X3+DKYWJm93DRSdC5M6K5hLqzSya9BjibtBsuARoPco=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "3e52e76b70d5508f3cec70b882a29199f4d1ee85", + "rev": "f5892ddac112a1e9b3612c39af1b72987ee5783a", "type": "github" }, "original": { @@ -81,7 +84,10 @@ }, "root": { "inputs": { - "flake": "flake", + "blank": "blank", + "flake": [ + "blank" + ], "flake-parts": "flake-parts", "flake-root": "flake-root", "nixpkgs": "nixpkgs", @@ -110,11 +116,11 @@ ] }, "locked": { - "lastModified": 1695822946, - "narHash": "sha256-IQU3fYo0H+oGlqX5YrgZU3VRhbt2Oqe6KmslQKUO4II=", + "lastModified": 1698438538, + "narHash": "sha256-AWxaKTDL3MtxaVTVU5lYBvSnlspOS0Fjt8GxBgnU0Do=", "owner": "numtide", "repo": "treefmt-nix", - "rev": "720bd006d855b08e60664e4683ccddb7a9ff614a", + "rev": "5deb8dc125a9f83b65ca86cf0c8167c46593e0b1", "type": "github" }, "original": { diff --git a/dev/flake.nix b/dev/flake.nix index db55fe5..be47158 100644 --- a/dev/flake.nix +++ b/dev/flake.nix @@ -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"; diff --git a/dev/updater/module.nix b/dev/updater/module.nix index b7f204d..a8c35ac 100644 --- a/dev/updater/module.nix +++ b/dev/updater/module.nix @@ -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 ''; }; }; diff --git a/pkgs/nvidia-driver/versions/default.nix b/pkgs/nvidia-driver/versions/default.nix new file mode 100644 index 0000000..dc42611 --- /dev/null +++ b/pkgs/nvidia-driver/versions/default.nix @@ -0,0 +1,3 @@ +_: { + test = "hello"; +} diff --git a/pkgs/nvidia-driver/versions/refs.json b/pkgs/nvidia-driver/versions/refs.json new file mode 100644 index 0000000..cceb7a7 --- /dev/null +++ b/pkgs/nvidia-driver/versions/refs.json @@ -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" +}