From 1bd8073958723e38bbb7d51aab1fe7b37c2e5236 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Fri, 21 Mar 2025 17:14:23 +0000 Subject: [PATCH 01/26] nixos/test-driver: add backdoor based on systemd-ssh-proxy & AF_VSOCK With this it's possible to trivially SSH into running machines from the test-driver. This is especially useful when running VM tests interactively on a remote system. This is based on `systemd-ssh-proxy(1)`, so there's no need to configure any additional networking on the host-side. Suggested-by: Ryan Lahfa --- ...nning-nixos-tests-interactively.section.md | 29 +++++++++++++++++++ nixos/doc/manual/redirects.json | 6 ++++ nixos/lib/testing/nodes.nix | 22 +++++++++++--- .../modules/testing/test-instrumentation.nix | 20 +++++++++++++ 4 files changed, 73 insertions(+), 4 deletions(-) diff --git a/nixos/doc/manual/development/running-nixos-tests-interactively.section.md b/nixos/doc/manual/development/running-nixos-tests-interactively.section.md index b65cab992253..2b0f44a04e44 100644 --- a/nixos/doc/manual/development/running-nixos-tests-interactively.section.md +++ b/nixos/doc/manual/development/running-nixos-tests-interactively.section.md @@ -63,6 +63,35 @@ using: Once the connection is established, you can enter commands in the socat terminal where socat is running. +## SSH Access for test machines {#sec-nixos-test-ssh-access} + +An SSH-based backdoor to log into machines can be enabled with + +```nix +{ + name = "…"; + nodes.machines = { /* … */ }; + sshBackdoor.enable = true; +} +``` + +This creates a [vsock socket](https://man7.org/linux/man-pages/man7/vsock.7.html) +for each VM to log in with SSH. This configures root login with an empty password. + +When the VMs get started interactively with the test-driver, it's possible to +connect to `machine` with + +``` +$ ssh vsock/3 -o User=root +``` + +The socket numbers correspond to the node number of the test VM, but start +at three instead of one because that's the lowest possible +vsock number. + +On non-NixOS systems you'll probably need to enable +the SSH config from {manpage}`systemd-ssh-proxy(1)` yourself. + ## Port forwarding to NixOS test VMs {#sec-nixos-test-port-forwarding} If your test has only a single VM, you may use e.g. diff --git a/nixos/doc/manual/redirects.json b/nixos/doc/manual/redirects.json index be29c7ca049a..b493295b9908 100644 --- a/nixos/doc/manual/redirects.json +++ b/nixos/doc/manual/redirects.json @@ -1817,6 +1817,9 @@ "sec-test-options-reference": [ "index.html#sec-test-options-reference" ], + "test-opt-sshBackdoor.enable": [ + "index.html#test-opt-sshBackdoor.enable" + ], "test-opt-defaults": [ "index.html#test-opt-defaults" ], @@ -1904,6 +1907,9 @@ "sec-nixos-test-shell-access": [ "index.html#sec-nixos-test-shell-access" ], + "sec-nixos-test-ssh-access": [ + "index.html#sec-nixos-test-ssh-access" + ], "sec-nixos-test-port-forwarding": [ "index.html#sec-nixos-test-port-forwarding" ], diff --git a/nixos/lib/testing/nodes.nix b/nixos/lib/testing/nodes.nix index caefac6c748c..ee9e7ebeae68 100644 --- a/nixos/lib/testing/nodes.nix +++ b/nixos/lib/testing/nodes.nix @@ -13,6 +13,7 @@ let mapAttrs mkDefault mkIf + mkMerge mkOption mkForce optional @@ -77,6 +78,14 @@ in { options = { + sshBackdoor = { + enable = mkOption { + default = false; + type = types.bool; + description = "Whether to turn on the vsock-based SSH backdoor for all VMs."; + }; + }; + node.type = mkOption { type = types.raw; default = baseOS.type; @@ -172,10 +181,15 @@ in passthru.nodes = config.nodesCompat; - defaults = mkIf config.node.pkgsReadOnly { - nixpkgs.pkgs = config.node.pkgs; - imports = [ ../../modules/misc/nixpkgs/read-only.nix ]; - }; + defaults = mkMerge [ + (mkIf config.node.pkgsReadOnly { + nixpkgs.pkgs = config.node.pkgs; + imports = [ ../../modules/misc/nixpkgs/read-only.nix ]; + }) + (mkIf config.sshBackdoor.enable { + testing.sshBackdoor.enable = true; + }) + ]; }; } diff --git a/nixos/modules/testing/test-instrumentation.nix b/nixos/modules/testing/test-instrumentation.nix index 49594964ed5f..8ace4ab30abf 100644 --- a/nixos/modules/testing/test-instrumentation.nix +++ b/nixos/modules/testing/test-instrumentation.nix @@ -87,6 +87,10 @@ in machine.switch_root() to leave stage 1 and proceed to stage 2 ''; + sshBackdoor = { + enable = mkEnableOption "vsock-based ssh backdoor for the VM"; + }; + }; config = { @@ -100,6 +104,18 @@ in } ]; + services.openssh = mkIf config.testing.sshBackdoor.enable { + enable = true; + settings = { + PermitRootLogin = "yes"; + PermitEmptyPasswords = "yes"; + }; + }; + + security.pam.services.sshd = mkIf config.testing.sshBackdoor.enable { + allowNullPassword = true; + }; + systemd.services.backdoor = lib.mkMerge [ backdoorService { @@ -175,6 +191,10 @@ in # we avoid defining attributes if not possible. # TODO: refactor such that test-instrumentation can import qemu-vm package = lib.mkDefault pkgs.qemu_test; + + options = mkIf config.testing.sshBackdoor.enable [ + "-device vhost-vsock-pci,guest-cid=${toString (config.virtualisation.test.nodeNumber + 2)}" + ]; }; }; From b1394ba443188c2b5a3b65f0daa83e87dbc7817b Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Sat, 26 Apr 2025 12:20:10 +0200 Subject: [PATCH 02/26] nixos/test-driver: improve wording of the `enable` option of SSH backdoor Co-authored-by: Ryan Lahfa --- nixos/lib/testing/nodes.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nixos/lib/testing/nodes.nix b/nixos/lib/testing/nodes.nix index ee9e7ebeae68..7e01e507d2e8 100644 --- a/nixos/lib/testing/nodes.nix +++ b/nixos/lib/testing/nodes.nix @@ -82,7 +82,7 @@ in enable = mkOption { default = false; type = types.bool; - description = "Whether to turn on the vsock-based SSH backdoor for all VMs."; + description = "Whether to turn on the VSOCK-based access to all VMs. This provides an unauthenticated access intended for debugging."; }; }; From 70b30c5ae8ea09d2cded4d4341b3772f061c642f Mon Sep 17 00:00:00 2001 From: PhiliPdB Date: Mon, 5 May 2025 13:50:45 +0200 Subject: [PATCH 03/26] ark-pixel-font: 2024.05.12 -> 2025.03.14 --- .../ar/ark-pixel-font/limit-builds.patch | 34 ------------------ pkgs/by-name/ar/ark-pixel-font/package.nix | 35 ++++++------------- 2 files changed, 10 insertions(+), 59 deletions(-) delete mode 100644 pkgs/by-name/ar/ark-pixel-font/limit-builds.patch diff --git a/pkgs/by-name/ar/ark-pixel-font/limit-builds.patch b/pkgs/by-name/ar/ark-pixel-font/limit-builds.patch deleted file mode 100644 index c63798e071c9..000000000000 --- a/pkgs/by-name/ar/ark-pixel-font/limit-builds.patch +++ /dev/null @@ -1,34 +0,0 @@ -diff --git a/build.py b/build.py -index 48bc757d..88b9ed9b 100644 ---- a/build.py -+++ b/build.py -@@ -1,6 +1,5 @@ - from scripts import configs - from scripts.configs import path_define --from scripts.services import publish_service, info_service, template_service, image_service - from scripts.services.font_service import DesignContext, FontContext - from scripts.utils import fs_util - -@@ -21,21 +20,6 @@ def main(): - font_context.make_pcf() - font_context.make_otc() - font_context.make_ttc() -- publish_service.make_release_zips(font_config, width_mode) -- info_service.make_info_file(design_context, width_mode) -- info_service.make_alphabet_txt_file(design_context, width_mode) -- template_service.make_alphabet_html_file(design_context, width_mode) -- template_service.make_demo_html_file(design_context) -- image_service.make_preview_image_file(font_config) -- template_service.make_index_html_file() -- template_service.make_playground_html_file() -- image_service.make_readme_banner() -- image_service.make_github_banner() -- image_service.make_itch_io_banner() -- image_service.make_itch_io_background() -- image_service.make_itch_io_cover() -- image_service.make_afdian_cover() -- - - if __name__ == '__main__': - main() - diff --git a/pkgs/by-name/ar/ark-pixel-font/package.nix b/pkgs/by-name/ar/ark-pixel-font/package.nix index 7d0313f9f23e..21e84141216b 100644 --- a/pkgs/by-name/ar/ark-pixel-font/package.nix +++ b/pkgs/by-name/ar/ark-pixel-font/package.nix @@ -3,52 +3,37 @@ python312Packages, fetchFromGitHub, nix-update-script, - fetchPypi, }: -let - pixel-font-builder-compat = python312Packages.pixel-font-builder.overrideAttrs rec { - version = "0.0.26"; - src = fetchPypi { - inherit version; - pname = "pixel_font_builder"; - hash = "sha256-bgs2FbOA5tcUXe5+KuVztWGAv5yFxQNBaiZMeZ+ic+8="; - }; - }; -in python312Packages.buildPythonPackage rec { pname = "ark-pixel-font"; - version = "2024.05.12"; + version = "2025.03.14"; + pyproject = false; src = fetchFromGitHub { owner = "TakWolf"; repo = "ark-pixel-font"; tag = version; - hash = "sha256-PGhhKWHDpvOqa3vaI40wuIsAEdWGb62cN7QJeHQqiss="; + hash = "sha256-B/XsZEpSxY4k8uj3Vy31c9+GcO7d3NFcADLtPU6p/CI="; }; - format = "other"; - - nativeBuildInputs = with python312Packages; [ - pixel-font-builder-compat + dependencies = with python312Packages; [ + pixel-font-builder + pixel-font-knife unidata-blocks character-encoding-utils - pypng + pyyaml pillow beautifulsoup4 jinja2 - gitpython + loguru + cyclopts ]; - # By default build.py builds a LOT of extraneous artifacts we don't need. - patches = [ ./limit-builds.patch ]; - buildPhase = '' runHook preBuild - # Too much debug output would break Hydra, so this jankness has to be here for it to build at all. - # I wish there's a builtin way to set the log level without modifying the script itself... - python3 build.py 2>&1 >/dev/null | grep -E '^(INFO|WARN|ERROR)' + python -m tools.cli --cleanup runHook postBuild ''; From a4ac5e846c84507d5ce2f9397aa0a6a98f7399a0 Mon Sep 17 00:00:00 2001 From: Martin Weinelt Date: Tue, 6 May 2025 01:18:20 +0200 Subject: [PATCH 04/26] borgbackup: reenable fixed test Reported upstream in 2023 and couldn't reproduce it anymore on 1.4.1. --- pkgs/by-name/bo/borgbackup/package.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/by-name/bo/borgbackup/package.nix b/pkgs/by-name/bo/borgbackup/package.nix index 0a9823869efa..afcc6d71902d 100644 --- a/pkgs/by-name/bo/borgbackup/package.nix +++ b/pkgs/by-name/bo/borgbackup/package.nix @@ -121,8 +121,6 @@ python.pkgs.buildPythonApplication rec { "test_get_keys_dir" "test_get_security_dir" "test_get_config_dir" - # https://github.com/borgbackup/borg/issues/6573 - "test_basic_functionality" ]; preCheck = '' From aa8a730c13cbc55d3455deaaf19d95e1e41be843 Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Wed, 7 May 2025 02:24:53 +0000 Subject: [PATCH 05/26] wit-bindgen: 0.41.0 -> 0.42.1 --- pkgs/by-name/wi/wit-bindgen/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/wi/wit-bindgen/package.nix b/pkgs/by-name/wi/wit-bindgen/package.nix index 43f88744ce42..08c6e77e3327 100644 --- a/pkgs/by-name/wi/wit-bindgen/package.nix +++ b/pkgs/by-name/wi/wit-bindgen/package.nix @@ -6,17 +6,17 @@ rustPlatform.buildRustPackage rec { pname = "wit-bindgen"; - version = "0.41.0"; + version = "0.42.1"; src = fetchFromGitHub { owner = "bytecodealliance"; repo = "wit-bindgen"; rev = "v${version}"; - hash = "sha256-ePrtWOCta9UtoEtSJ1NZb6iJricfsc2YtRF8hi///3c="; + hash = "sha256-zj+O8Rp/KXvDYCew0k5veBUokR91CGEIan398/mPY8w="; }; useFetchCargoVendor = true; - cargoHash = "sha256-vhhonclq6UGkygHoNIRkB4BIjMAdkSbu2qPXNb2y8pI="; + cargoHash = "sha256-epvE6qSKVUudqHXPJG5mP2X7xlR5XSm3UWDzZK0gHyA="; # Some tests fail because they need network access to install the `wasm32-unknown-unknown` target. # However, GitHub Actions ensures a proper build. From eb57b3e16e3114ca4b9b3b0ec9ceadcb6dccea68 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Wed, 7 May 2025 07:33:24 +0200 Subject: [PATCH 06/26] matrix-synapse: 1.128.0 -> 1.129.0 ChangeLog: https://github.com/element-hq/synapse/releases/tag/v1.129.0 --- pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix b/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix index d306a0c87be9..a2c01eb52dc1 100644 --- a/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix +++ b/pkgs/by-name/ma/matrix-synapse-unwrapped/package.nix @@ -18,14 +18,14 @@ let in python3.pkgs.buildPythonApplication rec { pname = "matrix-synapse"; - version = "1.128.0"; + version = "1.129.0"; format = "pyproject"; src = fetchFromGitHub { owner = "element-hq"; repo = "synapse"; rev = "v${version}"; - hash = "sha256-QgVx/9mZ3Do+42YwO8OtI2dcuckMX/xIaiBUi4HrK4Q="; + hash = "sha256-JDaTFbRb2eNtzxZBLn8wOBEN5uJcInNrhFnGFZjI8is="; }; cargoDeps = rustPlatform.fetchCargoVendor { From 40d5f4e0a0d9f45abaab7324963c69960c5c2327 Mon Sep 17 00:00:00 2001 From: Winter Date: Thu, 8 May 2025 03:23:13 -0400 Subject: [PATCH 07/26] fetchurl: don't prefer hashed mirrors by default Right now, when building any FOD that uses `fetchurl` (which is the majority of ours), `tarballs.nixos.org` will always be contacted before the actual URL. Given that `tarballs.nixos.org` mainly hosts the bootstrap tools, which already explicitly set it as the host to pull from, it doesn't make much sense to force every other `fetchurl` invocation to first reach out to `tarballs.nixos.org`. --- pkgs/build-support/fetchurl/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/build-support/fetchurl/default.nix b/pkgs/build-support/fetchurl/default.nix index 9575d98960fe..c0e53ba637a7 100644 --- a/pkgs/build-support/fetchurl/default.nix +++ b/pkgs/build-support/fetchurl/default.nix @@ -222,7 +222,7 @@ stdenvNoCC.mkDerivation ( # If set, prefer the content-addressable mirrors # (http://tarballs.nixos.org) over the original URLs. - preferHashedMirrors = true; + preferHashedMirrors = false; # New-style output content requirements. inherit (hash_) outputHashAlgo outputHash; From 8869265f93c6f8710a59807e88192b9ad2ebd905 Mon Sep 17 00:00:00 2001 From: Maximilian Bosch Date: Thu, 8 May 2025 10:50:35 +0200 Subject: [PATCH 08/26] nixos/test-driver: printout instructions on how to connect via AF_VSOCK --- nixos/lib/test-driver/src/test_driver/__init__.py | 7 +++++++ nixos/lib/test-driver/src/test_driver/driver.py | 15 +++++++++++++++ nixos/lib/testing-python.nix | 1 + nixos/lib/testing/nodes.nix | 4 ++++ 4 files changed, 27 insertions(+) diff --git a/nixos/lib/test-driver/src/test_driver/__init__.py b/nixos/lib/test-driver/src/test_driver/__init__.py index 26d8391017e8..ff6922e5b90e 100755 --- a/nixos/lib/test-driver/src/test_driver/__init__.py +++ b/nixos/lib/test-driver/src/test_driver/__init__.py @@ -109,6 +109,11 @@ def main() -> None: help="the test script to run", type=Path, ) + arg_parser.add_argument( + "--dump-vsocks", + help="indicates that the interactive SSH backdoor is active and dumps information about it on start", + action="store_true", + ) args = arg_parser.parse_args() @@ -136,6 +141,8 @@ def main() -> None: if args.interactive: history_dir = os.getcwd() history_path = os.path.join(history_dir, ".nixos-test-history") + if args.dump_vsocks: + driver.dump_machine_ssh() ptpython.ipython.embed( user_ns=driver.test_symbols(), history_filename=history_path, diff --git a/nixos/lib/test-driver/src/test_driver/driver.py b/nixos/lib/test-driver/src/test_driver/driver.py index 49b6692bf422..e65c6c5ba511 100644 --- a/nixos/lib/test-driver/src/test_driver/driver.py +++ b/nixos/lib/test-driver/src/test_driver/driver.py @@ -11,6 +11,8 @@ from pathlib import Path from typing import Any from unittest import TestCase +from colorama import Style + from test_driver.errors import MachineError, RequestedAssertionFailed from test_driver.logger import AbstractLogger from test_driver.machine import Machine, NixStartScript, retry @@ -176,6 +178,19 @@ class Driver: ) return {**general_symbols, **machine_symbols, **vlan_symbols} + def dump_machine_ssh(self) -> None: + print("SSH backdoor enabled, the machines can be accessed like this:") + print( + f"{Style.BRIGHT}Note:{Style.RESET_ALL} this requires {Style.BRIGHT}systemd-ssh-proxy(1){Style.RESET_ALL} to be enabled (default on NixOS 25.05 and newer)." + ) + names = [machine.name for machine in self.machines] + longest_name = len(max(names, key=len)) + for num, name in enumerate(names, start=3): + spaces = " " * (longest_name - len(name) + 2) + print( + f" {name}:{spaces}{Style.BRIGHT}ssh -o User=root vsock/{num}{Style.RESET_ALL}" + ) + def test_script(self) -> None: """Run the test script""" with self.logger.nested("run the VM test script"): diff --git a/nixos/lib/testing-python.nix b/nixos/lib/testing-python.nix index d01c1d9b5e09..878f9669321a 100644 --- a/nixos/lib/testing-python.nix +++ b/nixos/lib/testing-python.nix @@ -75,6 +75,7 @@ pkgs.lib.throwIf (args ? specialArgs) ), extraPythonPackages ? (_: [ ]), interactive ? { }, + sshBackdoor ? { }, }@t: let testConfig = diff --git a/nixos/lib/testing/nodes.nix b/nixos/lib/testing/nodes.nix index 7e01e507d2e8..38b32dbb6701 100644 --- a/nixos/lib/testing/nodes.nix +++ b/nixos/lib/testing/nodes.nix @@ -181,6 +181,10 @@ in passthru.nodes = config.nodesCompat; + extraDriverArgs = mkIf config.sshBackdoor.enable [ + "--dump-vsocks" + ]; + defaults = mkMerge [ (mkIf config.node.pkgsReadOnly { nixpkgs.pkgs = config.node.pkgs; From cd0cadde9a90e9a34150d8a463bdd2a261612d8f Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Thu, 8 May 2025 18:52:24 +0000 Subject: [PATCH 09/26] tile38: 1.34.3 -> 1.34.4 --- pkgs/by-name/ti/tile38/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/ti/tile38/package.nix b/pkgs/by-name/ti/tile38/package.nix index 12900cddce51..dabf52b762f4 100644 --- a/pkgs/by-name/ti/tile38/package.nix +++ b/pkgs/by-name/ti/tile38/package.nix @@ -6,16 +6,16 @@ buildGoModule rec { pname = "tile38"; - version = "1.34.3"; + version = "1.34.4"; src = fetchFromGitHub { owner = "tidwall"; repo = "tile38"; tag = version; - hash = "sha256-0kBSMoHo6RD6NIP4fGXe3K5B+FLEN5BuphViwa6KLSg="; + hash = "sha256-TLVFFgT5lxOLhv1RBS09DCcZAozkcHzIBlJSWt1ztB4="; }; - vendorHash = "sha256-SJ80FSoG8RhsReDmSX120bxzcgZ3cD3vNvWt/HiV3/w="; + vendorHash = "sha256-geXYLeJf/u+8RD7Slr2x+J6zABkWSIfhxKLxZVF/icU="; subPackages = [ "cmd/tile38-cli" From ab39a0fffaaafd6d1a3bea09e526b086134b5bcf Mon Sep 17 00:00:00 2001 From: Connor Baker Date: Wed, 7 May 2025 16:13:32 +0000 Subject: [PATCH 10/26] cudaPackages: name and consolidate use of fixups pattern Signed-off-by: Connor Baker --- pkgs/development/cuda-modules/README.md | 6 + .../cuda-library-samples/generic.nix | 146 +++--- .../cuda-modules/cuda/extension.nix | 39 +- .../cuda-modules/cuda/overrides.nix | 490 ------------------ pkgs/development/cuda-modules/cudnn/fixup.nix | 75 --- pkgs/development/cuda-modules/cudnn/shims.nix | 3 +- .../cuda-modules/cusparselt/extension.nix | 34 +- .../cuda-modules/cutensor/extension.nix | 24 +- .../cuda-modules/fixups/cuda_compat.nix | 12 + .../cuda-modules/fixups/cuda_cudart.nix | 38 ++ .../cuda-modules/fixups/cuda_demo_suite.nix | 18 + .../cuda-modules/fixups/cuda_gdb.nix | 38 ++ .../cuda-modules/fixups/cuda_nvcc.nix | 72 +++ .../cuda-modules/fixups/cuda_nvprof.nix | 1 + .../fixups/cuda_sanitizer_api.nix | 1 + .../development/cuda-modules/fixups/cudnn.nix | 84 +++ .../cuda-modules/fixups/default.nix | 12 + .../cuda-modules/fixups/fabricmanager.nix | 1 + pkgs/development/cuda-modules/fixups/imex.nix | 1 + .../cuda-modules/fixups/libcufile.nix | 18 + .../cuda-modules/fixups/libcusolver.nix | 24 + .../cuda-modules/fixups/libcusparse.nix | 16 + .../cuda-modules/fixups/libcusparse_lt.nix | 37 ++ .../cuda-modules/fixups/libcutensor.nix | 37 ++ .../cuda-modules/fixups/nsight_compute.nix | 62 +++ .../cuda-modules/fixups/nsight_systems.nix | 128 +++++ .../cuda-modules/fixups/nvidia_driver.nix | 5 + .../fixup.nix => fixups/tensorrt.nix} | 41 +- .../generic-builders/manifest.nix | 37 +- .../generic-builders/multiplex.nix | 42 +- .../cuda-modules/tensorrt/shims.nix | 3 +- pkgs/top-level/cuda-packages.nix | 102 ++-- 32 files changed, 835 insertions(+), 812 deletions(-) delete mode 100644 pkgs/development/cuda-modules/cuda/overrides.nix delete mode 100644 pkgs/development/cuda-modules/cudnn/fixup.nix create mode 100644 pkgs/development/cuda-modules/fixups/cuda_compat.nix create mode 100644 pkgs/development/cuda-modules/fixups/cuda_cudart.nix create mode 100644 pkgs/development/cuda-modules/fixups/cuda_demo_suite.nix create mode 100644 pkgs/development/cuda-modules/fixups/cuda_gdb.nix create mode 100644 pkgs/development/cuda-modules/fixups/cuda_nvcc.nix create mode 100644 pkgs/development/cuda-modules/fixups/cuda_nvprof.nix create mode 100644 pkgs/development/cuda-modules/fixups/cuda_sanitizer_api.nix create mode 100644 pkgs/development/cuda-modules/fixups/cudnn.nix create mode 100644 pkgs/development/cuda-modules/fixups/default.nix create mode 100644 pkgs/development/cuda-modules/fixups/fabricmanager.nix create mode 100644 pkgs/development/cuda-modules/fixups/imex.nix create mode 100644 pkgs/development/cuda-modules/fixups/libcufile.nix create mode 100644 pkgs/development/cuda-modules/fixups/libcusolver.nix create mode 100644 pkgs/development/cuda-modules/fixups/libcusparse.nix create mode 100644 pkgs/development/cuda-modules/fixups/libcusparse_lt.nix create mode 100644 pkgs/development/cuda-modules/fixups/libcutensor.nix create mode 100644 pkgs/development/cuda-modules/fixups/nsight_compute.nix create mode 100644 pkgs/development/cuda-modules/fixups/nsight_systems.nix create mode 100644 pkgs/development/cuda-modules/fixups/nvidia_driver.nix rename pkgs/development/cuda-modules/{tensorrt/fixup.nix => fixups/tensorrt.nix} (71%) diff --git a/pkgs/development/cuda-modules/README.md b/pkgs/development/cuda-modules/README.md index fadf5664de0d..d79f5bede0bb 100644 --- a/pkgs/development/cuda-modules/README.md +++ b/pkgs/development/cuda-modules/README.md @@ -27,6 +27,12 @@ scope. These are typically required for the creation of the finalized to `cudaPackages` scope. - `cudnn`: NVIDIA cuDNN library. - `cutensor`: NVIDIA cuTENSOR library. +- `fixups`: Each file or directory (excluding `default.nix`) should contain a + `callPackage`-able expression to be provided to the `overrideAttrs` attribute + of a package produced by the generic manifest builder. + These fixups are applied by `pname`, so packages with multiple versions + (e.g., `cudnn`, `cudnn_8_9`, etc.) all share a single fixup function + (i.e., `fixups/cudnn.nix`). - `generic-builders`: - Contains a builder `manifest.nix` which operates on the `Manifest` type defined in `modules/generic/manifests`. Most packages are built using this diff --git a/pkgs/development/cuda-modules/cuda-library-samples/generic.nix b/pkgs/development/cuda-modules/cuda-library-samples/generic.nix index 09440871a69f..dfd48ce7c5ed 100644 --- a/pkgs/development/cuda-modules/cuda-library-samples/generic.nix +++ b/pkgs/development/cuda-modules/cuda-library-samples/generic.nix @@ -1,36 +1,33 @@ { - lib, - backendStdenv, - fetchFromGitHub, - cmake, addDriverRunpath, autoAddDriverRunpath, - cudatoolkit, - cutensor, - cusparselt, - cudaPackages, - setupCudaHook, autoPatchelfHook, + backendStdenv, + cmake, + cuda_cccl ? null, + cuda_cudart ? null, + cuda_nvcc ? null, + cudaAtLeast, + cudaOlder, + cudatoolkit, + cusparselt ? null, + cutensor ? null, + fetchFromGitHub, + lib, + libcusparse ? null, + setupCudaHook, }: let - inherit (cudaPackages) - cuda_cccl - cuda_cudart - cuda_nvcc - libcusparse - cudaAtLeast - cudaOlder - ; - rev = "e57b9c483c5384b7b97b7d129457e5a9bdcdb5e1"; - src = fetchFromGitHub { - owner = "NVIDIA"; - repo = "CUDALibrarySamples"; - inherit rev; - sha256 = "0g17afsmb8am0darxchqgjz1lmkaihmnn7k1x4ahg5gllcmw8k3l"; - }; - commonAttrs = { - version = lib.strings.substring 0 7 rev + "-" + lib.versions.majorMinor cudatoolkit.version; + base = backendStdenv.mkDerivation (finalAttrs: { + src = fetchFromGitHub { + owner = "NVIDIA"; + repo = "CUDALibrarySamples"; + rev = "e57b9c483c5384b7b97b7d129457e5a9bdcdb5e1"; + sha256 = "0g17afsmb8am0darxchqgjz1lmkaihmnn7k1x4ahg5gllcmw8k3l"; + }; + version = + lib.strings.substring 0 7 finalAttrs.src.rev + "-" + lib.versions.majorMinor cudatoolkit.version; nativeBuildInputs = [ cmake addDriverRunpath @@ -53,64 +50,63 @@ let maintainers = with lib.maintainers; [ obsidian-systems-maintenance ]; teams = [ lib.teams.cuda ]; }; - }; + }); in { - cublas = backendStdenv.mkDerivation ( - commonAttrs - // { + cublas = base.overrideAttrs ( + finalAttrs: _: { pname = "cuda-library-samples-cublas"; - - src = "${src}/cuBLASLt"; + sourceRoot = "${finalAttrs.src.name}/cuBLASLt"; } ); - cusolver = backendStdenv.mkDerivation ( - commonAttrs - // { + cusolver = base.overrideAttrs ( + finalAttrs: _: { pname = "cuda-library-samples-cusolver"; - - src = "${src}/cuSOLVER"; - - sourceRoot = "cuSOLVER/gesv"; + sourceRoot = "${finalAttrs.src.name}/cuSOLVER/gesv"; } ); - cutensor = backendStdenv.mkDerivation ( - commonAttrs - // { + cutensor = base.overrideAttrs ( + finalAttrs: prevAttrs: { pname = "cuda-library-samples-cutensor"; - src = "${src}/cuTENSOR"; + sourceRoot = "${finalAttrs.src.name}/cuTENSOR"; - buildInputs = [ cutensor ]; + buildInputs = prevAttrs.buildInputs or [ ] ++ [ cutensor ]; - cmakeFlags = [ "-DCUTENSOR_EXAMPLE_BINARY_INSTALL_DIR=${builtins.placeholder "out"}/bin" ]; + cmakeFlags = prevAttrs.cmakeFlags or [ ] ++ [ + "-DCUTENSOR_EXAMPLE_BINARY_INSTALL_DIR=${builtins.placeholder "out"}/bin" + ]; # CUTENSOR_ROOT is double escaped - postPatch = '' - substituteInPlace CMakeLists.txt \ - --replace-fail "\''${CUTENSOR_ROOT}/include" "${cutensor.dev}/include" - ''; + postPatch = + prevAttrs.postPatch or "" + + '' + substituteInPlace CMakeLists.txt \ + --replace-fail "\''${CUTENSOR_ROOT}/include" "${lib.getDev cutensor}/include" + ''; CUTENSOR_ROOT = cutensor; + + meta = prevAttrs.meta or { } // { + broken = cutensor == null; + }; } ); - cusparselt = backendStdenv.mkDerivation ( - commonAttrs - // { + cusparselt = base.overrideAttrs ( + finalAttrs: prevAttrs: { pname = "cuda-library-samples-cusparselt"; - src = "${src}/cuSPARSELt"; + sourceRoot = "${finalAttrs.src.name}/cuSPARSELt/matmul"; - sourceRoot = "cuSPARSELt/matmul"; - - buildInputs = lib.optionals (cudaOlder "11.4") [ cudatoolkit ]; + buildInputs = prevAttrs.buildInputs or [ ] ++ lib.optionals (cudaOlder "11.4") [ cudatoolkit ]; nativeBuildInputs = - [ + prevAttrs.nativeBuildInputs or [ ] + ++ [ cmake addDriverRunpath (lib.getDev cusparselt) @@ -125,22 +121,34 @@ in cuda_cccl # ]; - postPatch = '' - substituteInPlace CMakeLists.txt \ - --replace-fail "''${CUSPARSELT_ROOT}/lib64/libcusparseLt.so" "${lib.getLib cusparselt}/lib/libcusparseLt.so" \ - --replace-fail "''${CUSPARSELT_ROOT}/lib64/libcusparseLt_static.a" "${lib.getStatic cusparselt}/lib/libcusparseLt_static.a" - ''; + postPatch = + prevAttrs.postPatch or "" + + '' + substituteInPlace CMakeLists.txt \ + --replace-fail "''${CUSPARSELT_ROOT}/lib64/libcusparseLt.so" "${lib.getLib cusparselt}/lib/libcusparseLt.so" \ + --replace-fail "''${CUSPARSELT_ROOT}/lib64/libcusparseLt_static.a" "${lib.getStatic cusparselt}/lib/libcusparseLt_static.a" + ''; - installPhase = '' - runHook preInstall - mkdir -p $out/bin - cp matmul_example $out/bin/ - cp matmul_example_static $out/bin/ - runHook postInstall - ''; + postInstall = + prevAttrs.postInstall or "" + + '' + mkdir -p $out/bin + cp matmul_example $out/bin/ + cp matmul_example_static $out/bin/ + ''; CUDA_TOOLKIT_PATH = lib.getLib cudatoolkit; CUSPARSELT_PATH = lib.getLib cusparselt; + + meta = prevAttrs.meta or { } // { + broken = + # Base dependencies + (cusparselt == null || libcusparse == null) + # CUDA 11.4+ dependencies + || (cudaAtLeast "11.4" && (cuda_nvcc == null || cuda_cudart == null)) + # CUDA 12.0+ dependencies + || (cudaAtLeast "12.0" && cuda_cccl == null); + }; } ); } diff --git a/pkgs/development/cuda-modules/cuda/extension.nix b/pkgs/development/cuda-modules/cuda/extension.nix index 5b9e808074ae..4c7298bab354 100644 --- a/pkgs/development/cuda-modules/cuda/extension.nix +++ b/pkgs/development/cuda-modules/cuda/extension.nix @@ -53,42 +53,13 @@ let # buildRedistPackage : callPackage -> PackageName -> Derivation buildRedistPackage = callPackage: pname: - let + callPackage ../generic-builders/manifest.nix { + inherit pname redistName; + # We pass the whole release to the builder because it has logic to handle + # the case we're trying to build on an unsupported platform. redistribRelease = redistribManifest.${pname}; featureRelease = featureManifest.${pname}; - drv = - let - # get `autoAddDriverRunpath` from pkgs instead of cudaPackages' alias to avoid warning - inherit (callPackage ({ pkgs }: pkgs) { }) autoAddDriverRunpath; - in - (callPackage ../generic-builders/manifest.nix { - # We pass the whole release to the builder because it has logic to handle - # the case we're trying to build on an unsupported platform. - inherit - pname - redistName - redistribRelease - featureRelease - autoAddDriverRunpath - ; - }).overrideAttrs - (prevAttrs: { - # Add the package-specific license. - meta = prevAttrs.meta // { - license = - let - licensePath = - if redistribRelease.license_path != null then - redistribRelease.license_path - else - "${pname}/LICENSE.txt"; - url = "https://developer.download.nvidia.com/compute/cuda/redist/${licensePath}"; - in - lib.licenses.nvidiaCudaRedist // { inherit url; }; - }; - }); - in - drv; + }; # Build all the redist packages given final and prev. redistPackages = diff --git a/pkgs/development/cuda-modules/cuda/overrides.nix b/pkgs/development/cuda-modules/cuda/overrides.nix deleted file mode 100644 index 46f5d506e6f2..000000000000 --- a/pkgs/development/cuda-modules/cuda/overrides.nix +++ /dev/null @@ -1,490 +0,0 @@ -let - filterAndCreateOverrides = - createOverrideAttrs: final: prev: - let - # It is imperative that we use `final.callPackage` to perform overrides, - # so the final package set is available to the override functions. - inherit (final) callPackage; - - # NOTE(@connorbaker): We MUST use `lib` from `prev` because the attribute - # names CAN NOT depend on `final`. - inherit (prev.lib.attrsets) filterAttrs mapAttrs; - inherit (prev.lib.trivial) pipe; - - # NOTE: Filter out attributes that are not present in the previous version of - # the package set. This is necessary to prevent the appearance of attributes - # like `cuda_nvcc` in `cudaPackages_10_0, which predates redistributables. - filterOutNewAttrs = filterAttrs (name: _: prev ? ${name}); - - # Apply callPackage to each attribute value, yielding a value to be passed - # to overrideAttrs. - callPackageThenOverrideAttrs = mapAttrs ( - name: value: prev.${name}.overrideAttrs (callPackage value { }) - ); - in - pipe createOverrideAttrs [ - filterOutNewAttrs - callPackageThenOverrideAttrs - ]; -in -# Each attribute name is the name of an existing package in the previous version -# of the package set. -# The value is a function (to be provided to callPackage), which yields a value -# to be provided to overrideAttrs. This allows us to override the attributes of -# a package without losing access to the fixed point of the package set -- -# especially useful given that some packages may depend on each other! -filterAndCreateOverrides { - libcufile = - { - cudaOlder, - lib, - libcublas, - numactl, - rdma-core, - }: - prevAttrs: { - buildInputs = prevAttrs.buildInputs ++ [ - libcublas - numactl - rdma-core - ]; - # Before 11.7 libcufile depends on itself for some reason. - autoPatchelfIgnoreMissingDeps = - prevAttrs.autoPatchelfIgnoreMissingDeps - ++ lib.lists.optionals (cudaOlder "11.7") [ "libcufile.so.0" ]; - }; - - libcusolver = - { - cudaAtLeast, - lib, - libcublas, - libcusparse ? null, - libnvjitlink ? null, - }: - prevAttrs: { - buildInputs = - prevAttrs.buildInputs - # Always depends on this - ++ [ libcublas ] - # Dependency from 12.0 and on - ++ lib.lists.optionals (cudaAtLeast "12.0") [ libnvjitlink ] - # Dependency from 12.1 and on - ++ lib.lists.optionals (cudaAtLeast "12.1") [ libcusparse ]; - - brokenConditions = prevAttrs.brokenConditions // { - "libnvjitlink missing (CUDA >= 12.0)" = - !(cudaAtLeast "12.0" -> (libnvjitlink != null && libnvjitlink != null)); - "libcusparse missing (CUDA >= 12.1)" = - !(cudaAtLeast "12.1" -> (libcusparse != null && libcusparse != null)); - }; - }; - - libcusparse = - { - cudaAtLeast, - lib, - libnvjitlink ? null, - }: - prevAttrs: { - buildInputs = - prevAttrs.buildInputs - # Dependency from 12.0 and on - ++ lib.lists.optionals (cudaAtLeast "12.0") [ libnvjitlink ]; - - brokenConditions = prevAttrs.brokenConditions // { - "libnvjitlink missing (CUDA >= 12.0)" = - !(cudaAtLeast "12.0" -> (libnvjitlink != null && libnvjitlink != null)); - }; - }; - - # TODO(@connorbaker): cuda_cudart.dev depends on crt/host_config.h, which is from - # (getDev cuda_nvcc). It would be nice to be able to encode that. - cuda_cudart = - { addDriverRunpath, lib }: - prevAttrs: { - # Remove once cuda-find-redist-features has a special case for libcuda - outputs = - prevAttrs.outputs - ++ lib.lists.optionals (!(builtins.elem "stubs" prevAttrs.outputs)) [ "stubs" ]; - - allowFHSReferences = false; - - # The libcuda stub's pkg-config doesn't follow the general pattern: - postPatch = - prevAttrs.postPatch or "" - + '' - while IFS= read -r -d $'\0' path; do - sed -i \ - -e "s|^libdir\s*=.*/lib\$|libdir=''${!outputLib}/lib/stubs|" \ - -e "s|^Libs\s*:\(.*\)\$|Libs: \1 -Wl,-rpath,${addDriverRunpath.driverLink}/lib|" \ - "$path" - done < <(find -iname 'cuda-*.pc' -print0) - '' - # Namelink may not be enough, add a soname. - # Cf. https://gitlab.kitware.com/cmake/cmake/-/issues/25536 - + '' - if [[ -f lib/stubs/libcuda.so && ! -f lib/stubs/libcuda.so.1 ]]; then - ln -s libcuda.so lib/stubs/libcuda.so.1 - fi - ''; - - postFixup = - prevAttrs.postFixup or "" - + '' - moveToOutput lib/stubs "$stubs" - ln -s "$stubs"/lib/stubs/* "$stubs"/lib/ - ln -s "$stubs"/lib/stubs "''${!outputLib}/lib/stubs" - ''; - }; - - cuda_compat = - { flags, lib }: - prevAttrs: { - autoPatchelfIgnoreMissingDeps = prevAttrs.autoPatchelfIgnoreMissingDeps ++ [ - "libnvrm_gpu.so" - "libnvrm_mem.so" - "libnvdla_runtime.so" - ]; - # `cuda_compat` only works on aarch64-linux, and only when building for Jetson devices. - badPlatformsConditions = prevAttrs.badPlatformsConditions // { - "Trying to use cuda_compat on aarch64-linux targeting non-Jetson devices" = !flags.isJetsonBuild; - }; - }; - - cuda_gdb = - { - cudaAtLeast, - gmp, - expat, - libxcrypt-legacy, - ncurses6, - python310, - python311, - python312, - stdenv, - lib, - }: - prevAttrs: { - buildInputs = - prevAttrs.buildInputs - # x86_64 only needs gmp from 12.0 and on - ++ lib.lists.optionals (cudaAtLeast "12.0") [ gmp ] - # Additional dependencies for CUDA 12.5 and later, which - # support multiple Python versions. - ++ lib.lists.optionals (cudaAtLeast "12.5") [ - libxcrypt-legacy - ncurses6 - python310 - python311 - python312 - ] - # aarch64,sbsa needs expat - ++ lib.lists.optionals (stdenv.hostPlatform.isAarch64) [ expat ]; - - installPhase = - prevAttrs.installPhase - # Python 3.8 is not in nixpkgs anymore, delete Python 3.8 cuda-gdb support - # to avoid autopatchelf failing to find libpython3.8.so. - + lib.optionalString (cudaAtLeast "12.5") '' - find $bin -name '*python3.8*' -delete - find $bin -name '*python3.9*' -delete - ''; - }; - - cuda_nvcc = - { - lib, - backendStdenv, - cudaOlder, - setupCudaHook, - }: - prevAttrs: { - # Merge "bin" and "dev" into "out" to avoid circular references - outputs = builtins.filter ( - x: - !(builtins.elem x [ - "dev" - "bin" - ]) - ) prevAttrs.outputs; - - # Patch the nvcc.profile. - # Syntax: - # - `=` for assignment, - # - `?=` for conditional assignment, - # - `+=` to "prepend", - # - `=+` to "append". - - # Cf. https://web.archive.org/web/20230308044351/https://arcb.csc.ncsu.edu/~mueller/cluster/nvidia/2.0/nvcc_2.0.pdf - - # We set all variables with the lowest priority (=+), but we do force - # nvcc to use the fixed backend toolchain. Cf. comments in - # backend-stdenv.nix - - postPatch = - let - nvvmReplace = lib.optionalString (cudaOlder "12.5") '' - --replace-fail \ - '$(TOP)/$(_NVVM_BRANCH_)' \ - "''${!outputBin}/nvvm" \ - ''; - in - (prevAttrs.postPatch or "") - + '' - substituteInPlace bin/nvcc.profile \ - --replace-fail \ - '$(TOP)/$(_TARGET_DIR_)/include' \ - "''${!outputDev}/include" \ - ${nvvmReplace} - - cat << EOF >> bin/nvcc.profile - - # Fix a compatible backend compiler - PATH += "${backendStdenv.cc}/bin": - - # Expose the split-out nvvm - LIBRARIES =+ "-L''${!outputBin}/nvvm/lib" - INCLUDES =+ "-I''${!outputBin}/nvvm/include" - EOF - ''; - - # NOTE(@connorbaker): - # Though it might seem odd or counter-intuitive to add the setup hook to `propagatedBuildInputs` instead of - # `propagatedNativeBuildInputs`, it is necessary! If you move the setup hook from `propagatedBuildInputs` to - # `propagatedNativeBuildInputs`, it stops being propagated to downstream packages during their build because - # setup hooks in `propagatedNativeBuildInputs` are not designed to affect the runtime or build environment of - # dependencies; they are only meant to affect the build environment of the package that directly includes them. - propagatedBuildInputs = (prevAttrs.propagatedBuildInputs or [ ]) ++ [ setupCudaHook ]; - - postInstall = - (prevAttrs.postInstall or "") - + '' - moveToOutput "nvvm" "''${!outputBin}" - ''; - - # The nvcc and cicc binaries contain hard-coded references to /usr - allowFHSReferences = true; - - meta = (prevAttrs.meta or { }) // { - mainProgram = "nvcc"; - }; - }; - - cuda_nvprof = { cuda_cupti }: prevAttrs: { buildInputs = prevAttrs.buildInputs ++ [ cuda_cupti ]; }; - - cuda_demo_suite = - { - libglut, - libcufft, - libcurand, - libGLU, - libglvnd, - libgbm, - }: - prevAttrs: { - buildInputs = prevAttrs.buildInputs ++ [ - libglut - libcufft - libcurand - libGLU - libglvnd - libgbm - ]; - }; - - cuda_sanitizer_api = _: _: { outputs = [ "out" ]; }; - - fabricmanager = { zlib }: prevAttrs: { buildInputs = prevAttrs.buildInputs ++ [ zlib ]; }; - - imex = { zlib }: prevAttrs: { buildInputs = prevAttrs.buildInputs ++ [ zlib ]; }; - - nsight_compute = - { - lib, - qt5 ? null, - qt6 ? null, - rdma-core, - stdenv, - }: - prevAttrs: - let - inherit (lib.strings) versionOlder versionAtLeast; - inherit (prevAttrs) version; - qt = if versionOlder version "2022.2.0" then qt5 else qt6; - qtwayland = - if lib.versions.major qt.qtbase.version == "5" then - lib.getBin qt.qtwayland - else - lib.getLib qt.qtwayland; - inherit (qt) wrapQtAppsHook qtwebview; - archDir = - { - aarch64-linux = "linux-desktop-t210-a64"; - x86_64-linux = "linux-desktop-glibc_2_11_3-x64"; - } - .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); - in - { - nativeBuildInputs = prevAttrs.nativeBuildInputs ++ [ wrapQtAppsHook ]; - buildInputs = prevAttrs.buildInputs ++ [ - qtwayland - qtwebview - (qt.qtwebengine or qt.full) - rdma-core - ]; - dontWrapQtApps = true; - preInstall = '' - rm -rf host/${archDir}/Mesa/ - ''; - postInstall = '' - moveToOutput 'ncu' "''${!outputBin}/bin" - moveToOutput 'ncu-ui' "''${!outputBin}/bin" - moveToOutput 'host/${archDir}' "''${!outputBin}/bin" - moveToOutput 'target/${archDir}' "''${!outputBin}/bin" - wrapQtApp "''${!outputBin}/bin/host/${archDir}/ncu-ui.bin" - ''; - preFixup = '' - # lib needs libtiff.so.5, but nixpkgs provides libtiff.so.6 - patchelf --replace-needed libtiff.so.5 libtiff.so "''${!outputBin}/bin/host/${archDir}/Plugins/imageformats/libqtiff.so" - ''; - autoPatchelfIgnoreMissingDeps = prevAttrs.autoPatchelfIgnoreMissingDeps ++ [ - "libnvidia-ml.so.1" - ]; - brokenConditions = prevAttrs.brokenConditions // { - "Qt 5 missing (<2022.2.0)" = !(versionOlder version "2022.2.0" -> qt5 != null); - "Qt 6 missing (>=2022.2.0)" = !(versionAtLeast version "2022.2.0" -> qt6 != null); - }; - }; - - nsight_systems = - { - boost178, - cuda_cudart, - cudaOlder, - gst_all_1, - lib, - nss, - numactl, - pulseaudio, - qt5 ? null, - qt6 ? null, - rdma-core, - stdenv, - ucx, - wayland, - xorg, - }: - prevAttrs: - let - inherit (lib.strings) versionOlder versionAtLeast; - inherit (prevAttrs) version; - qt = if lib.strings.versionOlder prevAttrs.version "2022.4.2.1" then qt5 else qt6; - qtwayland = - if lib.versions.major qt.qtbase.version == "5" then - lib.getBin qt.qtwayland - else - lib.getLib qt.qtwayland; - qtWaylandPlugins = "${qtwayland}/${qt.qtbase.qtPluginPrefix}"; - hostDir = - { - aarch64-linux = "host-linux-armv8"; - x86_64-linux = "host-linux-x64"; - } - .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); - targetDir = - { - aarch64-linux = "target-linux-sbsa-armv8"; - x86_64-linux = "target-linux-x64"; - } - .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); - versionString = with lib.versions; "${majorMinor version}.${patch version}"; - in - { - # An ad hoc replacement for - # https://github.com/ConnorBaker/cuda-redist-find-features/issues/11 - env.rmPatterns = toString [ - "nsight-systems/${versionString}/${hostDir}/lib{arrow,jpeg}*" - "nsight-systems/${versionString}/${hostDir}/lib{ssl,ssh,crypto}*" - "nsight-systems/${versionString}/${hostDir}/libboost*" - "nsight-systems/${versionString}/${hostDir}/libexec" - "nsight-systems/${versionString}/${hostDir}/libstdc*" - "nsight-systems/${versionString}/${hostDir}/python/bin/python" - "nsight-systems/${versionString}/${hostDir}/Mesa" - ]; - postPatch = - prevAttrs.postPatch or "" - + '' - for path in $rmPatterns; do - rm -r "$path" - done - patchShebangs nsight-systems - ''; - nativeBuildInputs = prevAttrs.nativeBuildInputs ++ [ qt.wrapQtAppsHook ]; - dontWrapQtApps = true; - buildInputs = prevAttrs.buildInputs ++ [ - (qt.qtdeclarative or qt.full) - (qt.qtsvg or qt.full) - (qt.qtimageformats or qt.full) - (qt.qtpositioning or qt.full) - (qt.qtscxml or qt.full) - (qt.qttools or qt.full) - (qt.qtwebengine or qt.full) - (qt.qtwayland or qt.full) - boost178 - cuda_cudart.stubs - gst_all_1.gst-plugins-base - gst_all_1.gstreamer - nss - numactl - pulseaudio - qt.qtbase - qtWaylandPlugins - rdma-core - ucx - wayland - xorg.libXcursor - xorg.libXdamage - xorg.libXrandr - xorg.libXtst - ]; - - postInstall = - # 1. Move dependencies of nsys, nsys-ui binaries to bin output - # 2. Fix paths in wrapper scripts - '' - moveToOutput 'nsight-systems/${versionString}/${hostDir}' "''${!outputBin}" - moveToOutput 'nsight-systems/${versionString}/${targetDir}' "''${!outputBin}" - moveToOutput 'nsight-systems/${versionString}/bin' "''${!outputBin}" - substituteInPlace $bin/bin/nsys $bin/bin/nsys-ui \ - --replace-fail 'nsight-systems-#VERSION_RSPLIT#' nsight-systems/${versionString} - wrapQtApp "$bin/nsight-systems/${versionString}/${hostDir}/nsys-ui.bin" - ''; - - preFixup = '' - # lib needs libtiff.so.5, but nixpkgs provides libtiff.so.6 - patchelf --replace-needed libtiff.so.5 libtiff.so $bin/nsight-systems/${versionString}/${hostDir}/Plugins/imageformats/libqtiff.so - ''; - - autoPatchelfIgnoreMissingDeps = prevAttrs.autoPatchelfIgnoreMissingDeps ++ [ - "libnvidia-ml.so.1" - ]; - - brokenConditions = prevAttrs.brokenConditions // { - "Qt 5 missing (<2022.4.2.1)" = !(versionOlder version "2022.4.2.1" -> qt5 != null); - "Qt 6 missing (>=2022.4.2.1)" = !(versionAtLeast version "2022.4.2.1" -> qt6 != null); - }; - badPlatformsConditions = prevAttrs.badPlatformsConditions // { - # Older releases require boost 1.70, which is deprecated in Nixpkgs - "CUDA too old (<11.8)" = cudaOlder "11.8"; - }; - }; - - nvidia_driver = - { }: - prevAttrs: { - badPlatformsConditions = prevAttrs.badPlatformsConditions // { - "Package is not supported; use drivers from linuxPackages" = true; - }; - }; -} diff --git a/pkgs/development/cuda-modules/cudnn/fixup.nix b/pkgs/development/cuda-modules/cudnn/fixup.nix deleted file mode 100644 index 65a6d81af663..000000000000 --- a/pkgs/development/cuda-modules/cudnn/fixup.nix +++ /dev/null @@ -1,75 +0,0 @@ -{ - cudaVersion, - fetchurl, - final, - lib, - package, - patchelf, - zlib, - ... -}: -let - inherit (lib) - lists - maintainers - meta - strings - ; -in -finalAttrs: prevAttrs: { - src = fetchurl { inherit (package) url hash; }; - - # Useful for inspecting why something went wrong. - badPlatformsConditions = - let - cudaTooOld = strings.versionOlder cudaVersion package.minCudaVersion; - cudaTooNew = - (package.maxCudaVersion != null) && strings.versionOlder package.maxCudaVersion cudaVersion; - in - prevAttrs.badPlatformsConditions - // { - "CUDA version is too old" = cudaTooOld; - "CUDA version is too new" = cudaTooNew; - }; - - buildInputs = - prevAttrs.buildInputs - ++ [ zlib ] - ++ lists.optionals finalAttrs.passthru.useCudatoolkitRunfile [ final.cudatoolkit ] - ++ lists.optionals (!finalAttrs.passthru.useCudatoolkitRunfile) [ final.libcublas.lib ]; - - # Tell autoPatchelf about runtime dependencies. *_infer* libraries only - # exist in CuDNN 8. - # NOTE: Versions from CUDNN releases have four components. - postFixup = - strings.optionalString - ( - strings.versionAtLeast finalAttrs.version "8.0.5.0" - && strings.versionOlder finalAttrs.version "9.0.0.0" - ) - '' - ${meta.getExe patchelf} $lib/lib/libcudnn.so --add-needed libcudnn_cnn_infer.so - ${meta.getExe patchelf} $lib/lib/libcudnn_ops_infer.so --add-needed libcublas.so --add-needed libcublasLt.so - ''; - - passthru.useCudatoolkitRunfile = strings.versionOlder cudaVersion "11.3.999"; - - meta = prevAttrs.meta // { - homepage = "https://developer.nvidia.com/cudnn"; - maintainers = - prevAttrs.meta.maintainers or [ ] - ++ (with maintainers; [ - mdaiter - samuela - connorbaker - ]); - teams = prevAttrs.meta.teams or [ ]; - license = { - shortName = "cuDNN EULA"; - fullName = "NVIDIA cuDNN Software License Agreement (EULA)"; - url = "https://docs.nvidia.com/deeplearning/sdk/cudnn-sla/index.html#supplement"; - free = false; - redistributable = !finalAttrs.passthru.useCudatoolkitRunfile; - }; - }; -} diff --git a/pkgs/development/cuda-modules/cudnn/shims.nix b/pkgs/development/cuda-modules/cudnn/shims.nix index a36ee26dab5d..9cb879b363bf 100644 --- a/pkgs/development/cuda-modules/cudnn/shims.nix +++ b/pkgs/development/cuda-modules/cudnn/shims.nix @@ -8,6 +8,7 @@ }: { featureRelease = lib.optionalAttrs (redistArch != "unsupported") { + inherit (package) minCudaVersion maxCudaVersion; ${redistArch}.outputs = { lib = true; static = true; @@ -16,6 +17,6 @@ }; redistribRelease = { name = "NVIDIA CUDA Deep Neural Network library (cuDNN)"; - inherit (package) version; + inherit (package) hash url version; }; } diff --git a/pkgs/development/cuda-modules/cusparselt/extension.nix b/pkgs/development/cuda-modules/cusparselt/extension.nix index a41001fedde2..07b368c653c7 100644 --- a/pkgs/development/cuda-modules/cusparselt/extension.nix +++ b/pkgs/development/cuda-modules/cusparselt/extension.nix @@ -12,8 +12,6 @@ let attrsets lists modules - versions - strings trivial ; @@ -65,14 +63,6 @@ let # - 11.0 # - 12 - # libPath :: String - libPath = - let - cudaMajorMinor = versions.majorMinor cudaVersion; - cudaMajor = versions.major cudaVersion; - in - if cudaMajorMinor == "10.2" then cudaMajorMinor else cudaMajor; - # A release is supported if it has a libPath that matches our CUDA version for our platform. # LibPath are not constant across the same release -- one platform may support fewer # CUDA versions than another. @@ -109,30 +99,8 @@ let redistribRelease = redistrib.${pname}; featureRelease = feature.${pname}; }; - fixedDrv = drv.overrideAttrs (prevAttrs: { - buildInputs = - prevAttrs.buildInputs - ++ lists.optionals (strings.versionOlder cudaVersion "11.4") [ final.cudatoolkit ] - ++ lists.optionals (strings.versionAtLeast cudaVersion "11.4") ( - [ final.libcublas.lib ] - # For some reason, the 1.4.x release of cusparselt requires the cudart library. - ++ lists.optionals (strings.hasPrefix "1.4" redistrib.${pname}.version) [ final.cuda_cudart.lib ] - ); - meta = prevAttrs.meta // { - description = "cuSPARSELt: A High-Performance CUDA Library for Sparse Matrix-Matrix Multiplication"; - homepage = "https://developer.nvidia.com/cusparselt-downloads"; - - maintainers = prevAttrs.meta.maintainers or [ ] ++ [ lib.maintainers.sepiabrown ]; - teams = prevAttrs.meta.teams or [ ]; - license = lib.licenses.unfreeRedistributable // { - shortName = "cuSPARSELt EULA"; - fullName = "cuSPARSELt SUPPLEMENT TO SOFTWARE LICENSE AGREEMENT FOR NVIDIA SOFTWARE DEVELOPMENT KITS"; - url = "https://docs.nvidia.com/cuda/cusparselt/license.html"; - }; - }; - }); in - attrsets.nameValuePair (computeName redistrib.${pname}) fixedDrv; + attrsets.nameValuePair (computeName redistrib.${pname}) drv; extension = let diff --git a/pkgs/development/cuda-modules/cutensor/extension.nix b/pkgs/development/cuda-modules/cutensor/extension.nix index 0571c44f0706..82af5bbe48c3 100644 --- a/pkgs/development/cuda-modules/cutensor/extension.nix +++ b/pkgs/development/cuda-modules/cutensor/extension.nix @@ -25,7 +25,6 @@ let lists modules versions - strings trivial ; @@ -127,29 +126,8 @@ let redistribRelease = redistrib.${pname}; featureRelease = feature.${pname}; }; - fixedDrv = drv.overrideAttrs (prevAttrs: { - buildInputs = - prevAttrs.buildInputs - ++ lists.optionals (strings.versionOlder cudaVersion "11.4") [ final.cudatoolkit ] - ++ lists.optionals (strings.versionAtLeast cudaVersion "11.4") ( - [ final.libcublas.lib ] - # For some reason, the 1.4.x release of cuTENSOR requires the cudart library. - ++ lists.optionals (strings.hasPrefix "1.4" redistrib.${pname}.version) [ final.cuda_cudart.lib ] - ); - meta = prevAttrs.meta // { - description = "cuTENSOR: A High-Performance CUDA Library For Tensor Primitives"; - homepage = "https://developer.nvidia.com/cutensor"; - maintainers = prevAttrs.meta.maintainers or [ ] ++ [ lib.maintainers.obsidian-systems-maintenance ]; - teams = prevAttrs.meta.teams; - license = lib.licenses.unfreeRedistributable // { - shortName = "cuTENSOR EULA"; - fullName = "cuTENSOR SUPPLEMENT TO SOFTWARE LICENSE AGREEMENT FOR NVIDIA SOFTWARE DEVELOPMENT KITS"; - url = "https://docs.nvidia.com/cuda/cutensor/license.html"; - }; - }; - }); in - attrsets.nameValuePair (computeName redistrib.${pname}) fixedDrv; + attrsets.nameValuePair (computeName redistrib.${pname}) drv; extension = let diff --git a/pkgs/development/cuda-modules/fixups/cuda_compat.nix b/pkgs/development/cuda-modules/fixups/cuda_compat.nix new file mode 100644 index 000000000000..1f5736ba059a --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/cuda_compat.nix @@ -0,0 +1,12 @@ +{ flags, lib }: +prevAttrs: { + autoPatchelfIgnoreMissingDeps = prevAttrs.autoPatchelfIgnoreMissingDeps or [ ] ++ [ + "libnvrm_gpu.so" + "libnvrm_mem.so" + "libnvdla_runtime.so" + ]; + # `cuda_compat` only works on aarch64-linux, and only when building for Jetson devices. + badPlatformsConditions = prevAttrs.badPlatformsConditions or { } // { + "Trying to use cuda_compat on aarch64-linux targeting non-Jetson devices" = !flags.isJetsonBuild; + }; +} diff --git a/pkgs/development/cuda-modules/fixups/cuda_cudart.nix b/pkgs/development/cuda-modules/fixups/cuda_cudart.nix new file mode 100644 index 000000000000..67b45ece2026 --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/cuda_cudart.nix @@ -0,0 +1,38 @@ +# TODO(@connorbaker): cuda_cudart.dev depends on crt/host_config.h, which is from +# (getDev cuda_nvcc). It would be nice to be able to encode that. +{ addDriverRunpath, lib }: +prevAttrs: { + # Remove once cuda-find-redist-features has a special case for libcuda + outputs = + prevAttrs.outputs or [ ] + ++ lib.lists.optionals (!(builtins.elem "stubs" prevAttrs.outputs)) [ "stubs" ]; + + allowFHSReferences = false; + + # The libcuda stub's pkg-config doesn't follow the general pattern: + postPatch = + prevAttrs.postPatch or "" + + '' + while IFS= read -r -d $'\0' path; do + sed -i \ + -e "s|^libdir\s*=.*/lib\$|libdir=''${!outputLib}/lib/stubs|" \ + -e "s|^Libs\s*:\(.*\)\$|Libs: \1 -Wl,-rpath,${addDriverRunpath.driverLink}/lib|" \ + "$path" + done < <(find -iname 'cuda-*.pc' -print0) + '' + # Namelink may not be enough, add a soname. + # Cf. https://gitlab.kitware.com/cmake/cmake/-/issues/25536 + + '' + if [[ -f lib/stubs/libcuda.so && ! -f lib/stubs/libcuda.so.1 ]]; then + ln -s libcuda.so lib/stubs/libcuda.so.1 + fi + ''; + + postFixup = + prevAttrs.postFixup or "" + + '' + moveToOutput lib/stubs "$stubs" + ln -s "$stubs"/lib/stubs/* "$stubs"/lib/ + ln -s "$stubs"/lib/stubs "''${!outputLib}/lib/stubs" + ''; +} diff --git a/pkgs/development/cuda-modules/fixups/cuda_demo_suite.nix b/pkgs/development/cuda-modules/fixups/cuda_demo_suite.nix new file mode 100644 index 000000000000..817f9d1a0302 --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/cuda_demo_suite.nix @@ -0,0 +1,18 @@ +{ + libglut, + libcufft, + libcurand, + libGLU, + libglvnd, + libgbm, +}: +prevAttrs: { + buildInputs = prevAttrs.buildInputs or [ ] ++ [ + libglut + libcufft + libcurand + libGLU + libglvnd + libgbm + ]; +} diff --git a/pkgs/development/cuda-modules/fixups/cuda_gdb.nix b/pkgs/development/cuda-modules/fixups/cuda_gdb.nix new file mode 100644 index 000000000000..c76e8e131c9d --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/cuda_gdb.nix @@ -0,0 +1,38 @@ +{ + cudaAtLeast, + gmp, + expat, + libxcrypt-legacy, + ncurses6, + python310, + python311, + python312, + stdenv, + lib, +}: +prevAttrs: { + buildInputs = + prevAttrs.buildInputs or [ ] + # x86_64 only needs gmp from 12.0 and on + ++ lib.lists.optionals (cudaAtLeast "12.0") [ gmp ] + # Additional dependencies for CUDA 12.5 and later, which + # support multiple Python versions. + ++ lib.lists.optionals (cudaAtLeast "12.5") [ + libxcrypt-legacy + ncurses6 + python310 + python311 + python312 + ] + # aarch64,sbsa needs expat + ++ lib.lists.optionals (stdenv.hostPlatform.isAarch64) [ expat ]; + + installPhase = + prevAttrs.installPhase or "" + # Python 3.8 is not in nixpkgs anymore, delete Python 3.8 cuda-gdb support + # to avoid autopatchelf failing to find libpython3.8.so. + + lib.optionalString (cudaAtLeast "12.5") '' + find $bin -name '*python3.8*' -delete + find $bin -name '*python3.9*' -delete + ''; +} diff --git a/pkgs/development/cuda-modules/fixups/cuda_nvcc.nix b/pkgs/development/cuda-modules/fixups/cuda_nvcc.nix new file mode 100644 index 000000000000..3dac231a2900 --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/cuda_nvcc.nix @@ -0,0 +1,72 @@ +{ + lib, + backendStdenv, + cudaOlder, + setupCudaHook, +}: +prevAttrs: { + # Merge "bin" and "dev" into "out" to avoid circular references + outputs = builtins.filter ( + x: + !(builtins.elem x [ + "dev" + "bin" + ]) + ) prevAttrs.outputs or [ ]; + + # Patch the nvcc.profile. + # Syntax: + # - `=` for assignment, + # - `?=` for conditional assignment, + # - `+=` to "prepend", + # - `=+` to "append". + + # Cf. https://web.archive.org/web/20230308044351/https://arcb.csc.ncsu.edu/~mueller/cluster/nvidia/2.0/nvcc_2.0.pdf + + # We set all variables with the lowest priority (=+), but we do force + # nvcc to use the fixed backend toolchain. Cf. comments in + # backend-stdenv.nix + + postPatch = + prevAttrs.postPatch or "" + + '' + substituteInPlace bin/nvcc.profile \ + --replace-fail \ + '$(TOP)/$(_TARGET_DIR_)/include' \ + "''${!outputDev}/include" + '' + # Additional patching required pre-CUDA 12.5. + + lib.optionalString (cudaOlder "12.5") '' + substituteInPlace bin/nvcc.profile \ + --replace-fail \ + '$(TOP)/$(_NVVM_BRANCH_)' \ + "''${!outputBin}/nvvm" \ + '' + + '' + cat << EOF >> bin/nvcc.profile + + # Fix a compatible backend compiler + PATH += "${backendStdenv.cc}/bin": + + # Expose the split-out nvvm + LIBRARIES =+ "-L''${!outputBin}/nvvm/lib" + INCLUDES =+ "-I''${!outputBin}/nvvm/include" + EOF + ''; + + # Entries here will be in nativeBuildInputs when cuda_nvcc is in nativeBuildInputs. + propagatedBuildInputs = prevAttrs.propagatedBuildInputs or [ ] ++ [ setupCudaHook ]; + + postInstall = + prevAttrs.postInstall or "" + + '' + moveToOutput "nvvm" "''${!outputBin}" + ''; + + # The nvcc and cicc binaries contain hard-coded references to /usr + allowFHSReferences = true; + + meta = prevAttrs.meta or { } // { + mainProgram = "nvcc"; + }; +} diff --git a/pkgs/development/cuda-modules/fixups/cuda_nvprof.nix b/pkgs/development/cuda-modules/fixups/cuda_nvprof.nix new file mode 100644 index 000000000000..7452e41bad7b --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/cuda_nvprof.nix @@ -0,0 +1 @@ +{ cuda_cupti }: prevAttrs: { buildInputs = prevAttrs.buildInputs or [ ] ++ [ cuda_cupti ]; } diff --git a/pkgs/development/cuda-modules/fixups/cuda_sanitizer_api.nix b/pkgs/development/cuda-modules/fixups/cuda_sanitizer_api.nix new file mode 100644 index 000000000000..df0019f4d827 --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/cuda_sanitizer_api.nix @@ -0,0 +1 @@ +_: _: { outputs = [ "out" ]; } diff --git a/pkgs/development/cuda-modules/fixups/cudnn.nix b/pkgs/development/cuda-modules/fixups/cudnn.nix new file mode 100644 index 000000000000..f4294789732f --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/cudnn.nix @@ -0,0 +1,84 @@ +{ + cudaOlder, + cudatoolkit, + cudaVersion, + fetchurl, + lib, + libcublas ? null, # cuDNN uses CUDA Toolkit on old releases, where libcublas is not available. + patchelf, + zlib, +}: +let + inherit (lib) + lists + maintainers + meta + strings + ; +in +finalAttrs: prevAttrs: { + src = fetchurl { inherit (finalAttrs.passthru.redistribRelease) hash url; }; + + # Useful for inspecting why something went wrong. + badPlatformsConditions = + let + cudaTooOld = cudaOlder finalAttrs.passthru.featureRelease.minCudaVersion; + cudaTooNew = + (finalAttrs.passthru.featureRelease.maxCudaVersion != null) + && strings.versionOlder finalAttrs.passthru.featureRelease.maxCudaVersion cudaVersion; + in + prevAttrs.badPlatformsConditions or { } + // { + "CUDA version is too old" = cudaTooOld; + "CUDA version is too new" = cudaTooNew; + }; + + buildInputs = + prevAttrs.buildInputs or [ ] + ++ [ zlib ] + ++ lists.optionals finalAttrs.passthru.useCudatoolkitRunfile [ cudatoolkit ] + ++ lists.optionals (!finalAttrs.passthru.useCudatoolkitRunfile) [ (libcublas.lib or null) ]; + + # Tell autoPatchelf about runtime dependencies. *_infer* libraries only + # exist in CuDNN 8. + # NOTE: Versions from CUDNN releases have four components. + postFixup = + prevAttrs.postFixup or "" + + + strings.optionalString + ( + strings.versionAtLeast finalAttrs.version "8.0.5.0" + && strings.versionOlder finalAttrs.version "9.0.0.0" + ) + '' + ${meta.getExe patchelf} $lib/lib/libcudnn.so --add-needed libcudnn_cnn_infer.so + ${meta.getExe patchelf} $lib/lib/libcudnn_ops_infer.so --add-needed libcublas.so --add-needed libcublasLt.so + ''; + + passthru = prevAttrs.passthru or { } // { + useCudatoolkitRunfile = cudaOlder "11.3.999"; + }; + + meta = prevAttrs.meta or { } // { + homepage = "https://developer.nvidia.com/cudnn"; + maintainers = + prevAttrs.meta.maintainers or [ ] + ++ (with maintainers; [ + mdaiter + samuela + connorbaker + ]); + # TODO(@connorbaker): Temporary workaround to avoid changing the derivation hash since introducing more + # brokenConditions would change the derivation as they're top-level and __structuredAttrs is set. + broken = + prevAttrs.meta.broken or false || (finalAttrs.passthru.useCudatoolkitRunfile && libcublas == null); + teams = prevAttrs.meta.teams or [ ]; + license = { + shortName = "cuDNN EULA"; + fullName = "NVIDIA cuDNN Software License Agreement (EULA)"; + url = "https://docs.nvidia.com/deeplearning/sdk/cudnn-sla/index.html#supplement"; + free = false; + redistributable = !finalAttrs.passthru.useCudatoolkitRunfile; + }; + }; +} diff --git a/pkgs/development/cuda-modules/fixups/default.nix b/pkgs/development/cuda-modules/fixups/default.nix new file mode 100644 index 000000000000..9166e413bb71 --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/default.nix @@ -0,0 +1,12 @@ +{ lib }: + +lib.concatMapAttrs ( + fileName: _type: + let + # Fixup is in `./${attrName}.nix` or in `./${fileName}/default.nix`: + attrName = lib.removeSuffix ".nix" fileName; + fixup = import (./. + "/${fileName}"); + isFixup = fileName != "default.nix"; + in + lib.optionalAttrs isFixup { ${attrName} = fixup; } +) (builtins.readDir ./.) diff --git a/pkgs/development/cuda-modules/fixups/fabricmanager.nix b/pkgs/development/cuda-modules/fixups/fabricmanager.nix new file mode 100644 index 000000000000..fa2073ce002a --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/fabricmanager.nix @@ -0,0 +1 @@ +{ zlib }: prevAttrs: { buildInputs = prevAttrs.buildInputs or [ ] ++ [ zlib ]; } diff --git a/pkgs/development/cuda-modules/fixups/imex.nix b/pkgs/development/cuda-modules/fixups/imex.nix new file mode 100644 index 000000000000..fa2073ce002a --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/imex.nix @@ -0,0 +1 @@ +{ zlib }: prevAttrs: { buildInputs = prevAttrs.buildInputs or [ ] ++ [ zlib ]; } diff --git a/pkgs/development/cuda-modules/fixups/libcufile.nix b/pkgs/development/cuda-modules/fixups/libcufile.nix new file mode 100644 index 000000000000..fe6d52c76d57 --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/libcufile.nix @@ -0,0 +1,18 @@ +{ + cudaOlder, + lib, + libcublas, + numactl, + rdma-core, +}: +prevAttrs: { + buildInputs = prevAttrs.buildInputs or [ ] ++ [ + libcublas + numactl + rdma-core + ]; + # Before 11.7 libcufile depends on itself for some reason. + autoPatchelfIgnoreMissingDeps = + prevAttrs.autoPatchelfIgnoreMissingDeps or [ ] + ++ lib.lists.optionals (cudaOlder "11.7") [ "libcufile.so.0" ]; +} diff --git a/pkgs/development/cuda-modules/fixups/libcusolver.nix b/pkgs/development/cuda-modules/fixups/libcusolver.nix new file mode 100644 index 000000000000..90378d67e09f --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/libcusolver.nix @@ -0,0 +1,24 @@ +{ + cudaAtLeast, + lib, + libcublas, + libcusparse ? null, + libnvjitlink ? null, +}: +prevAttrs: { + buildInputs = + prevAttrs.buildInputs or [ ] + # Always depends on this + ++ [ libcublas ] + # Dependency from 12.0 and on + ++ lib.lists.optionals (cudaAtLeast "12.0") [ libnvjitlink ] + # Dependency from 12.1 and on + ++ lib.lists.optionals (cudaAtLeast "12.1") [ libcusparse ]; + + brokenConditions = prevAttrs.brokenConditions or { } // { + "libnvjitlink missing (CUDA >= 12.0)" = + !(cudaAtLeast "12.0" -> (libnvjitlink != null && libnvjitlink != null)); + "libcusparse missing (CUDA >= 12.1)" = + !(cudaAtLeast "12.1" -> (libcusparse != null && libcusparse != null)); + }; +} diff --git a/pkgs/development/cuda-modules/fixups/libcusparse.nix b/pkgs/development/cuda-modules/fixups/libcusparse.nix new file mode 100644 index 000000000000..45893e0ca6de --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/libcusparse.nix @@ -0,0 +1,16 @@ +{ + cudaAtLeast, + lib, + libnvjitlink ? null, +}: +prevAttrs: { + buildInputs = + prevAttrs.buildInputs or [ ] + # Dependency from 12.0 and on + ++ lib.lists.optionals (cudaAtLeast "12.0") [ libnvjitlink ]; + + brokenConditions = prevAttrs.brokenConditions or { } // { + "libnvjitlink missing (CUDA >= 12.0)" = + !(cudaAtLeast "12.0" -> (libnvjitlink != null && libnvjitlink != null)); + }; +} diff --git a/pkgs/development/cuda-modules/fixups/libcusparse_lt.nix b/pkgs/development/cuda-modules/fixups/libcusparse_lt.nix new file mode 100644 index 000000000000..d4e26c533e70 --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/libcusparse_lt.nix @@ -0,0 +1,37 @@ +{ + cuda_cudart ? null, + cudaAtLeast, + cudaOlder, + cudatoolkit, + lib, + libcublas ? null, +}: +finalAttrs: prevAttrs: { + buildInputs = + prevAttrs.buildInputs or [ ] + ++ lib.optionals (cudaOlder "11.4") [ cudatoolkit ] + ++ lib.optionals (cudaAtLeast "11.4") ( + [ (libcublas.lib or null) ] + # For some reason, the 1.4.x release of cusparselt requires the cudart library. + ++ lib.optionals (lib.hasPrefix "1.4" finalAttrs.version) [ (cuda_cudart.lib or null) ] + ); + meta = prevAttrs.meta or { } // { + description = "cuSPARSELt: A High-Performance CUDA Library for Sparse Matrix-Matrix Multiplication"; + homepage = "https://developer.nvidia.com/cusparselt-downloads"; + # TODO(@connorbaker): Temporary workaround to avoid changing the derivation hash since introducing more + # brokenConditions would change the derivation as they're top-level and __structuredAttrs is set. + broken = + prevAttrs.meta.broken or false + || ( + cudaAtLeast "11.4" + && (libcublas == null || (lib.hasPrefix "1.4" finalAttrs.version && cuda_cudart == null)) + ); + maintainers = prevAttrs.meta.maintainers or [ ] ++ [ lib.maintainers.sepiabrown ]; + teams = prevAttrs.meta.teams or [ ]; + license = lib.licenses.unfreeRedistributable // { + shortName = "cuSPARSELt EULA"; + fullName = "cuSPARSELt SUPPLEMENT TO SOFTWARE LICENSE AGREEMENT FOR NVIDIA SOFTWARE DEVELOPMENT KITS"; + url = "https://docs.nvidia.com/cuda/cusparselt/license.html"; + }; + }; +} diff --git a/pkgs/development/cuda-modules/fixups/libcutensor.nix b/pkgs/development/cuda-modules/fixups/libcutensor.nix new file mode 100644 index 000000000000..1e3e503eb926 --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/libcutensor.nix @@ -0,0 +1,37 @@ +{ + cuda_cudart ? null, + cudaAtLeast, + cudaOlder, + cudatoolkit, + lib, + libcublas ? null, +}: +finalAttrs: prevAttrs: { + buildInputs = + prevAttrs.buildInputs or [ ] + ++ lib.optionals (cudaOlder "11.4") [ cudatoolkit ] + ++ lib.optionals (cudaAtLeast "11.4") ( + [ (libcublas.lib or null) ] + # For some reason, the 1.4.x release of cuTENSOR requires the cudart library. + ++ lib.optionals (lib.hasPrefix "1.4" finalAttrs.version) [ (cuda_cudart.lib or null) ] + ); + meta = prevAttrs.meta or { } // { + description = "cuTENSOR: A High-Performance CUDA Library For Tensor Primitives"; + homepage = "https://developer.nvidia.com/cutensor"; + # TODO(@connorbaker): Temporary workaround to avoid changing the derivation hash since introducing more + # brokenConditions would change the derivation as they're top-level and __structuredAttrs is set. + broken = + prevAttrs.meta.broken or false + || ( + cudaAtLeast "11.4" + && (libcublas == null || (lib.hasPrefix "1.4" finalAttrs.version && cuda_cudart == null)) + ); + maintainers = prevAttrs.meta.maintainers or [ ] ++ [ lib.maintainers.obsidian-systems-maintenance ]; + teams = prevAttrs.meta.teams; + license = lib.licenses.unfreeRedistributable // { + shortName = "cuTENSOR EULA"; + fullName = "cuTENSOR SUPPLEMENT TO SOFTWARE LICENSE AGREEMENT FOR NVIDIA SOFTWARE DEVELOPMENT KITS"; + url = "https://docs.nvidia.com/cuda/cutensor/license.html"; + }; + }; +} diff --git a/pkgs/development/cuda-modules/fixups/nsight_compute.nix b/pkgs/development/cuda-modules/fixups/nsight_compute.nix new file mode 100644 index 000000000000..babb54fdd0c7 --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/nsight_compute.nix @@ -0,0 +1,62 @@ +{ + lib, + qt5 ? null, + qt6 ? null, + rdma-core, + stdenv, +}: +prevAttrs: +let + inherit (lib.strings) versionOlder versionAtLeast; + inherit (prevAttrs) version; + qt = if versionOlder version "2022.2.0" then qt5 else qt6; + qtwayland = + if lib.versions.major qt.qtbase.version == "5" then + lib.getBin qt.qtwayland + else + lib.getLib qt.qtwayland; + inherit (qt) wrapQtAppsHook qtwebview; + archDir = + { + aarch64-linux = "linux-desktop-t210-a64"; + x86_64-linux = "linux-desktop-glibc_2_11_3-x64"; + } + .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); +in +{ + nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ wrapQtAppsHook ]; + buildInputs = prevAttrs.buildInputs or [ ] ++ [ + qtwayland + qtwebview + (qt.qtwebengine or qt.full) + rdma-core + ]; + dontWrapQtApps = true; + preInstall = + prevAttrs.preInstall or "" + + '' + rm -rf host/${archDir}/Mesa/ + ''; + postInstall = + prevAttrs.postInstall or "" + + '' + moveToOutput 'ncu' "''${!outputBin}/bin" + moveToOutput 'ncu-ui' "''${!outputBin}/bin" + moveToOutput 'host/${archDir}' "''${!outputBin}/bin" + moveToOutput 'target/${archDir}' "''${!outputBin}/bin" + wrapQtApp "''${!outputBin}/bin/host/${archDir}/ncu-ui.bin" + ''; + preFixup = + prevAttrs.preFixup or "" + + '' + # lib needs libtiff.so.5, but nixpkgs provides libtiff.so.6 + patchelf --replace-needed libtiff.so.5 libtiff.so "''${!outputBin}/bin/host/${archDir}/Plugins/imageformats/libqtiff.so" + ''; + autoPatchelfIgnoreMissingDeps = prevAttrs.autoPatchelfIgnoreMissingDeps or [ ] ++ [ + "libnvidia-ml.so.1" + ]; + brokenConditions = prevAttrs.brokenConditions or { } // { + "Qt 5 missing (<2022.2.0)" = !(versionOlder version "2022.2.0" -> qt5 != null); + "Qt 6 missing (>=2022.2.0)" = !(versionAtLeast version "2022.2.0" -> qt6 != null); + }; +} diff --git a/pkgs/development/cuda-modules/fixups/nsight_systems.nix b/pkgs/development/cuda-modules/fixups/nsight_systems.nix new file mode 100644 index 000000000000..5f2319adfb75 --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/nsight_systems.nix @@ -0,0 +1,128 @@ +{ + boost178, + cuda_cudart, + cudaOlder, + gst_all_1, + lib, + nss, + numactl, + pulseaudio, + qt5 ? null, + qt6 ? null, + rdma-core, + stdenv, + ucx, + wayland, + xorg, +}: +prevAttrs: +let + inherit (lib.strings) versionOlder versionAtLeast; + inherit (prevAttrs) version; + qt = if lib.strings.versionOlder prevAttrs.version "2022.4.2.1" then qt5 else qt6; + qtwayland = + if lib.versions.major qt.qtbase.version == "5" then + lib.getBin qt.qtwayland + else + lib.getLib qt.qtwayland; + qtWaylandPlugins = "${qtwayland}/${qt.qtbase.qtPluginPrefix}"; + hostDir = + { + aarch64-linux = "host-linux-armv8"; + x86_64-linux = "host-linux-x64"; + } + .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + targetDir = + { + aarch64-linux = "target-linux-sbsa-armv8"; + x86_64-linux = "target-linux-x64"; + } + .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}"); + versionString = with lib.versions; "${majorMinor version}.${patch version}"; +in +{ + # An ad hoc replacement for + # https://github.com/ConnorBaker/cuda-redist-find-features/issues/11 + env = prevAttrs.env or { } // { + rmPatterns = + prevAttrs.env.rmPatterns or "" + + toString [ + "nsight-systems/${versionString}/${hostDir}/lib{arrow,jpeg}*" + "nsight-systems/${versionString}/${hostDir}/lib{ssl,ssh,crypto}*" + "nsight-systems/${versionString}/${hostDir}/libboost*" + "nsight-systems/${versionString}/${hostDir}/libexec" + "nsight-systems/${versionString}/${hostDir}/libstdc*" + "nsight-systems/${versionString}/${hostDir}/python/bin/python" + "nsight-systems/${versionString}/${hostDir}/Mesa" + ]; + }; + postPatch = + prevAttrs.postPatch or "" + + '' + for path in $rmPatterns; do + rm -r "$path" + done + patchShebangs nsight-systems + ''; + nativeBuildInputs = prevAttrs.nativeBuildInputs or [ ] ++ [ qt.wrapQtAppsHook ]; + dontWrapQtApps = true; + buildInputs = prevAttrs.buildInputs or [ ] ++ [ + (qt.qtdeclarative or qt.full) + (qt.qtsvg or qt.full) + (qt.qtimageformats or qt.full) + (qt.qtpositioning or qt.full) + (qt.qtscxml or qt.full) + (qt.qttools or qt.full) + (qt.qtwebengine or qt.full) + (qt.qtwayland or qt.full) + boost178 + cuda_cudart.stubs + gst_all_1.gst-plugins-base + gst_all_1.gstreamer + nss + numactl + pulseaudio + qt.qtbase + qtWaylandPlugins + rdma-core + ucx + wayland + xorg.libXcursor + xorg.libXdamage + xorg.libXrandr + xorg.libXtst + ]; + + postInstall = + prevAttrs.postInstall or "" + # 1. Move dependencies of nsys, nsys-ui binaries to bin output + # 2. Fix paths in wrapper scripts + + '' + moveToOutput 'nsight-systems/${versionString}/${hostDir}' "''${!outputBin}" + moveToOutput 'nsight-systems/${versionString}/${targetDir}' "''${!outputBin}" + moveToOutput 'nsight-systems/${versionString}/bin' "''${!outputBin}" + substituteInPlace $bin/bin/nsys $bin/bin/nsys-ui \ + --replace-fail 'nsight-systems-#VERSION_RSPLIT#' nsight-systems/${versionString} + wrapQtApp "$bin/nsight-systems/${versionString}/${hostDir}/nsys-ui.bin" + ''; + + preFixup = + prevAttrs.preFixup or "" + + '' + # lib needs libtiff.so.5, but nixpkgs provides libtiff.so.6 + patchelf --replace-needed libtiff.so.5 libtiff.so $bin/nsight-systems/${versionString}/${hostDir}/Plugins/imageformats/libqtiff.so + ''; + + autoPatchelfIgnoreMissingDeps = prevAttrs.autoPatchelfIgnoreMissingDeps or [ ] ++ [ + "libnvidia-ml.so.1" + ]; + + brokenConditions = prevAttrs.brokenConditions or { } // { + "Qt 5 missing (<2022.4.2.1)" = !(versionOlder version "2022.4.2.1" -> qt5 != null); + "Qt 6 missing (>=2022.4.2.1)" = !(versionAtLeast version "2022.4.2.1" -> qt6 != null); + }; + badPlatformsConditions = prevAttrs.badPlatformsConditions or { } // { + # Older releases require boost 1.70, which is deprecated in Nixpkgs + "CUDA too old (<11.8)" = cudaOlder "11.8"; + }; +} diff --git a/pkgs/development/cuda-modules/fixups/nvidia_driver.nix b/pkgs/development/cuda-modules/fixups/nvidia_driver.nix new file mode 100644 index 000000000000..e9c50b2f4eaf --- /dev/null +++ b/pkgs/development/cuda-modules/fixups/nvidia_driver.nix @@ -0,0 +1,5 @@ +_: prevAttrs: { + badPlatformsConditions = prevAttrs.badPlatformsConditions or { } // { + "Package is not supported; use drivers from linuxPackages" = true; + }; +} diff --git a/pkgs/development/cuda-modules/tensorrt/fixup.nix b/pkgs/development/cuda-modules/fixups/tensorrt.nix similarity index 71% rename from pkgs/development/cuda-modules/tensorrt/fixup.nix rename to pkgs/development/cuda-modules/fixups/tensorrt.nix index 722145a9aac1..02e1ad097075 100644 --- a/pkgs/development/cuda-modules/tensorrt/fixup.nix +++ b/pkgs/development/cuda-modules/fixups/tensorrt.nix @@ -1,13 +1,12 @@ { + cudaOlder, + cudaPackages, cudaVersion, - final, lib, mkVersionedPackageName, - package, patchelf, requireFile, stdenv, - ... }: let inherit (lib) @@ -28,18 +27,19 @@ finalAttrs: prevAttrs: { # Useful for inspecting why something went wrong. brokenConditions = let - cudaTooOld = strings.versionOlder cudaVersion package.minCudaVersion; + cudaTooOld = cudaOlder finalAttrs.passthru.featureRelease.minCudaVersion; cudaTooNew = - (package.maxCudaVersion != null) && strings.versionOlder package.maxCudaVersion cudaVersion; - cudnnVersionIsSpecified = package.cudnnVersion != null; - cudnnVersionSpecified = versions.majorMinor package.cudnnVersion; + (finalAttrs.passthru.featureRelease.maxCudaVersion != null) + && strings.versionOlder finalAttrs.passthru.featureRelease.maxCudaVersion cudaVersion; + cudnnVersionIsSpecified = finalAttrs.passthru.featureRelease.cudnnVersion != null; + cudnnVersionSpecified = versions.majorMinor finalAttrs.passthru.featureRelease.cudnnVersion; cudnnVersionProvided = versions.majorMinor finalAttrs.passthru.cudnn.version; cudnnTooOld = cudnnVersionIsSpecified && (strings.versionOlder cudnnVersionProvided cudnnVersionSpecified); cudnnTooNew = cudnnVersionIsSpecified && (strings.versionOlder cudnnVersionSpecified cudnnVersionProvided); in - prevAttrs.brokenConditions + prevAttrs.brokenConditions or { } // { "CUDA version is too old" = cudaTooOld; "CUDA version is too new" = cudaTooNew; @@ -48,27 +48,27 @@ finalAttrs: prevAttrs: { }; src = requireFile { - name = package.filename; - inherit (package) hash; + name = finalAttrs.passthru.redistribRelease.filename; + inherit (finalAttrs.passthru.redistribRelease) hash; message = '' To use the TensorRT derivation, you must join the NVIDIA Developer Program and - download the ${package.version} TAR package for CUDA ${cudaVersion} from + download the ${finalAttrs.version} TAR package for CUDA ${cudaVersion} from ${finalAttrs.meta.homepage}. Once you have downloaded the file, add it to the store with the following command, and try building this derivation again. - $ nix-store --add-fixed sha256 ${package.filename} + $ nix-store --add-fixed sha256 ${finalAttrs.passthru.redistribRelease.filename} ''; }; # We need to look inside the extracted output to get the files we need. sourceRoot = "TensorRT-${finalAttrs.version}"; - buildInputs = prevAttrs.buildInputs ++ [ (finalAttrs.passthru.cudnn.lib or null) ]; + buildInputs = prevAttrs.buildInputs or [ ] ++ [ (finalAttrs.passthru.cudnn.lib or null) ]; preInstall = - (prevAttrs.preInstall or "") + prevAttrs.preInstall or "" + strings.optionalString (targetArch != "unsupported") '' # Replace symlinks to bin and lib with the actual directories from targets. for dir in bin lib; do @@ -87,7 +87,7 @@ finalAttrs: prevAttrs: { let versionTriple = "${versions.majorMinor finalAttrs.version}.${versions.patch finalAttrs.version}"; in - (prevAttrs.postFixup or "") + prevAttrs.postFixup or "" + '' ${meta.getExe' patchelf "patchelf"} --add-needed libnvinfer.so \ "$lib/lib/libnvinfer.so.${versionTriple}" \ @@ -95,7 +95,7 @@ finalAttrs: prevAttrs: { "$lib/lib/libnvinfer_builder_resource.so.${versionTriple}" ''; - passthru = { + passthru = prevAttrs.passthru or { } // { useCudatoolkitRunfile = strings.versionOlder cudaVersion "11.3.999"; # The CUDNN used with TensorRT. # If null, the default cudnn derivation will be used. @@ -103,12 +103,15 @@ finalAttrs: prevAttrs: { # unless it is not available, in which case the default cudnn derivation will be used. cudnn = let - desiredName = mkVersionedPackageName "cudnn" package.cudnnVersion; + desiredName = mkVersionedPackageName "cudnn" finalAttrs.passthru.featureRelease.cudnnVersion; in - if package.cudnnVersion == null || (final ? desiredName) then final.cudnn else final.${desiredName}; + if finalAttrs.passthru.featureRelease.cudnnVersion == null || (cudaPackages ? desiredName) then + cudaPackages.cudnn + else + cudaPackages.${desiredName}; }; - meta = prevAttrs.meta // { + meta = prevAttrs.meta or { } // { badPlatforms = prevAttrs.meta.badPlatforms or [ ] ++ lib.optionals (targetArch == "unsupported") [ hostPlatform.system ]; diff --git a/pkgs/development/cuda-modules/generic-builders/manifest.nix b/pkgs/development/cuda-modules/generic-builders/manifest.nix index e798bd29b6ea..f36cc2d989ad 100644 --- a/pkgs/development/cuda-modules/generic-builders/manifest.nix +++ b/pkgs/development/cuda-modules/generic-builders/manifest.nix @@ -4,7 +4,9 @@ autoAddCudaCompatRunpath, autoPatchelfHook, backendStdenv, + callPackage, fetchurl, + fixups, lib, markForCudatoolkitRootHook, flags, @@ -30,7 +32,6 @@ let inherit (lib) attrsets lists - meta strings trivial licenses @@ -40,6 +41,12 @@ let inherit (stdenv) hostPlatform; + # Last step before returning control to `callPackage` (adds the `.override` method) + # we'll apply (`overrideAttrs`) necessary package-specific "fixup" functions. + # Order is significant. + maybeFixup = fixups.${pname} or null; + fixup = if maybeFixup != null then callPackage maybeFixup { } else { }; + # Get the redist architectures for which package provides distributables. # These are used by meta.platforms. supportedRedistArchs = builtins.attrNames featureRelease; @@ -50,7 +57,7 @@ let sourceMatchesHost = flags.getNixSystem redistArch == hostPlatform.system; in -backendStdenv.mkDerivation (finalAttrs: { +(backendStdenv.mkDerivation (finalAttrs: { # NOTE: Even though there's no actual buildPhase going on here, the derivations of the # redistributables are sensitive to the compiler flags provided to stdenv. The patchelf package # is sensitive to the compiler flags provided to stdenv, and we depend on it. As such, we are @@ -303,8 +310,12 @@ backendStdenv.mkDerivation (finalAttrs: { true ''; - # Make the CUDA-patched stdenv available - passthru.stdenv = backendStdenv; + passthru = { + # Provide access to the release information for fixup functions. + inherit redistribRelease featureRelease; + # Make the CUDA-patched stdenv available + stdenv = backendStdenv; + }; meta = { description = "${redistribRelease.name}. By downloading and using the packages you accept the terms and conditions of the ${finalAttrs.meta.license.shortName}"; @@ -321,7 +332,21 @@ backendStdenv.mkDerivation (finalAttrs: { isBadPlatform = lists.any trivial.id (attrsets.attrValues finalAttrs.badPlatformsConditions); in lists.optionals isBadPlatform finalAttrs.meta.platforms; - license = licenses.unfree; + license = + if redistName == "cuda" then + # Add the package-specific license. + let + licensePath = + if redistribRelease.license_path != null then + redistribRelease.license_path + else + "${pname}/LICENSE.txt"; + url = "https://developer.download.nvidia.com/compute/cuda/redist/${licensePath}"; + in + lib.licenses.nvidiaCudaRedist // { inherit url; } + else + licenses.unfree; teams = [ teams.cuda ]; }; -}) +})).overrideAttrs + fixup diff --git a/pkgs/development/cuda-modules/generic-builders/multiplex.nix b/pkgs/development/cuda-modules/generic-builders/multiplex.nix index ce50653bb5d4..f6cb5ae7e658 100644 --- a/pkgs/development/cuda-modules/generic-builders/multiplex.nix +++ b/pkgs/development/cuda-modules/generic-builders/multiplex.nix @@ -6,8 +6,14 @@ stdenv, # Expected to be passed by the caller mkVersionedPackageName, - # pname :: String + # Builder-specific arguments + # Short package name (e.g., "cuda_cccl") + # pname : String pname, + # Common name (e.g., "cutensor" or "cudnn") -- used in the URL. + # Also known as the Redistributable Name. + # redistName : String, + redistName, # releasesModule :: Path # A path to a module which provides a `releases` attribute releasesModule, @@ -17,20 +23,11 @@ # and the package description (which NVIDIA's manifest calls the "name"). # It's also used for fetching the source, but we override that since we can't # re-use that portion of the functionality (different URLs, etc.). - # The featureRelease is used to populate meta.platforms (by way of looking at the attribute names) - # and to determine the outputs of the package. + # The featureRelease is used to populate meta.platforms (by way of looking at the attribute names), determine the + # outputs of the package, and provide additional package-specific constraints (e.g., min/max supported CUDA versions, + # required versions of other packages, etc.). # shimFn :: {package, redistArch} -> AttrSet shimsFn ? (throw "shimsFn must be provided"), - # fixupFn :: Path - # A path (or nix expression) to be evaluated with callPackage and then - # provided to the package's overrideAttrs function. - # It must accept at least the following arguments: - # - final - # - cudaVersion - # - mkVersionedPackageName - # - package - # - ... - fixupFn ? (throw "fixupFn must be provided"), }: let inherit (lib) @@ -97,19 +94,6 @@ let newest = builtins.head (builtins.sort preferable allReleases); - # A function which takes the `final` overlay and the `package` being built and returns - # a function to be consumed via `overrideAttrs`. - overrideAttrsFixupFn = - final: package: - final.callPackage fixupFn { - inherit - final - cudaVersion - mkVersionedPackageName - package - ; - }; - extension = final: _: let @@ -124,13 +108,11 @@ let }; name = computeName package; drv = final.callPackage ./manifest.nix { - inherit pname; - redistName = pname; + inherit pname redistName; inherit (shims) redistribRelease featureRelease; }; - fixedDrv = drv.overrideAttrs (overrideAttrsFixupFn final package); in - attrsets.nameValuePair name fixedDrv; + attrsets.nameValuePair name drv; # versionedDerivations :: AttrSet Derivation versionedDerivations = builtins.listToAttrs (lists.map buildPackage allReleases); diff --git a/pkgs/development/cuda-modules/tensorrt/shims.nix b/pkgs/development/cuda-modules/tensorrt/shims.nix index 12465434ec85..7832f8e97c51 100644 --- a/pkgs/development/cuda-modules/tensorrt/shims.nix +++ b/pkgs/development/cuda-modules/tensorrt/shims.nix @@ -8,6 +8,7 @@ }: { featureRelease = lib.optionalAttrs (redistArch != "unsupported") { + inherit (package) cudnnVersion minCudaVersion maxCudaVersion; ${redistArch}.outputs = { bin = true; lib = true; @@ -19,6 +20,6 @@ }; redistribRelease = { name = "TensorRT: a high-performance deep learning interface"; - inherit (package) version; + inherit (package) hash filename version; }; } diff --git a/pkgs/top-level/cuda-packages.nix b/pkgs/top-level/cuda-packages.nix index 4f44a495fd52..89315d25ac39 100644 --- a/pkgs/top-level/cuda-packages.nix +++ b/pkgs/top-level/cuda-packages.nix @@ -13,20 +13,20 @@ # # - `prev` should only be used to access attributes which are going to be overridden. # - `final` should only be used to access `callPackage` to build new packages. -# - Attribute names should be computable without relying on `final`. -# - Extensions should take arguments to build attribute names before relying on `final`. +# - Attribute names are evaluated eagerly ("NAMESET STRICTNESS"). +# - Extensions must not depend on `final` when computing names and count of new attributes. # # Silvan's recommendation then is to explicitly use `callPackage` to provide everything our # extensions need to compute the attribute names, without relying on `final`. # # I've (@connorbaker) attempted to do that, though I'm unsure of how this will interact with overrides. { - callPackage, + config, cudaVersion, lib, newScope, pkgs, - config, + stdenv, }: let inherit (lib) @@ -37,18 +37,42 @@ let strings versions ; - # Backbone - gpus = builtins.import ../development/cuda-modules/gpus.nix; - nvccCompatibilities = builtins.import ../development/cuda-modules/nvcc-compatibilities.nix; - flags = callPackage ../development/cuda-modules/flags.nix { inherit cudaVersion gpus; }; + # MUST be defined outside fix-point (cf. "NAMESET STRICTNESS" above) + fixups = import ../development/cuda-modules/fixups { inherit lib; }; + gpus = import ../development/cuda-modules/gpus.nix; + nvccCompatibilities = import ../development/cuda-modules/nvcc-compatibilities.nix; + flags = import ../development/cuda-modules/flags.nix { + inherit + config + cudaVersion + gpus + lib + stdenv + ; + }; + + mkVersionedPackageName = + name: version: name + "_" + strings.replaceStrings [ "." ] [ "_" ] (versions.majorMinor version); + passthruFunction = final: { - inherit cudaVersion lib pkgs; - inherit gpus nvccCompatibilities flags; + inherit + cudaVersion + fixups + flags + gpus + lib + nvccCompatibilities + pkgs + ; cudaMajorVersion = versions.major cudaVersion; cudaMajorMinorVersion = versions.majorMinor cudaVersion; cudaOlder = strings.versionOlder cudaVersion; cudaAtLeast = strings.versionAtLeast cudaVersion; + # NOTE: mkVersionedPackageName is an internal, implementation detail and should not be relied on by outside consumers. + # It may be removed in the future. + inherit mkVersionedPackageName; + # Maintain a reference to the final cudaPackages. # Without this, if we use `final.callPackage` and a package accepts `cudaPackages` as an # argument, it's provided with `cudaPackages` from the top-level scope, which is not what we @@ -111,13 +135,6 @@ let attrsets.listToAttrs (attrsets.mapCartesianProduct builder configs); }; - mkVersionedPackageName = - name: version: - strings.concatStringsSep "_" [ - name - (strings.replaceStrings [ "." ] [ "_" ] (versions.majorMinor version)) - ]; - composedExtension = fixedPoints.composeManyExtensions ( [ ( @@ -127,30 +144,53 @@ let directory = ../development/cuda-modules/packages; } ) - (callPackage ../development/cuda-modules/cuda/extension.nix { inherit cudaVersion; }) - (import ../development/cuda-modules/cuda/overrides.nix) - (callPackage ../development/cuda-modules/generic-builders/multiplex.nix { - inherit cudaVersion flags mkVersionedPackageName; + (import ../development/cuda-modules/cuda/extension.nix { inherit cudaVersion lib; }) + (import ../development/cuda-modules/generic-builders/multiplex.nix { + inherit + cudaVersion + flags + lib + mkVersionedPackageName + stdenv + ; pname = "cudnn"; + redistName = "cudnn"; releasesModule = ../development/cuda-modules/cudnn/releases.nix; shimsFn = ../development/cuda-modules/cudnn/shims.nix; - fixupFn = ../development/cuda-modules/cudnn/fixup.nix; }) - (callPackage ../development/cuda-modules/cutensor/extension.nix { - inherit cudaVersion flags mkVersionedPackageName; + (import ../development/cuda-modules/cutensor/extension.nix { + inherit + cudaVersion + flags + lib + mkVersionedPackageName + stdenv + ; }) - (callPackage ../development/cuda-modules/cusparselt/extension.nix { - inherit cudaVersion flags mkVersionedPackageName; + (import ../development/cuda-modules/cusparselt/extension.nix { + inherit + cudaVersion + flags + lib + mkVersionedPackageName + stdenv + ; }) - (callPackage ../development/cuda-modules/generic-builders/multiplex.nix { - inherit cudaVersion flags mkVersionedPackageName; + (import ../development/cuda-modules/generic-builders/multiplex.nix { + inherit + cudaVersion + flags + lib + mkVersionedPackageName + stdenv + ; pname = "tensorrt"; + redistName = "tensorrt"; releasesModule = ../development/cuda-modules/tensorrt/releases.nix; shimsFn = ../development/cuda-modules/tensorrt/shims.nix; - fixupFn = ../development/cuda-modules/tensorrt/fixup.nix; }) - (callPackage ../development/cuda-modules/cuda-samples/extension.nix { inherit cudaVersion; }) - (callPackage ../development/cuda-modules/cuda-library-samples/extension.nix { }) + (import ../development/cuda-modules/cuda-samples/extension.nix { inherit cudaVersion lib stdenv; }) + (import ../development/cuda-modules/cuda-library-samples/extension.nix { inherit lib stdenv; }) ] ++ lib.optionals config.allowAliases [ (import ../development/cuda-modules/aliases.nix) ] ); From eec8903639b0d80304eff9fd4c3d39b5398d79ee Mon Sep 17 00:00:00 2001 From: SomeoneSerge Date: Thu, 8 May 2025 15:51:43 +0000 Subject: [PATCH 11/26] cudaPackages_11_0.cudnn-frontend: mark unsupported, prevent eval error With https://github.com/NixOS/nixpkgs/pull/404686 we add packages/ unconditionally --- .../packages/cudnn-frontend/package.nix | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pkgs/development/cuda-modules/packages/cudnn-frontend/package.nix b/pkgs/development/cuda-modules/packages/cudnn-frontend/package.nix index 07af94f4e927..22b895f7658e 100644 --- a/pkgs/development/cuda-modules/packages/cudnn-frontend/package.nix +++ b/pkgs/development/cuda-modules/packages/cudnn-frontend/package.nix @@ -2,13 +2,18 @@ autoAddDriverRunpath, catch2_3, cmake, - cudaPackages, fetchFromGitHub, gitUpdater, lib, ninja, nlohmann_json, stdenv, + cuda_cccl ? null, + cuda_cudart ? null, + cuda_nvcc ? null, + cuda_nvrtc ? null, + cudnn ? null, + libcublas ? null, }: let inherit (lib.lists) optionals; @@ -17,14 +22,6 @@ let cmakeFeature optionalString ; - inherit (cudaPackages) - cuda_cccl - cuda_cudart - cuda_nvcc - cuda_nvrtc - cudnn - libcublas - ; in # TODO(@connorbaker): This should be a hybrid C++/Python package. @@ -125,6 +122,7 @@ stdenv.mkDerivation (finalAttrs: { description = "A c++ wrapper for the cudnn backend API"; homepage = "https://github.com/NVIDIA/cudnn-frontend"; license = lib.licenses.mit; + badPlatforms = optionals (cudnn == null) finalAttrs.meta.platforms; platforms = [ "aarch64-linux" "x86_64-linux" From 5f817f208f9f4e34af0be8a3cbf720277442b7c3 Mon Sep 17 00:00:00 2001 From: hustlerone Date: Thu, 1 May 2025 01:42:22 +0200 Subject: [PATCH 12/26] pkgs/buffybox: 3.2.0-unstable-2025-03-16 -> 3.3.0 --- pkgs/by-name/bu/buffybox/package.nix | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/pkgs/by-name/bu/buffybox/package.nix b/pkgs/by-name/bu/buffybox/package.nix index 734edca31ddc..3e6af13bacf8 100644 --- a/pkgs/by-name/bu/buffybox/package.nix +++ b/pkgs/by-name/bu/buffybox/package.nix @@ -11,27 +11,32 @@ pkg-config, scdoc, stdenv, - unstableGitUpdater, + gitUpdater, }: stdenv.mkDerivation (finalAttrs: { pname = "buffybox"; - version = "3.2.0-unstable-2025-03-16"; + version = "3.3.0"; src = fetchFromGitLab { domain = "gitlab.postmarketos.org"; owner = "postmarketOS"; repo = "buffybox"; fetchSubmodules = true; # to use its vendored lvgl - rev = "56a9867e90ece88596e330774da64cf277069b59"; - hash = "sha256-4lSgswcvvV6W1KN6QhsjeHY8MMXXC4fRYBmPE/hb0vA="; + rev = "dce41a6f07a2b63c3136409b7bcd0078299fadf9"; + hash = "sha256-n5RQg7kGS+lg7sRe5Defl3nDEha0vhc/FbwywD5wBsg="; }; patches = [ (fetchpatch2 { - # https://gitlab.postmarketos.org/postmarketOS/buffybox/-/merge_requests/42 - url = "https://gitlab.postmarketos.org/postmarketOS/buffybox/-/commit/1f0c30e88dc61b8b508696cd890393c3b7911b58.patch?full_index=1"; - hash = "sha256-hQ6Hjfyj059j2cRfrFz9Se6xRowIGW1HVHULLYtHcS8="; + # This fixes a bug that might annoy you if you use something like PKCS#11 + url = "https://gitlab.postmarketos.org/postmarketOS/buffybox/-/commit/d8214b522a3cc72cd4639a1dd114103a02e9218c.patch"; + hash = "sha256-WxKuioJ1Fo5ARRYF/R4yULDVB4pq11phljzVGdWTV6s="; + }) + (fetchpatch2 { + # Fixes up UB + url = "https://gitlab.postmarketos.org/postmarketOS/buffybox/-/commit/4e13c312241420cbb3e5cc7d4f0dd3e5d17449be.patch"; + hash = "sha256-7yX6gGsptwijx+ZedSJWJKhwaoBVpxIbGK+ZiMLsIhc="; }) ]; @@ -57,7 +62,7 @@ stdenv.mkDerivation (finalAttrs: { strictDeps = true; - passthru.updateScript = unstableGitUpdater { }; + passthru.updateScript = gitUpdater { }; meta = with lib; { description = "A suite of graphical applications for the terminal"; From 90ff6dc49edaeeb3817dba7ca9c87f841a076c6e Mon Sep 17 00:00:00 2001 From: hustlerone Date: Fri, 9 May 2025 00:29:43 +0200 Subject: [PATCH 13/26] nixos/unl0kr: fix touchpads --- nixos/modules/system/boot/unl0kr.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/nixos/modules/system/boot/unl0kr.nix b/nixos/modules/system/boot/unl0kr.nix index 318090047b3a..7b7197cb0c10 100644 --- a/nixos/modules/system/boot/unl0kr.nix +++ b/nixos/modules/system/boot/unl0kr.nix @@ -75,6 +75,7 @@ in "usbtouchscreen" "evdev" + "psmouse" ] ++ lib.optionals cfg.allowVendorDrivers [ "intel_lpss_pci" From e4778f3cd49df8333b2572d9e2c54a33dcb6ca7b Mon Sep 17 00:00:00 2001 From: qbisi Date: Mon, 21 Apr 2025 00:47:10 +0800 Subject: [PATCH 14/26] python312Packages.fenics-basix: init at 0.9.0 --- .../python-modules/fenics-basix/default.nix | 81 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 83 insertions(+) create mode 100644 pkgs/development/python-modules/fenics-basix/default.nix diff --git a/pkgs/development/python-modules/fenics-basix/default.nix b/pkgs/development/python-modules/fenics-basix/default.nix new file mode 100644 index 000000000000..d48c7082805d --- /dev/null +++ b/pkgs/development/python-modules/fenics-basix/default.nix @@ -0,0 +1,81 @@ +{ + lib, + buildPythonPackage, + fetchFromGitHub, + scikit-build-core, + nanobind, + cmake, + ninja, + pkg-config, + blas, + lapack, + numpy, + sympy, + scipy, + matplotlib, + fenics-ufl, + pytest-xdist, + pytestCheckHook, +}: + +buildPythonPackage rec { + pname = "fenics-basix"; + version = "0.9.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "fenics"; + repo = "basix"; + tag = "v${version}"; + hash = "sha256-jLQMDt6zdl+oixd5Qevn4bvxBsXpTNcbH2Os6TC9sRQ="; + }; + + dontUseCmakeConfigure = true; + + build-system = [ + scikit-build-core + nanobind + ]; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + ]; + + dependencies = [ + numpy + ]; + + buildInputs = [ + blas + lapack + ]; + + # Prefer finding BLAS and LAPACK via pkg-config. + # Avoid using the Accelerate.framework from the Darwin SDK. + # Also, avoid mistaking BLAS for LAPACK. + env.CMAKE_ARGS = lib.cmakeBool "BLA_PREFER_PKGCONFIG" true; + + pythonImportsCheck = [ + "basix" + ]; + + nativeCheckInputs = [ + sympy + scipy + matplotlib + fenics-ufl + pytest-xdist + pytestCheckHook + ]; + + meta = { + homepage = "https://fenicsproject.org"; + downloadPage = "https://github.com/fenics/basix"; + description = "Finite element definition and tabulation runtime library"; + changelog = "https://github.com/fenics/basix/releases/tag/${src.tag}"; + license = lib.licenses.mit; + maintainers = with lib.maintainers; [ qbisi ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index cb008fa244ec..17f2ac93399d 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4859,6 +4859,8 @@ self: super: with self; { fenics = callPackage ../development/python-modules/fenics { hdf5 = pkgs.hdf5_1_10; }; + fenics-basix = callPackage ../development/python-modules/fenics-basix { }; + fenics-ufl = callPackage ../development/python-modules/fenics-ufl { }; ffcv = callPackage ../development/python-modules/ffcv { }; From 0c3ed24d1e7e9b625dcf980dcb133118ddfd787f Mon Sep 17 00:00:00 2001 From: qbisi Date: Mon, 21 Apr 2025 00:47:54 +0800 Subject: [PATCH 15/26] python312Packages.fenics-ffcx: init at 0.9.0 --- .../python-modules/fenics-ffcx/default.nix | 70 +++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 72 insertions(+) create mode 100644 pkgs/development/python-modules/fenics-ffcx/default.nix diff --git a/pkgs/development/python-modules/fenics-ffcx/default.nix b/pkgs/development/python-modules/fenics-ffcx/default.nix new file mode 100644 index 000000000000..c0b212d7b01d --- /dev/null +++ b/pkgs/development/python-modules/fenics-ffcx/default.nix @@ -0,0 +1,70 @@ +{ + lib, + stdenv, + buildPythonPackage, + fetchFromGitHub, + setuptools, + numpy, + cffi, + fenics-ufl, + fenics-basix, + sympy, + numba, + pytestCheckHook, + addBinToPathHook, +}: + +buildPythonPackage rec { + pname = "fenics-ffcx"; + version = "0.9.0"; + pyproject = true; + + src = fetchFromGitHub { + owner = "fenics"; + repo = "ffcx"; + tag = "v${version}"; + hash = "sha256-eAV//RLbrxyhqgbZ2DiR7qML7xfgPn0/Seh+2no0x8w="; + }; + + pythonRelaxDeps = [ + "fenics-ufl" + ]; + + build-system = [ + setuptools + ]; + + dependencies = [ + numpy + cffi + setuptools + fenics-ufl + fenics-basix + ]; + + pythonImportsCheck = [ + "ffcx" + ]; + + nativeCheckInputs = [ + sympy + numba + pytestCheckHook + addBinToPathHook + ]; + + env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang "-Wno-error=unused-command-line-argument"; + + meta = { + homepage = "https://fenicsproject.org"; + downloadPage = "https://github.com/fenics/ffcx"; + description = "FEniCSx Form Compiler"; + changelog = "https://github.com/fenics/ffcx/releases/tag/${src.tag}"; + mainProgram = "ffcx"; + license = with lib.licenses; [ + unlicense + lgpl3Plus + ]; + maintainers = with lib.maintainers; [ qbisi ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index 17f2ac93399d..a34b96108028 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4861,6 +4861,8 @@ self: super: with self; { fenics-basix = callPackage ../development/python-modules/fenics-basix { }; + fenics-ffcx = callPackage ../development/python-modules/fenics-ffcx { }; + fenics-ufl = callPackage ../development/python-modules/fenics-ufl { }; ffcv = callPackage ../development/python-modules/ffcv { }; From 77ce9519c32777831b7c8c82244727790a741029 Mon Sep 17 00:00:00 2001 From: qbisi Date: Tue, 6 May 2025 20:46:33 +0800 Subject: [PATCH 16/26] petsc: inherit python3/python3Packages in petscPackages --- pkgs/by-name/pe/petsc/package.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pkgs/by-name/pe/petsc/package.nix b/pkgs/by-name/pe/petsc/package.nix index e05d85d7f2a2..8f45a30a051a 100644 --- a/pkgs/by-name/pe/petsc/package.nix +++ b/pkgs/by-name/pe/petsc/package.nix @@ -78,6 +78,8 @@ let petscPackages = lib.makeScope newScope (self: { inherit mpi + python3 + python3Packages # global override options mpiSupport fortranSupport From 178cabec1a4d62eb19e409c622a9314f2f6d2354 Mon Sep 17 00:00:00 2001 From: qbisi Date: Tue, 6 May 2025 20:47:45 +0800 Subject: [PATCH 17/26] adiso2: override hdf5-mpi with mpi --- pkgs/by-name/ad/adios2/package.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/by-name/ad/adios2/package.nix b/pkgs/by-name/ad/adios2/package.nix index 08120d9f2a34..6dc9083f41dd 100644 --- a/pkgs/by-name/ad/adios2/package.nix +++ b/pkgs/by-name/ad/adios2/package.nix @@ -71,7 +71,7 @@ stdenv.mkDerivation (finalAttrs: { bzip2 lz4 c-blosc2 - hdf5-mpi + (hdf5-mpi.override { inherit mpi; }) libfabric libpng libsodium From 9a2e22cb0e8903810d515dbfdaaa54fd22038ccd Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Thu, 8 May 2025 23:05:23 +0000 Subject: [PATCH 18/26] jawiki-all-titles-in-ns0: 0-unstable-2025-04-01 -> 0-unstable-2025-05-01 --- pkgs/by-name/ja/jawiki-all-titles-in-ns0/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/ja/jawiki-all-titles-in-ns0/package.nix b/pkgs/by-name/ja/jawiki-all-titles-in-ns0/package.nix index d1035c5d46b7..cdbc29fd3aab 100644 --- a/pkgs/by-name/ja/jawiki-all-titles-in-ns0/package.nix +++ b/pkgs/by-name/ja/jawiki-all-titles-in-ns0/package.nix @@ -7,13 +7,13 @@ stdenvNoCC.mkDerivation { pname = "jawiki-all-titles-in-ns0"; - version = "0-unstable-2025-04-01"; + version = "0-unstable-2025-05-01"; src = fetchFromGitHub { owner = "musjj"; repo = "jawiki-archive"; - rev = "7c9ce3d1e3000a56222011566a9d8cb9b910416d"; - hash = "sha256-Yw/Iv7osjhL1kZwTOc2iiOJIf96GPcEDTCNO67gwbYU="; + rev = "11011d2a5a27251a75a0ce822ed05fa9be7bf878"; + hash = "sha256-ZTCW14kHfewzCJuT6afGgSi3ZwC4cGiqecEma8Fj2mk="; }; installPhase = '' From f76bdc0af6d53336f8eca12f340b5fe430755c00 Mon Sep 17 00:00:00 2001 From: qbisi Date: Thu, 8 May 2025 19:57:33 +0800 Subject: [PATCH 19/26] dolfinx: init at 0.9.0.post1 --- pkgs/by-name/do/dolfinx/package.nix | 114 ++++++++++++++++++++++++++++ 1 file changed, 114 insertions(+) create mode 100644 pkgs/by-name/do/dolfinx/package.nix diff --git a/pkgs/by-name/do/dolfinx/package.nix b/pkgs/by-name/do/dolfinx/package.nix new file mode 100644 index 000000000000..db7d0659601f --- /dev/null +++ b/pkgs/by-name/do/dolfinx/package.nix @@ -0,0 +1,114 @@ +{ + lib, + stdenv, + fetchFromGitHub, + cmake, + pkg-config, + spdlog, + pugixml, + boost, + petsc, + slepc, + kahip, + adios2, + python3Packages, + catch2_3, + withParmetis ? false, +}: +let + dolfinxPackages = petsc.petscPackages.overrideScope ( + final: prev: { + slepc = final.callPackage slepc.override { }; + adios2 = final.callPackage adios2.override { }; + kahip = final.callPackage kahip.override { }; + } + ); +in +stdenv.mkDerivation (finalAttrs: { + version = "0.9.0.post1"; + pname = "dolfinx"; + + src = fetchFromGitHub { + owner = "fenics"; + repo = "dolfinx"; + tag = "v${finalAttrs.version}"; + hash = "sha256-4IIx7vUZeDwOGVdyC2PBvfhVjrmGZeVQKAwgDYScbY0="; + }; + + preConfigure = '' + cd cpp + ''; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ + dolfinxPackages.kahip + dolfinxPackages.scotch + ] ++ lib.optional withParmetis dolfinxPackages.parmetis; + + propagatedBuildInputs = [ + spdlog + pugixml + boost + petsc + dolfinxPackages.hdf5 + dolfinxPackages.slepc + dolfinxPackages.adios2 + python3Packages.fenics-basix + python3Packages.fenics-ffcx + ]; + + cmakeFlags = [ + (lib.cmakeBool "DOLFINX_ENABLE_ADIOS2" true) + (lib.cmakeBool "DOLFINX_ENABLE_PETSC" true) + (lib.cmakeBool "DOLFIN_ENABLE_PARMETIS" withParmetis) + (lib.cmakeBool "DOLFINX_ENABLE_SCOTCH" true) + (lib.cmakeBool "DOLFINX_ENABLE_SLEPC" true) + (lib.cmakeBool "DOLFINX_ENABLE_KAHIP" true) + (lib.cmakeFeature "CMAKE_INSTALL_BINDIR" "bin") + (lib.cmakeFeature "CMAKE_INSTALL_LIBDIR" "lib") + (lib.cmakeFeature "CMAKE_INSTALL_INCLUDEDIR" "include") + ]; + + passthru.tests = { + unittests = stdenv.mkDerivation { + pname = "${finalAttrs.pname}-unittests"; + inherit (finalAttrs) version src; + + preConfigure = '' + cd cpp/test + ''; + + nativeBuildInputs = [ + cmake + pkg-config + ]; + + buildInputs = [ finalAttrs.finalPackage ]; + + nativeCheckInputs = [ catch2_3 ]; + + doCheck = true; + + installPhase = '' + touch $out + ''; + }; + }; + + meta = { + homepage = "https://fenicsproject.org"; + downloadPage = "https://github.com/fenics/dolfinx"; + description = "Computational environment of FEniCSx and implements the FEniCS Problem Solving Environment in C++ and Python"; + changelog = "https://github.com/fenics/dolfinx/releases/tag/${finalAttrs.src.tag}"; + license = with lib.licenses; [ + bsd2 + lgpl3Plus + ]; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ qbisi ]; + }; +}) From 2bbc507c013b3c55028d88671bcbd336e57e5090 Mon Sep 17 00:00:00 2001 From: qbisi Date: Tue, 6 May 2025 17:42:52 +0800 Subject: [PATCH 20/26] python312Packages.fenics-dolfinx: init at 0.9.0.post1 --- .../python-modules/fenics-dolfinx/default.nix | 157 ++++++++++++++++++ pkgs/top-level/python-packages.nix | 2 + 2 files changed, 159 insertions(+) create mode 100644 pkgs/development/python-modules/fenics-dolfinx/default.nix diff --git a/pkgs/development/python-modules/fenics-dolfinx/default.nix b/pkgs/development/python-modules/fenics-dolfinx/default.nix new file mode 100644 index 000000000000..ffb5ead74482 --- /dev/null +++ b/pkgs/development/python-modules/fenics-dolfinx/default.nix @@ -0,0 +1,157 @@ +{ + lib, + stdenv, + toPythonModule, + fetchFromGitHub, + buildPythonPackage, + + # build-system + scikit-build-core, + nanobind, + + # nativeBuildInputs + cmake, + ninja, + pkg-config, + + # buildInputs + dolfinx, + + # dependency + numpy, + cffi, + mpi4py, + petsc4py, + slepc4py, + adios2, + kahip, + fenics-ffcx, + fenics-basix, + fenics-ufl, + + # nativeCheckInputs + scipy, + matplotlib, + pytest-xdist, + pytestCheckHook, + writableTmpDirAsHomeHook, + mpiCheckPhaseHook, + + # custom options + withParmetis ? false, + + # passthru.tests + fenics-dolfinx, + mpich, +}: + +let + fenicsPackages = petsc4py.petscPackages.overrideScope ( + final: prev: { + slepc = final.callPackage slepc4py.override { }; + adios2 = final.callPackage adios2.override { }; + kahip = final.callPackage kahip.override { }; + dolfinx = final.callPackage dolfinx.override { inherit withParmetis; }; + } + ); +in +buildPythonPackage rec { + inherit (dolfinx) + version + src + ; + pname = "fenics-dolfinx"; + pyproject = true; + + pythonRelaxDeps = [ + "cffi" + "fenics-ufl" + ]; + + preConfigure = '' + cd python + ''; + + dontUseCmakeConfigure = true; + + build-system = [ + scikit-build-core + nanobind + ]; + + nativeBuildInputs = [ + cmake + ninja + pkg-config + fenicsPackages.mpi + ]; + + buildInputs = [ + fenicsPackages.dolfinx + ]; + + dependencies = [ + numpy + cffi + fenics-basix + fenics-ffcx + fenics-ufl + petsc4py + fenicsPackages.slepc + fenicsPackages.adios2 + fenicsPackages.kahip + (mpi4py.override { inherit (fenicsPackages) mpi; }) + ]; + + doCheck = true; + + nativeCheckInputs = [ + scipy + matplotlib + pytest-xdist + pytestCheckHook + writableTmpDirAsHomeHook + mpiCheckPhaseHook + ]; + + preCheck = '' + rm -rf dolfinx + ''; + + pythonImportsCheck = [ + "dolfinx" + ]; + + disabledTests = [ + # require cffi<1.17 + "test_cffi_expression" + "test_hexahedron_mesh" + ]; + + passthru = { + tests = + { + complex = fenics-dolfinx.override { + petsc4py = petsc4py.override { scalarType = "complex"; }; + }; + } + // lib.optionalAttrs stdenv.hostPlatform.isLinux { + mpich = fenics-dolfinx.override { + petsc4py = petsc4py.override { mpi = mpich; }; + }; + }; + }; + + meta = { + homepage = "https://fenicsproject.org"; + downloadPage = "https://github.com/fenics/dolfinx"; + description = "Computational environment of FEniCSx and implements the FEniCS Problem Solving Environment in C++ and Python"; + changelog = "https://github.com/fenics/dolfinx/releases/tag/${src.tag}"; + license = with lib.licenses; [ + bsd2 + lgpl3Plus + ]; + platforms = lib.platforms.unix; + maintainers = with lib.maintainers; [ qbisi ]; + }; +} diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index a34b96108028..1df25bc30548 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -4861,6 +4861,8 @@ self: super: with self; { fenics-basix = callPackage ../development/python-modules/fenics-basix { }; + fenics-dolfinx = callPackage ../development/python-modules/fenics-dolfinx { }; + fenics-ffcx = callPackage ../development/python-modules/fenics-ffcx { }; fenics-ufl = callPackage ../development/python-modules/fenics-ufl { }; From ae94f7ce023ca7fb489408e896e5b598ff352a94 Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Fri, 9 May 2025 01:32:55 +0000 Subject: [PATCH 21/26] kubergrunt: 0.17.2 -> 0.17.3 --- pkgs/by-name/ku/kubergrunt/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/ku/kubergrunt/package.nix b/pkgs/by-name/ku/kubergrunt/package.nix index e5900a7132c1..55b84075f330 100644 --- a/pkgs/by-name/ku/kubergrunt/package.nix +++ b/pkgs/by-name/ku/kubergrunt/package.nix @@ -6,13 +6,13 @@ buildGoModule rec { pname = "kubergrunt"; - version = "0.17.2"; + version = "0.17.3"; src = fetchFromGitHub { owner = "gruntwork-io"; repo = "kubergrunt"; rev = "v${version}"; - sha256 = "sha256-ros126t4QEhWnItScaY1ntcGI/YMpeC2f2yQrzSZ7w4="; + sha256 = "sha256-9ZF2O4/5n5uL+FA50Rfiq9gStQwNDWIhtz2GvJVu+u4="; }; vendorHash = "sha256-6dFIW2wwu6HHvoMo0+MhvKOtAJNVhg7JyVlBPqLQerw="; From 16985aed9a8a336578cba4af9ab755f35fab0980 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 8 May 2025 22:16:46 -0500 Subject: [PATCH 22/26] _1password-gui: move to by-name --- .../misc/1password-gui => by-name/_1/_1password-gui}/darwin.nix | 0 .../misc/1password-gui => by-name/_1/_1password-gui}/linux.nix | 0 .../default.nix => by-name/_1/_1password-gui/package.nix} | 0 .../1password-gui => by-name/_1/_1password-gui}/sources.json | 0 .../misc/1password-gui => by-name/_1/_1password-gui}/update.sh | 0 .../1password-gui => by-name/_1/_1password-gui}/versions.json | 0 pkgs/top-level/all-packages.nix | 2 -- 7 files changed, 2 deletions(-) rename pkgs/{applications/misc/1password-gui => by-name/_1/_1password-gui}/darwin.nix (100%) rename pkgs/{applications/misc/1password-gui => by-name/_1/_1password-gui}/linux.nix (100%) rename pkgs/{applications/misc/1password-gui/default.nix => by-name/_1/_1password-gui/package.nix} (100%) rename pkgs/{applications/misc/1password-gui => by-name/_1/_1password-gui}/sources.json (100%) rename pkgs/{applications/misc/1password-gui => by-name/_1/_1password-gui}/update.sh (100%) rename pkgs/{applications/misc/1password-gui => by-name/_1/_1password-gui}/versions.json (100%) diff --git a/pkgs/applications/misc/1password-gui/darwin.nix b/pkgs/by-name/_1/_1password-gui/darwin.nix similarity index 100% rename from pkgs/applications/misc/1password-gui/darwin.nix rename to pkgs/by-name/_1/_1password-gui/darwin.nix diff --git a/pkgs/applications/misc/1password-gui/linux.nix b/pkgs/by-name/_1/_1password-gui/linux.nix similarity index 100% rename from pkgs/applications/misc/1password-gui/linux.nix rename to pkgs/by-name/_1/_1password-gui/linux.nix diff --git a/pkgs/applications/misc/1password-gui/default.nix b/pkgs/by-name/_1/_1password-gui/package.nix similarity index 100% rename from pkgs/applications/misc/1password-gui/default.nix rename to pkgs/by-name/_1/_1password-gui/package.nix diff --git a/pkgs/applications/misc/1password-gui/sources.json b/pkgs/by-name/_1/_1password-gui/sources.json similarity index 100% rename from pkgs/applications/misc/1password-gui/sources.json rename to pkgs/by-name/_1/_1password-gui/sources.json diff --git a/pkgs/applications/misc/1password-gui/update.sh b/pkgs/by-name/_1/_1password-gui/update.sh similarity index 100% rename from pkgs/applications/misc/1password-gui/update.sh rename to pkgs/by-name/_1/_1password-gui/update.sh diff --git a/pkgs/applications/misc/1password-gui/versions.json b/pkgs/by-name/_1/_1password-gui/versions.json similarity index 100% rename from pkgs/applications/misc/1password-gui/versions.json rename to pkgs/by-name/_1/_1password-gui/versions.json diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index aada23abf900..334b6458b0eb 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1005,8 +1005,6 @@ with pkgs; _3llo = callPackage ../tools/misc/3llo { }; - _1password-gui = callPackage ../applications/misc/1password-gui { }; - _1password-gui-beta = callPackage ../applications/misc/1password-gui { channel = "beta"; }; _7zz-rar = _7zz.override { enableUnfree = true; }; From 99512615523a82416a5988fc31c48a65030bd5a5 Mon Sep 17 00:00:00 2001 From: Austin Horstman Date: Thu, 8 May 2025 22:17:00 -0500 Subject: [PATCH 23/26] _1password-gui-beta: move to by-name --- pkgs/by-name/_1/_1password-gui-beta/package.nix | 4 ++++ pkgs/top-level/all-packages.nix | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-) create mode 100644 pkgs/by-name/_1/_1password-gui-beta/package.nix diff --git a/pkgs/by-name/_1/_1password-gui-beta/package.nix b/pkgs/by-name/_1/_1password-gui-beta/package.nix new file mode 100644 index 000000000000..9c95e4f99039 --- /dev/null +++ b/pkgs/by-name/_1/_1password-gui-beta/package.nix @@ -0,0 +1,4 @@ +{ _1password-gui }: +_1password-gui.override { + channel = "beta"; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 334b6458b0eb..e71c2e9367ef 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -1005,8 +1005,6 @@ with pkgs; _3llo = callPackage ../tools/misc/3llo { }; - _1password-gui-beta = callPackage ../applications/misc/1password-gui { channel = "beta"; }; - _7zz-rar = _7zz.override { enableUnfree = true; }; acquire = with python3Packages; toPythonApplication acquire; From f414261449ad9a978a6630eba52fe3c03f9ad9be Mon Sep 17 00:00:00 2001 From: SchweGELBin Date: Thu, 8 May 2025 22:45:27 +0200 Subject: [PATCH 24/26] hyprutils: 0.7.0 -> 0.7.1 --- pkgs/by-name/hy/hyprutils/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/hy/hyprutils/package.nix b/pkgs/by-name/hy/hyprutils/package.nix index 79fc26fcea12..60354ad36f88 100644 --- a/pkgs/by-name/hy/hyprutils/package.nix +++ b/pkgs/by-name/hy/hyprutils/package.nix @@ -10,13 +10,13 @@ stdenv.mkDerivation (finalAttrs: { pname = "hyprutils"; - version = "0.7.0"; + version = "0.7.1"; src = fetchFromGitHub { owner = "hyprwm"; repo = "hyprutils"; tag = "v${finalAttrs.version}"; - hash = "sha256-s3GzsRxBL/N/xYgUXZhQh4t62uR1BN4zxXgWBtJ3lWM="; + hash = "sha256-W9G9bb0zRYDBRseHbVez0J8qVpD5QbizX67H/vsudhM="; }; nativeBuildInputs = [ From 8a05ea506120078c7b738c920f0a08c0292f29a8 Mon Sep 17 00:00:00 2001 From: SchweGELBin Date: Thu, 8 May 2025 22:45:55 +0200 Subject: [PATCH 25/26] hyprlang: 0.6.1 -> 0.6.3 --- pkgs/by-name/hy/hyprlang/package.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/by-name/hy/hyprlang/package.nix b/pkgs/by-name/hy/hyprlang/package.nix index 5570b078806c..9c0125f130e9 100644 --- a/pkgs/by-name/hy/hyprlang/package.nix +++ b/pkgs/by-name/hy/hyprlang/package.nix @@ -9,13 +9,13 @@ gcc14Stdenv.mkDerivation (finalAttrs: { pname = "hyprlang"; - version = "0.6.1"; + version = "0.6.3"; src = fetchFromGitHub { owner = "hyprwm"; repo = "hyprlang"; rev = "v${finalAttrs.version}"; - hash = "sha256-9HySx+EtsbbKlZDlY+naqqOV679VdxP6x6fP3wxDXJk="; + hash = "sha256-kVQ0bHVtX6baYxRWWIh4u3LNJZb9Zcm2xBeDPOGz5BY="; }; nativeBuildInputs = [ From 8aa7a0765328b318b8d1d23cf5a6934ce60b54f4 Mon Sep 17 00:00:00 2001 From: sudoforge Date: Mon, 24 Feb 2025 17:20:06 -0800 Subject: [PATCH 26/26] nixos/iwd: move General.UseDefaultInterface to DriverQuirks.DefaultInterface `General.UseDefaultInterface` was deprecated last year, with a recommendation to move to `DriverQuirks.DefaultInterface` [0] [1] [2]. [0]: https://git.kernel.org/pub/scm/network/wireless/iwd.git/commit/?id=5c7777ff0fbcdee3c5d3a3cf6b1f375f2e820644 [1]: https://git.kernel.org/pub/scm/network/wireless/iwd.git/commit/?id=d223f49fbc622e5b2f270711619ecbd542bed12e [2]: https://git.kernel.org/pub/scm/network/wireless/iwd.git/commit/?id=a27b7823df12c5d185b39aa7777c546843c1c96f --- nixos/modules/services/networking/iwd.nix | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/nixos/modules/services/networking/iwd.nix b/nixos/modules/services/networking/iwd.nix index 2209841678b3..e275e7906ad5 100644 --- a/nixos/modules/services/networking/iwd.nix +++ b/nixos/modules/services/networking/iwd.nix @@ -20,7 +20,7 @@ let defaults = { # without UseDefaultInterface, sometimes wlan0 simply goes AWOL with NetworkManager # https://iwd.wiki.kernel.org/interface_lifecycle#interface_management_in_iwd - General.UseDefaultInterface = + DriverQuirks.UseDefaultInterface = with config.networking.networkmanager; (enable && (wifi.backend == "iwd")); }; @@ -61,6 +61,12 @@ in Only one wireless daemon is allowed at the time: networking.wireless.enable and networking.wireless.iwd.enable are mutually exclusive. ''; } + { + assertion = !(cfg.settings ? General && cfg.settings.General ? UseDefaultInterface); + message = '' + `networking.wireless.iwd.settings.General.UseDefaultInterface` has been deprecated. Use `networking.wireless.iwd.settings.DriverQuirks.UseDefaultInterface` instead. + ''; + } ]; environment.etc."iwd/${configFile.name}".source = configFile;