From fd636882374cdce4c1e042b088b4eeaa18bbdb69 Mon Sep 17 00:00:00 2001 From: Zexin Yuan Date: Sun, 13 Apr 2025 22:49:45 +0800 Subject: [PATCH 1/7] python3Packages.warp-lang: init at 1.7.2.post1 --- .../warp-lang/darwin-libcxx.patch | 39 +++ .../warp-lang/darwin-single-target.patch | 50 ++++ .../python-modules/warp-lang/default.nix | 251 ++++++++++++++++++ .../warp-lang/standalone-cxx11-abi.patch | 25 ++ .../warp-lang/standalone-llvm.patch | 62 +++++ pkgs/top-level/python-packages.nix | 2 + 6 files changed, 429 insertions(+) create mode 100644 pkgs/development/python-modules/warp-lang/darwin-libcxx.patch create mode 100644 pkgs/development/python-modules/warp-lang/darwin-single-target.patch create mode 100644 pkgs/development/python-modules/warp-lang/default.nix create mode 100644 pkgs/development/python-modules/warp-lang/standalone-cxx11-abi.patch create mode 100644 pkgs/development/python-modules/warp-lang/standalone-llvm.patch diff --git a/pkgs/development/python-modules/warp-lang/darwin-libcxx.patch b/pkgs/development/python-modules/warp-lang/darwin-libcxx.patch new file mode 100644 index 000000000000..52fd5eb06b4f --- /dev/null +++ b/pkgs/development/python-modules/warp-lang/darwin-libcxx.patch @@ -0,0 +1,39 @@ +diff --git a/warp/build_dll.py b/warp/build_dll.py +index 4d411e1b..a9304c6a 100644 +--- a/warp/build_dll.py ++++ b/warp/build_dll.py +@@ -316,6 +316,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None + cuda_includes = f' -I"{cuda_home}/include"' if cu_path else "" + includes = cpp_includes + cuda_includes + ++ includes += " -isystem @LIBCXX_DEV@/include/c++/v1" ++ + if sys.platform == "darwin": + version = f"--target={arch}-apple-macos11" + else: +@@ -345,6 +347,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None + build_cmd = f'g++ {cpp_flags} -c "{cpp_path}" -o "{cpp_out}"' + run_cmd(build_cmd) + ++ ld_inputs.append('-L"@LIBCXX_LIB@/lib" -lc++') ++ + if cu_path: + cu_out = cu_path + ".o" + +diff --git a/warp/native/crt.h b/warp/native/crt.h +index 47ef9983..89ae289b 100644 +--- a/warp/native/crt.h ++++ b/warp/native/crt.h +@@ -65,6 +65,12 @@ extern "C" WP_API int _wp_isinf(double); + #include + #include + ++#undef isfinite ++#undef isinf ++#undef isnan ++ ++#include ++ + #else + + // These definitions are taken from Jitify: https://github.com/NVIDIA/jitify diff --git a/pkgs/development/python-modules/warp-lang/darwin-single-target.patch b/pkgs/development/python-modules/warp-lang/darwin-single-target.patch new file mode 100644 index 000000000000..08b5b8f0594c --- /dev/null +++ b/pkgs/development/python-modules/warp-lang/darwin-single-target.patch @@ -0,0 +1,50 @@ +diff --git a/build_llvm.py b/build_llvm.py +index 9d5a26a7..0be02a89 100644 +--- a/build_llvm.py ++++ b/build_llvm.py +@@ -389,15 +389,4 @@ def build_warp_clang_for_arch(args, lib_name, arch): + + + def build_warp_clang(args, lib_name): +- if sys.platform == "darwin": +- # create a universal binary by combining x86-64 and AArch64 builds +- build_warp_clang_for_arch(args, lib_name + "-x86_64", "x86_64") +- build_warp_clang_for_arch(args, lib_name + "-aarch64", "aarch64") +- +- dylib_path = os.path.join(build_path, f"bin/{lib_name}") +- run_cmd(f"lipo -create -output {dylib_path} {dylib_path}-x86_64 {dylib_path}-aarch64") +- os.remove(f"{dylib_path}-x86_64") +- os.remove(f"{dylib_path}-aarch64") +- +- else: +- build_warp_clang_for_arch(args, lib_name, machine_architecture()) ++ build_warp_clang_for_arch(args, lib_name, machine_architecture()) +diff --git a/warp/build_dll.py b/warp/build_dll.py +index 4d411e1b..4cf4a6c2 100644 +--- a/warp/build_dll.py ++++ b/warp/build_dll.py +@@ -317,7 +317,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None + includes = cpp_includes + cuda_includes + + if sys.platform == "darwin": +- version = f"--target={arch}-apple-macos11" ++ version = "" + else: + version = "-fabi-version=13" # GCC 8.2+ + +@@ -392,14 +392,4 @@ def build_dll(args, dll_path, cpp_paths, cu_path, libs=None): + if libs is None: + libs = [] + +- if sys.platform == "darwin": +- # create a universal binary by combining x86-64 and AArch64 builds +- build_dll_for_arch(args, dll_path + "-x86_64", cpp_paths, cu_path, libs, "x86_64") +- build_dll_for_arch(args, dll_path + "-aarch64", cpp_paths, cu_path, libs, "aarch64") +- +- run_cmd(f"lipo -create -output {dll_path} {dll_path}-x86_64 {dll_path}-aarch64") +- os.remove(f"{dll_path}-x86_64") +- os.remove(f"{dll_path}-aarch64") +- +- else: +- build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, machine_architecture()) ++ build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, machine_architecture()) diff --git a/pkgs/development/python-modules/warp-lang/default.nix b/pkgs/development/python-modules/warp-lang/default.nix new file mode 100644 index 000000000000..6cc8c8aaaa0c --- /dev/null +++ b/pkgs/development/python-modules/warp-lang/default.nix @@ -0,0 +1,251 @@ +{ + config, + lib, + stdenv, + buildPythonPackage, + fetchurl, + fetchFromGitHub, + replaceVars, + build, + setuptools, + numpy, + llvmPackages, + cudaPackages, + unittestCheckHook, + jax, + torch, + nix-update-script, + + # Use standalone LLVM-based JIT compiler and CPU device support + standaloneSupport ? true, + + # Use CUDA toolchain and GPU device support + cudaSupport ? config.cudaSupport, + + # Build Warp with MathDx support (requires CUDA support) + # Most linear-algebra tile operations like tile_cholesky(), tile_fft(), + # and tile_matmul() require Warp to be built with the MathDx library. + libmathdxSupport ? cudaSupport && stdenv.hostPlatform.isLinux, +}: + +let + version = "1.7.2.post1"; + + libmathdx = stdenv.mkDerivation (finalAttrs: { + pname = "libmathdx"; + version = "0.2.0"; + + src = + let + inherit (stdenv.hostPlatform) system; + selectSystem = attrs: attrs.${system} or (throw "Unsupported system: ${system}"); + + suffix = selectSystem { + x86_64-linux = "Linux-x86_64"; + aarch64-linux = "Linux-aarch64"; + x86_64-windows = "win32-x86_64"; + }; + + # nix-hash --type sha256 --to-sri $(nix-prefetch-url "https://...") + hash = selectSystem { + x86_64-linux = "sha256-Lk+PxWFvyQGRClFdmyuo4y7HBdR7pigOhMyEzajqbmg="; + aarch64-linux = "sha256-6tH9YH98kSvDiut9rQEU5potEpeKqma/QtrCHLxwRLo="; + x86_64-windows = "sha256-B8qwj7UzOXEDZh2oT3ip1qW0uqtygMsyfcbhh5Dgc8U="; + }; + in + fetchurl { + url = "https://developer.nvidia.com/downloads/compute/cublasdx/redist/cublasdx/libmathdx-${suffix}-${finalAttrs.version}.tar.gz"; + inherit hash; + }; + + unpackPhase = '' + runHook preUnpack + + mkdir unpacked + cd unpacked + tar -xzf $src + export sourceRoot=$(pwd) + + runHook postUnpack + ''; + + dontConfigure = true; + dontBuild = true; + + installPhase = '' + runHook preInstall + + cp -rT "$sourceRoot" "$out" + + runHook postInstall + ''; + + meta = { + description = "library used to integrate cuBLASDx and cuFFTDx into Warp"; + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; + license = with lib.licenses; [ + # By downloading and using the software, you agree to fully + # comply with the terms and conditions of the NVIDIA Software + # License Agreement. + ( + nvidiaCudaRedist + // { + url = "https://developer.download.nvidia.cn/compute/mathdx/License.txt"; + } + ) + + # Some of the libmathdx routines were written by or derived + # from code written by Meta Platforms, Inc. and affiliates and + # are subject to the BSD License. + bsd + ]; + platforms = with lib.platforms; linux ++ [ "x86_64-windows" ]; + maintainers = with lib.maintainers; [ yzx9 ]; + }; + }); +in +buildPythonPackage { + pname = "warp-lang"; + inherit version; + pyproject = true; + + src = fetchFromGitHub { + owner = "NVIDIA"; + repo = "warp"; + tag = "v${version}"; + hash = "sha256-cT0CrD71nNZnQMimGrmnSQl6RQx4MiUv2xBFPWNI/0s="; + }; + + patches = + lib.optionals stdenv.hostPlatform.isDarwin [ + (replaceVars ./darwin-libcxx.patch { + LIBCXX_DEV = llvmPackages.libcxx.dev; + LIBCXX_LIB = llvmPackages.libcxx; + }) + ./darwin-single-target.patch + ] + ++ lib.optionals standaloneSupport [ + (replaceVars ./standalone-llvm.patch { + LLVM_DEV = llvmPackages.llvm.dev; + LLVM_LIB = llvmPackages.llvm.lib; + LIBCLANG_DEV = llvmPackages.libclang.dev; + LIBCLANG_LIB = llvmPackages.libclang.lib; + }) + ./standalone-cxx11-abi.patch + ]; + + postPatch = + lib.optionalString (!stdenv.cc.isGNU) '' + substituteInPlace warp/build_dll.py \ + --replace-fail "g++" "${lib.getExe stdenv.cc}" + '' + # Broken tests on aarch64. Since unittest doesn't support disabling a + # single test, and pytest isn't compatible, we patch the test file directly + # instead. + # + # See: https://github.com/NVIDIA/warp/issues/552 + + lib.optionalString stdenv.hostPlatform.isAarch64 '' + substituteInPlace warp/tests/test_fem.py \ + --replace-fail "add_function_test(TestFem, \"test_integrate_gradient\", test_integrate_gradient, devices=devices)" "" + ''; + + build-system = [ + build + setuptools + ]; + + dependencies = [ + numpy + ]; + + nativeBuildInputs = lib.optionals libmathdxSupport [ + libmathdx + cudaPackages.libcublas + cudaPackages.libcufft + cudaPackages.libnvjitlink + ]; + + buildInputs = + lib.optionals standaloneSupport [ + llvmPackages.llvm + llvmPackages.clang + llvmPackages.libcxx + ] + ++ lib.optionals cudaSupport [ + cudaPackages.cudatoolkit + cudaPackages.cuda_cudart + cudaPackages.cuda_nvcc + cudaPackages.cuda_nvrtc + ]; + + preBuild = + let + buildOptions = + lib.optionals (!standaloneSupport) [ + "--no_standalone" + ] + ++ lib.optionals cudaSupport [ + "--cuda_path=${cudaPackages.cudatoolkit}" + ] + ++ lib.optionals libmathdxSupport [ + "--libmathdx" + "--libmathdx_path=${libmathdx}" + ] + ++ lib.optionals (!libmathdxSupport) [ + "--no_libmathdx" + ]; + + buildOptionString = lib.concatStringsSep " " buildOptions; + in + '' + python build_lib.py ${buildOptionString} + ''; + + pythonImportsCheck = [ + "warp" + ]; + + # Many unit tests fail with segfaults on aarch64-linux, especially in the sim + # and grad modules. However, other functionality generally works, so we don't + # mark the package as broken. + # + # See: https://www.github.com/NVIDIA/warp/issues/{356,372,552} + doCheck = !(stdenv.hostPlatform.isAarch64 && stdenv.hostPlatform.isLinux); + + nativeCheckInputs = [ + unittestCheckHook + (jax.override { inherit cudaSupport; }) + (torch.override { inherit cudaSupport; }) + + # # Disable paddlepaddle interop tests: malloc(): unaligned tcache chunk detected + # (paddlepaddle.override { inherit cudaSupport; }) + ]; + + preCheck = '' + export WARP_CACHE_PATH=$(mktemp -d) # warp.config.kernel_cache_dir + ''; + + passthru.updateScript = nix-update-script { }; + + meta = { + description = "Python framework for high performance GPU simulation and graphics"; + longDescription = '' + Warp is a Python framework for writing high-performance simulation + and graphics code. Warp takes regular Python functions and JIT + compiles them to efficient kernel code that can run on the CPU or + GPU. + + Warp is designed for spatial computing and comes with a rich set + of primitives that make it easy to write programs for physics + simulation, perception, robotics, and geometry processing. In + addition, Warp kernels are differentiable and can be used as part + of machine-learning pipelines with frameworks such as PyTorch, + JAX and Paddle. + ''; + homepage = "https://github.com/NVIDIA/warp"; + changelog = "https://github.com/NVIDIA/warp/blob/v${version}/CHANGELOG.md"; + license = lib.licenses.asl20; + platforms = with lib.platforms; linux ++ darwin; + maintainers = with lib.maintainers; [ yzx9 ]; + }; +} diff --git a/pkgs/development/python-modules/warp-lang/standalone-cxx11-abi.patch b/pkgs/development/python-modules/warp-lang/standalone-cxx11-abi.patch new file mode 100644 index 000000000000..12a23658f900 --- /dev/null +++ b/pkgs/development/python-modules/warp-lang/standalone-cxx11-abi.patch @@ -0,0 +1,25 @@ +diff --git a/build_llvm.py b/build_llvm.py +index 9d5a26a7..839909ad 100644 +--- a/build_llvm.py ++++ b/build_llvm.py +@@ -161,7 +161,6 @@ def build_from_source_for_arch(args, arch, llvm_source): + "-D", "LLVM_INCLUDE_TESTS=FALSE", + "-D", "LLVM_INCLUDE_TOOLS=TRUE", # Needed by Clang + "-D", "LLVM_INCLUDE_UTILS=FALSE", +- "-D", f"CMAKE_CXX_FLAGS=-D_GLIBCXX_USE_CXX11_ABI=0 {abi_version}", # The pre-C++11 ABI is still the default on the CentOS 7 toolchain + "-D", f"CMAKE_INSTALL_PREFIX={install_path}", + "-D", f"LLVM_HOST_TRIPLE={host_triple}", + "-D", f"CMAKE_OSX_ARCHITECTURES={osx_architectures}", +diff --git a/warp/build_dll.py b/warp/build_dll.py +index 4d411e1b..4177725b 100644 +--- a/warp/build_dll.py ++++ b/warp/build_dll.py +@@ -321,7 +321,7 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None + else: + version = "-fabi-version=13" # GCC 8.2+ + +- cpp_flags = f'{version} --std=c++17 -fno-rtti -D{cuda_enabled} -D{mathdx_enabled} -D{cuda_compat_enabled} -fPIC -fvisibility=hidden -D_GLIBCXX_USE_CXX11_ABI=0 -I"{native_dir}" {includes} ' ++ cpp_flags = f'{version} --std=c++17 -fno-rtti -D{cuda_enabled} -D{mathdx_enabled} -D{cuda_compat_enabled} -fPIC -fvisibility=hidden -I"{native_dir}" {includes} ' + + if mode == "debug": + cpp_flags += "-O0 -g -D_DEBUG -DWP_ENABLE_DEBUG=1 -fkeep-inline-functions" diff --git a/pkgs/development/python-modules/warp-lang/standalone-llvm.patch b/pkgs/development/python-modules/warp-lang/standalone-llvm.patch new file mode 100644 index 000000000000..2e90a0ebf188 --- /dev/null +++ b/pkgs/development/python-modules/warp-lang/standalone-llvm.patch @@ -0,0 +1,62 @@ +diff --git a/build_llvm.py b/build_llvm.py +index 9d5a26a7..3663e9c9 100644 +--- a/build_llvm.py ++++ b/build_llvm.py +@@ -338,25 +338,19 @@ def build_warp_clang_for_arch(args, lib_name, arch): + + clang_dll_path = os.path.join(build_path, f"bin/{lib_name}") + +- if args.build_llvm: +- # obtain Clang and LLVM libraries from the local build +- install_path = os.path.join(llvm_install_path, f"{args.mode}-{arch}") +- libpath = os.path.join(install_path, "lib") +- else: +- # obtain Clang and LLVM libraries from packman +- fetch_prebuilt_libraries(arch) +- libpath = os.path.join(base_path, f"_build/host-deps/llvm-project/release-{arch}/lib") +- ++ # obtain Clang and LLVM libraries from the local build + libs = [] +- +- for _, _, libraries in os.walk(libpath): +- libs.extend(libraries) +- break # just the top level contains library files ++ install_paths = ["@LLVM_LIB@", "@LIBCLANG_LIB@"] ++ libpaths = [os.path.join(install_path, "lib") for install_path in install_paths] ++ for libpath in libpaths: ++ for _, _, libraries in os.walk(libpath): ++ libs.extend(libraries) ++ break # just the top level contains library files + + if os.name == "nt": + libs.append("Version.lib") + libs.append("Ws2_32.lib") +- libs.append(f'/LIBPATH:"{libpath}"') ++ libs.extend(f'/LIBPATH:"{libpath}"' for libpath in libpaths) + else: + libs = [f"-l{lib[3:-2]}" for lib in libs if os.path.splitext(lib)[1] == ".a"] + if sys.platform == "darwin": +@@ -364,7 +358,8 @@ def build_warp_clang_for_arch(args, lib_name, arch): + else: + libs.insert(0, "-Wl,--start-group") + libs.append("-Wl,--end-group") +- libs.append(f"-L{libpath}") ++ libs.extend(f"-L{libpath}" for libpath in libpaths) ++ libs.append("-lz") + libs.append("-lpthread") + libs.append("-ldl") + if sys.platform != "darwin": +diff --git a/warp/build_dll.py b/warp/build_dll.py +index 4d411e1b..95fb7eaf 100644 +--- a/warp/build_dll.py ++++ b/warp/build_dll.py +@@ -311,8 +311,8 @@ def build_dll_for_arch(args, dll_path, cpp_paths, cu_path, libs, arch, mode=None + run_cmd(link_cmd) + + else: +- cpp_includes = f' -I"{warp_home_path.parent}/external/llvm-project/out/install/{mode}-{arch}/include"' +- cpp_includes += f' -I"{warp_home_path.parent}/_build/host-deps/llvm-project/release-{arch}/include"' ++ cpp_includes = ' -I"@LLVM_DEV@/include"' ++ cpp_includes += ' -I"@LIBCLANG_DEV@/include"' + cuda_includes = f' -I"{cuda_home}/include"' if cu_path else "" + includes = cpp_includes + cuda_includes diff --git a/pkgs/top-level/python-packages.nix b/pkgs/top-level/python-packages.nix index e5c695d03d59..6b8f933a6aaa 100644 --- a/pkgs/top-level/python-packages.nix +++ b/pkgs/top-level/python-packages.nix @@ -19133,6 +19133,8 @@ self: super: with self; { warlock = callPackage ../development/python-modules/warlock { }; + warp-lang = callPackage ../development/python-modules/warp-lang { }; + warrant = callPackage ../development/python-modules/warrant { }; warrant-lite = callPackage ../development/python-modules/warrant-lite { }; From f6f3549df6dc19f7b2e4587960e53f95f40d3d6a Mon Sep 17 00:00:00 2001 From: "R. Ryantm" Date: Thu, 19 Jun 2025 17:50:14 +0000 Subject: [PATCH 2/7] python3Packages.wadler-lindig: 0.1.6 -> 0.1.7 --- pkgs/development/python-modules/wadler-lindig/default.nix | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pkgs/development/python-modules/wadler-lindig/default.nix b/pkgs/development/python-modules/wadler-lindig/default.nix index ebf484a15d4d..1b14de3ce55c 100644 --- a/pkgs/development/python-modules/wadler-lindig/default.nix +++ b/pkgs/development/python-modules/wadler-lindig/default.nix @@ -13,14 +13,14 @@ buildPythonPackage rec { pname = "wadler-lindig"; - version = "0.1.6"; + version = "0.1.7"; pyproject = true; src = fetchFromGitHub { owner = "patrick-kidger"; repo = "wadler_lindig"; tag = "v${version}"; - hash = "sha256-EO47eYZk3Hr4328liDmRfCbwi5NDJ4V9NUzk3bpY9IM="; + hash = "sha256-qP826zdzR5BEQ8bGd45RFSLTH6Eal+b7UN+BW07/glo="; }; build-system = [ From acc1c0ae59106180ec63f11503d0f4bd090436c4 Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 23 Jun 2025 09:20:45 +0200 Subject: [PATCH 3/7] workflows/labels: run with app token This gives us a much higher rate limit of 12.5k requests per hour. If the app is not available, we fallback to the regular `github.token`. This can happen when testing in forks without setting up an app. --- .github/workflows/labels.yml | 27 +++++++++++++++++++++------ .github/workflows/pr.yml | 2 ++ 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 262a050797b8..7578af452f76 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -13,6 +13,9 @@ on: headBranch: required: true type: string + secrets: + NIXPKGS_CI_APP_PRIVATE_KEY: + required: true workflow_dispatch: inputs: updatedWithin: @@ -28,6 +31,8 @@ concurrency: # PR- and manually-triggered runs will be cancelled, but scheduled runs will be queued. cancel-in-progress: ${{ github.event_name != 'schedule' }} +# This is used as fallback without app only. +# This happens when testing in forks without setting up that app. permissions: issues: write # needed to create *new* labels pull-requests: write @@ -44,9 +49,18 @@ jobs: - name: Install dependencies run: npm install @actions/artifact bottleneck + # Use a GitHub App, because it has much higher rate limits: 12,500 instead of 5,000 req / hour. + - uses: actions/create-github-app-token@df432ceedc7162793a195dd1713ff69aefc7379e # v2.0.6 + if: vars.NIXPKGS_CI_APP_ID + id: app-token + with: + app-id: ${{ vars.NIXPKGS_CI_APP_ID }} + private-key: ${{ secrets.NIXPKGS_CI_APP_PRIVATE_KEY }} + permission-pull-requests: write + - name: Log current API rate limits env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} run: gh api /rate_limit | jq - name: Labels from API data and Eval results @@ -54,6 +68,7 @@ jobs: env: UPDATED_WITHIN: ${{ inputs.updatedWithin }} with: + github-token: ${{ steps.app-token.outputs.token || github.token }} script: | const Bottleneck = require('bottleneck') const path = require('node:path') @@ -272,7 +287,7 @@ jobs: - name: Log current API rate limits env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} run: gh api /rate_limit | jq - uses: actions/labeler@8558fd74291d67161a8a78ce36a881fa63b766a9 # v5.0.0 @@ -281,7 +296,7 @@ jobs: github.event_name == 'pull_request_target' && !contains(fromJSON(inputs.headBranch).type, 'development') with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ steps.app-token.outputs.token }} configuration-path: .github/labeler.yml # default sync-labels: true @@ -291,7 +306,7 @@ jobs: github.event_name == 'pull_request_target' && !contains(fromJSON(inputs.headBranch).type, 'development') with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ steps.app-token.outputs.token }} configuration-path: .github/labeler-no-sync.yml sync-labels: false @@ -304,11 +319,11 @@ jobs: github.event_name == 'pull_request_target' && contains(fromJSON(inputs.headBranch).type, 'development') with: - repo-token: ${{ secrets.GITHUB_TOKEN }} + repo-token: ${{ steps.app-token.outputs.token }} configuration-path: .github/labeler-development-branches.yml sync-labels: true - name: Log current API rate limits env: - GH_TOKEN: ${{ github.token }} + GH_TOKEN: ${{ steps.app-token.outputs.token || github.token }} run: gh api /rate_limit | jq diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 4837ae5f1fc5..d3a6d2a56a82 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -103,6 +103,8 @@ jobs: permissions: issues: write pull-requests: write + secrets: + NIXPKGS_CI_APP_PRIVATE_KEY: ${{ secrets.NIXPKGS_CI_APP_PRIVATE_KEY }} with: headBranch: ${{ needs.prepare.outputs.headBranch }} From 0c84d34f95dbd0dd15eb47a93d2464a799f0cfb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C2=B7=F0=90=91=91=F0=90=91=B4=F0=90=91=95=F0=90=91=91?= =?UTF-8?q?=F0=90=91=A9=F0=90=91=A4?= Date: Mon, 23 Jun 2025 23:36:51 +0700 Subject: [PATCH 4/7] factorPackages.buildFactorVocab: fix find directory typo --- pkgs/development/compilers/factor-lang/mk-vocab.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkgs/development/compilers/factor-lang/mk-vocab.nix b/pkgs/development/compilers/factor-lang/mk-vocab.nix index 9d5925aa6de0..3d929498fbac 100644 --- a/pkgs/development/compilers/factor-lang/mk-vocab.nix +++ b/pkgs/development/compilers/factor-lang/mk-vocab.nix @@ -41,7 +41,7 @@ drvArgs: base=$(basename "${finalAttrs.vocabName}") root=''${fname%$base} root=''${root:-.} - find "$root" -mindepth 1 -maxdepth 1 -type -d \ + find "$root" -mindepth 1 -maxdepth 1 -type d \ -not \( -name bin -or -name doc -or -name lib \) -exec \ cp -r -t "$out/lib/factor/${finalAttrs.vocabRoot}" {} \+ else From 864a6fdd7f577e2cab3c44866017b2f5ce84b5d8 Mon Sep 17 00:00:00 2001 From: Sizhe Zhao Date: Tue, 24 Jun 2025 11:13:22 +0800 Subject: [PATCH 5/7] uv: 0.7.13 -> 0.7.14 --- pkgs/by-name/uv/uv/package.nix | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkgs/by-name/uv/uv/package.nix b/pkgs/by-name/uv/uv/package.nix index 22407a8e6510..7defed8d3503 100644 --- a/pkgs/by-name/uv/uv/package.nix +++ b/pkgs/by-name/uv/uv/package.nix @@ -18,17 +18,17 @@ rustPlatform.buildRustPackage (finalAttrs: { pname = "uv"; - version = "0.7.13"; + version = "0.7.14"; src = fetchFromGitHub { owner = "astral-sh"; repo = "uv"; tag = finalAttrs.version; - hash = "sha256-/K8zTExK6G/Rrh/4g2CLS4rBbQovb6DvAL8puS7eM5w="; + hash = "sha256-RBcJuQ2NCFoNfhecR88fsKpdq0+YpvS7sSUkewIueEU="; }; useFetchCargoVendor = true; - cargoHash = "sha256-GsjBTqV7GO1NNI/3EMXN0S0TwPvdtP/PTTv6NbGa9a4="; + cargoHash = "sha256-pKANEM4XiRRRXY+AOym5mq2nrVa0iByKZ1UAkh80IrA="; buildInputs = [ rust-jemalloc-sys From fd751b2cae7edc93d8f4bf11916169aae84964aa Mon Sep 17 00:00:00 2001 From: Mathieu Rene Date: Sat, 21 Jun 2025 11:44:44 -0400 Subject: [PATCH 6/7] vscode: expose vscodeVersion as a passthru attribute --- pkgs/applications/editors/vscode/generic.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/applications/editors/vscode/generic.nix b/pkgs/applications/editors/vscode/generic.nix index be51acc0b3ac..c13d92c70251 100644 --- a/pkgs/applications/editors/vscode/generic.nix +++ b/pkgs/applications/editors/vscode/generic.nix @@ -144,6 +144,7 @@ stdenv.mkDerivation ( longName tests updateScript + vscodeVersion ; fhs = fhs { }; fhsWithPackages = f: fhs { additionalPkgs = f; }; From 24e7e47c91afc7e1c264c14c723a7f57e5241dee Mon Sep 17 00:00:00 2001 From: Wolfgang Walther Date: Mon, 23 Jun 2025 09:42:14 +0200 Subject: [PATCH 7/7] workflows/labels: dynamically adjust reservoir to remaining rate limit Instead of approximating how many requests we can still make and hoping the best that concurrent jobs won't break the bank, we can just work with the actual limits. By updating regularly, we make sure that concurrent jobs are taken into account. We always keep a reserve of 1000 requests to make sure *any* non-labeling jobs using this app will always succeed. This will allow us to easily backfill labels across multiple days, especially taking the increased rate limit for the app into account. With this, we should get up to 11.5k requests per hour in. --- .github/workflows/labels.yml | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/.github/workflows/labels.yml b/.github/workflows/labels.yml index 7578af452f76..83cf0511fc5e 100644 --- a/.github/workflows/labels.yml +++ b/.github/workflows/labels.yml @@ -33,6 +33,8 @@ concurrency: # This is used as fallback without app only. # This happens when testing in forks without setting up that app. +# Labels will most likely not exist in forks, yet. For this case, +# we add the issues permission only here. permissions: issues: write # needed to create *new* labels pull-requests: write @@ -56,6 +58,8 @@ jobs: with: app-id: ${{ vars.NIXPKGS_CI_APP_ID }} private-key: ${{ secrets.NIXPKGS_CI_APP_PRIVATE_KEY }} + # No issues: write permission here, because labels in Nixpkgs should + # be created explicitly via the UI with color and description. permission-pull-requests: write - name: Log current API rate limits @@ -89,15 +93,14 @@ jobs: const allLimits = new Bottleneck({ // Avoid concurrent requests maxConcurrent: 1, - // Hourly limit is at 5000, but other jobs need some, too! - // https://docs.github.com/en/rest/using-the-rest-api/rate-limits-for-the-rest-api - reservoir: 500, - reservoirRefreshAmount: 500, - reservoirRefreshInterval: 60 * 60 * 1000 + // Will be updated with first `updateReservoir()` call below. + reservoir: 0 }) // Pause between mutative requests const writeLimits = new Bottleneck({ minTime: 1000 }).chain(allLimits) github.hook.wrap('request', async (request, options) => { + // Requests to the /rate_limit endpoint do not count against the rate limit. + if (options.url == '/rate_limit') return request(options) stats.requests++ if (['POST', 'PUT', 'PATCH', 'DELETE'].includes(options.method)) return writeLimits.schedule(request.bind(null, options)) @@ -105,6 +108,26 @@ jobs: return allLimits.schedule(request.bind(null, options)) }) + async function updateReservoir() { + let response + try { + response = await github.rest.rateLimit.get() + } catch (err) { + core.error(`Failed updating reservoir:\n${err}`) + // Keep retrying on failed rate limit requests instead of exiting the script early. + return + } + // Always keep 1000 spare requests for other jobs to do their regular duty. + // They normally use below 100, so 1000 is *plenty* of room to work with. + const reservoir = Math.max(0, response.data.resources.core.remaining - 1000) + core.info(`Updating reservoir to: ${reservoir}`) + allLimits.updateSettings({ reservoir }) + } + await updateReservoir() + // Update remaining requests every minute to account for other jobs running in parallel. + const reservoirUpdater = setInterval(updateReservoir, 60 * 1000) + process.on('uncaughtException', () => clearInterval(reservoirUpdater)) + if (process.env.UPDATED_WITHIN && !/^\d+$/.test(process.env.UPDATED_WITHIN)) throw new Error('Please enter "updated within" as integer in hours.') @@ -284,6 +307,7 @@ jobs: .map(({ reason }) => core.setFailed(`${reason.message}\n${reason.cause.stack}`)) core.notice(`Processed ${stats.prs} PRs, made ${stats.requests + stats.artifacts} API requests and downloaded ${stats.artifacts} artifacts.`) + clearInterval(reservoirUpdater) - name: Log current API rate limits env: