push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,95 @@
{
stdenv,
lib,
fetchFromGitHub,
bash,
cmake,
cfitsio,
libusb1,
kmod,
zlib,
boost,
libev,
libnova,
curl,
libjpeg,
gsl,
fftw,
gtest,
udevCheckHook,
indi-full,
}:
stdenv.mkDerivation (finalAttrs: {
pname = "indilib";
version = "2.1.5.1";
src = fetchFromGitHub {
owner = "indilib";
repo = "indi";
rev = "v${finalAttrs.version}";
hash = "sha256-mbY3iDLRcQ+pis26u6pHzB43ureaKH7KYPkV0CwHU/E=";
};
nativeBuildInputs = [
cmake
udevCheckHook
];
buildInputs = [
curl
cfitsio
libev
libusb1
zlib
boost
libnova
libjpeg
gsl
fftw
];
cmakeFlags = [
"-DCMAKE_INSTALL_LIBDIR=lib"
"-DUDEVRULES_INSTALL_DIR=lib/udev/rules.d"
]
++ lib.optional finalAttrs.finalPackage.doCheck [
"-DINDI_BUILD_UNITTESTS=ON"
"-DINDI_BUILD_INTEGTESTS=ON"
];
checkInputs = [ gtest ];
doCheck = true;
doInstallCheck = true;
# Socket address collisions between tests
enableParallelChecking = false;
postFixup = lib.optionalString stdenv.hostPlatform.isLinux ''
for f in $out/lib/udev/rules.d/*.rules
do
substituteInPlace $f --replace-quiet "/bin/sh" "${bash}/bin/sh" \
--replace-quiet "/sbin/modprobe" "${kmod}/sbin/modprobe"
done
'';
passthru.tests = {
# make sure 3rd party drivers compile with this indilib
indi-full = indi-full.override {
indilib = finalAttrs.finalPackage;
};
};
meta = with lib; {
homepage = "https://www.indilib.org/";
description = "Implementation of the INDI protocol for POSIX operating systems";
changelog = "https://github.com/indilib/indi/releases/tag/v${finalAttrs.version}";
license = licenses.lgpl2Plus;
maintainers = with maintainers; [
sheepforce
returntoreality
];
platforms = platforms.unix;
};
})

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,99 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
zlib,
eigen,
libGL,
spglib,
mmtf-cpp,
glew,
python3,
libarchive,
libmsym,
qttools,
wrapQtAppsHook,
}:
let
pythonWP = python3.withPackages (
p: with p; [
openbabel
numpy
]
);
# Pure data repositories
moleculesRepo = fetchFromGitHub {
owner = "OpenChemistry";
repo = "molecules";
tag = "1.101.0";
hash = "sha256-hMLf0gYYnQpjSGKcPy4tihNbmpRR7UxnXF/hyhforgI=";
};
crystalsRepo = fetchFromGitHub {
owner = "OpenChemistry";
repo = "crystals";
tag = "1.101.0";
hash = "sha256-WhzFldaOt/wJy1kk+ypOkw1OYFT3hqD7j5qGdq9g+IY=";
};
fragmentsRepo = fetchFromGitHub {
owner = "OpenChemistry";
repo = "fragments";
tag = "1.101.0";
hash = "sha256-x10jGl3lAEfm8OxUZJnjXRJCQg8RLQZTstjwnt5B2bw=";
};
in
stdenv.mkDerivation rec {
pname = "avogadrolibs";
version = "1.101.0";
src = fetchFromGitHub {
owner = "OpenChemistry";
repo = "avogadrolibs";
tag = version;
hash = "sha256-0DJU40Etse90rdX8xByjQeUiBsJtEQozZQQsWsc4vxk=";
};
postUnpack = ''
cp -r ${moleculesRepo} molecules
cp -r ${crystalsRepo} crystals
cp -r ${fragmentsRepo} fragments
'';
nativeBuildInputs = [
cmake
wrapQtAppsHook
pythonWP
];
buildInputs = [
eigen
zlib
libGL
spglib
mmtf-cpp
glew
libarchive
libmsym
qttools
];
# Fix the broken CMake files to use the correct paths
postInstall = ''
substituteInPlace $out/lib/cmake/avogadrolibs/AvogadroLibsConfig.cmake \
--replace "$out/" ""
substituteInPlace $out/lib/cmake/avogadrolibs/AvogadroLibsTargets.cmake \
--replace "_IMPORT_PREFIX}/$out" "_IMPORT_PREFIX}/"
'';
meta = with lib; {
description = "Molecule editor and visualizer";
maintainers = with maintainers; [ sheepforce ];
homepage = "https://github.com/OpenChemistry/avogadrolibs";
platforms = platforms.linux;
license = licenses.gpl2Only;
};
}

View File

@@ -0,0 +1,42 @@
{
lib,
stdenv,
fetchFromGitHub,
cmake,
qttools,
wrapQtAppsHook,
}:
stdenv.mkDerivation rec {
pname = "molequeue";
version = "0.9.0";
src = fetchFromGitHub {
owner = "OpenChemistry";
repo = "molequeue";
rev = version;
hash = "sha256-+NoY8YVseFyBbxc3ttFWiQuHQyy1GN8zvV1jGFjmvLg=";
};
nativeBuildInputs = [
cmake
wrapQtAppsHook
];
buildInputs = [ qttools ];
# Fix the broken CMake files to use the correct paths
postInstall = ''
substituteInPlace $out/lib/cmake/molequeue/MoleQueueConfig.cmake \
--replace "$out/" ""
'';
meta = with lib; {
description = "Desktop integration of high performance computing resources";
mainProgram = "molequeue";
maintainers = with maintainers; [ sheepforce ];
homepage = "https://github.com/OpenChemistry/molequeue";
platforms = platforms.linux;
license = licenses.bsd3;
};
}

View File

@@ -0,0 +1,13 @@
diff --git a/config/template.pc b/config/template.pc
index 3d6efbb..e338a42 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@

View File

@@ -0,0 +1,82 @@
{
stdenv,
lib,
fetchFromGitHub,
gfortran,
meson,
ninja,
cmake,
pkg-config,
mctc-lib,
mstore,
toml-f,
blas,
buildType ? "meson",
}:
assert !blas.isILP64;
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "simple-dftd3";
version = "1.2.1";
src = fetchFromGitHub {
owner = "dftd3";
repo = "simple-dftd3";
tag = "v${version}";
hash = "sha256-c4xctcMcPQ70ippqbwtinygmnZ5en6ZGF5/v0ZWtzys=";
};
patches = [
./cmake.patch
];
nativeBuildInputs = [
gfortran
pkg-config
]
++ lib.optionals (buildType == "meson") [
meson
ninja
]
++ lib.optional (buildType == "cmake") cmake;
buildInputs = [
mctc-lib
mstore
toml-f
blas
];
outputs = [
"out"
"dev"
];
cmakeFlags = [
(lib.strings.cmakeBool "BUILD_SHARED_LIBS" (!stdenv.hostPlatform.isStatic))
];
doCheck = true;
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = with lib; {
description = "Reimplementation of the DFT-D3 program";
mainProgram = "s-dftd3";
license = with licenses; [
lgpl3Only
gpl3Only
];
homepage = "https://github.com/dftd3/simple-dftd3";
platforms = platforms.linux;
maintainers = [ maintainers.sheepforce ];
};
}

View File

@@ -0,0 +1,58 @@
{
buildPythonPackage,
python,
simple-dftd3,
cffi,
numpy,
toml,
qcengine,
pyscf,
ase,
pytestCheckHook,
}:
buildPythonPackage {
format = "setuptools";
inherit (simple-dftd3)
pname
version
src
meta
;
# pytest is also required for installation, not only testing
nativeBuildInputs = [ pytestCheckHook ];
buildInputs = [ simple-dftd3 ];
propagatedBuildInputs = [
cffi
numpy
toml
];
checkInputs = [
ase
qcengine
pyscf
];
preConfigure = ''
cd python
'';
# The compiled CFFI is not placed correctly before pytest invocation
preCheck = ''
find . -name "_libdftd3*" -exec cp {} ./dftd3/. \;
'';
pythonImportsCheck = [ "dftd3" ];
doCheck = true;
# Parameters need to be present in the python site packages directory, but they
# are originally only present in the fortran package. This is a consequence of
# building the python bindings separately from the fortran library.
postInstall = ''
ln -s ${simple-dftd3}/share/s-dftd3/parameters.toml $out/${python.sitePackages}/dftd3/.
'';
}

View File

@@ -0,0 +1,31 @@
From 1885a2349102742e33c5c97a8ab4bcacc032fc70 Mon Sep 17 00:00:00 2001
From: Ryan Swart <ryan@talosystems.com>
Date: Thu, 30 Mar 2023 15:50:23 +0800
Subject: [PATCH] fix: multicharge dep needed for static compilation
---
config/meson.build | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/config/meson.build b/config/meson.build
index 4f76160..629fa5e 100644
--- a/config/meson.build
+++ b/config/meson.build
@@ -136,6 +136,14 @@ sdftd3_dep = dependency(
)
lib_deps += sdftd3_dep
+# Create multicharge library as subproject
+multicharge_dep = dependency(
+ 'multicharge',
+ fallback: ['multicharge'],
+ default_options: ['default_library=static', 'api=false', 'python=false'],
+)
+lib_deps += multicharge_dep
+
# Create TOML Fortran as subproject
tomlf_dep = dependency(
'toml-f',
--
2.39.2

View File

@@ -0,0 +1,106 @@
{
stdenv,
lib,
fetchFromGitHub,
gfortran,
buildType ? "meson",
meson,
ninja,
cmake,
pkg-config,
blas,
lapack,
mctc-lib,
mstore,
toml-f,
multicharge,
dftd4,
simple-dftd3,
python3,
}:
assert !blas.isILP64 && !lapack.isILP64;
assert (
builtins.elem buildType [
"meson"
"cmake"
]
);
stdenv.mkDerivation rec {
pname = "tblite";
version = "0.5.0";
src = fetchFromGitHub {
owner = "tblite";
repo = "tblite";
rev = "v${version}";
hash = "sha256-hePy/slEeM2o1gtrAbq/nkEUILa6oQjkD2ddDstQ2Zc=";
};
patches = [
./0001-fix-multicharge-dep-needed-for-static-compilation.patch
# Fix wrong paths in pkg-config file
./pkgconfig.patch
];
# Python scripts in test subdirectories to run the tests
postPatch = ''
patchShebangs ./
'';
nativeBuildInputs = [
gfortran
pkg-config
]
++ lib.optionals (buildType == "meson") [
meson
ninja
]
++ lib.optionals (buildType == "cmake") [
cmake
];
buildInputs = [
blas
lapack
mctc-lib
mstore
toml-f
multicharge
dftd4
simple-dftd3
];
outputs = [
"out"
"dev"
];
checkInputs = [
python3
];
checkFlags = [
"-j1" # Tests hang when multiple are run in parallel
];
doCheck = buildType == "meson";
preCheck = ''
export OMP_NUM_THREADS=2
'';
meta = with lib; {
description = "Light-weight tight-binding framework";
mainProgram = "tblite";
license = with licenses; [
gpl3Plus
lgpl3Plus
];
homepage = "https://github.com/tblite/tblite";
platforms = platforms.linux;
maintainers = [ maintainers.sheepforce ];
};
}

View File

@@ -0,0 +1,13 @@
diff --git a/config/template.pc b/config/template.pc
index 3d6efbb..e338a42 100644
--- a/config/template.pc
+++ b/config/template.pc
@@ -1,6 +1,6 @@
prefix=@CMAKE_INSTALL_PREFIX@
-libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@
-includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@
+libdir=@CMAKE_INSTALL_FULL_LIBDIR@
+includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: @PROJECT_DESCRIPTION@

View File

@@ -0,0 +1,69 @@
{
buildPythonPackage,
meson,
ninja,
pkg-config,
tblite,
numpy,
simple-dftd3,
cffi,
gfortran,
blas,
lapack,
mctc-lib,
mstore,
toml-f,
multicharge,
dftd4,
setuptools,
}:
buildPythonPackage {
inherit (tblite)
pname
version
src
meta
;
nativeBuildInputs = [
tblite
meson
ninja
pkg-config
gfortran
mctc-lib
setuptools
];
buildInputs = [
tblite
simple-dftd3
blas
lapack
mctc-lib
mstore
toml-f
multicharge
dftd4
];
propagatedBuildInputs = [
tblite
simple-dftd3
cffi
numpy
];
patches = [
# Add multicharge to the meson deps; otherwise we get missing mod_multicharge errors
./0001-fix-multicharge-dep-needed-for-static-compilation.patch
];
format = "other";
pythonImportsCheck = [
"tblite"
"tblite.interface"
];
mesonFlags = [ "-Dpython=true" ];
}

View File

@@ -0,0 +1,118 @@
{
callPackage,
stdenv,
fetchzip,
lib,
libcxx,
llvmPackages,
config,
addDriverRunpath,
patchelf,
fixDarwinDylibNames,
cudaSupport ? config.cudaSupport,
}:
let
# The binary libtorch distribution statically links the CUDA
# toolkit. This means that we do not need to provide CUDA to
# this derivation. However, we should ensure on version bumps
# that the CUDA toolkit for `passthru.tests` is still
# up-to-date.
version = "2.5.0";
device = if cudaSupport then "cuda" else "cpu";
srcs = import ./binary-hashes.nix version;
unavailable = throw "libtorch is not available for this platform";
in
stdenv.mkDerivation {
inherit version;
pname = "libtorch";
src = fetchzip srcs."${stdenv.hostPlatform.system}-${device}" or unavailable;
nativeBuildInputs =
if stdenv.hostPlatform.isDarwin then
[ fixDarwinDylibNames ]
else
[ patchelf ] ++ lib.optionals cudaSupport [ addDriverRunpath ];
dontBuild = true;
dontConfigure = true;
dontStrip = true;
installPhase = ''
# Copy headers and CMake files.
mkdir -p $dev
cp -r include $dev
cp -r share $dev
install -Dm755 -t $out/lib lib/*${stdenv.hostPlatform.extensions.sharedLibrary}*
# We do not care about Java support...
rm -f $out/lib/lib*jni* 2> /dev/null || true
# Fix up library paths for split outputs
substituteInPlace $dev/share/cmake/Torch/TorchConfig.cmake \
--replace \''${TORCH_INSTALL_PREFIX}/lib "$out/lib" \
substituteInPlace \
$dev/share/cmake/Caffe2/Caffe2Targets-release.cmake \
--replace \''${_IMPORT_PREFIX}/lib "$out/lib" \
'';
postFixup =
let
rpath = lib.makeLibraryPath [ stdenv.cc.cc ];
in
lib.optionalString stdenv.hostPlatform.isLinux ''
find $out/lib -type f \( -name '*.so' -or -name '*.so.*' \) | while read lib; do
echo "setting rpath for $lib..."
patchelf --set-rpath "${rpath}:$out/lib" "$lib"
${lib.optionalString cudaSupport ''
addDriverRunpath "$lib"
''}
done
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
for f in $out/lib/*.dylib; do
otool -L $f
done
for f in $out/lib/*.dylib; do
if otool -L $f | grep "@rpath/libomp.dylib" >& /dev/null; then
install_name_tool -change "@rpath/libomp.dylib" ${llvmPackages.openmp}/lib/libomp.dylib $f
fi
install_name_tool -id $out/lib/$(basename $f) $f || true
for rpath in $(otool -L $f | grep rpath | awk '{print $1}');do
install_name_tool -change $rpath $out/lib/$(basename $rpath) $f
done
done
for f in $out/lib/*.dylib; do
otool -L $f
done
'';
outputs = [
"out"
"dev"
];
passthru.tests.cmake = callPackage ./test {
inherit cudaSupport;
};
meta = with lib; {
description = "C++ API of the PyTorch machine learning framework";
homepage = "https://pytorch.org/";
sourceProvenance = with sourceTypes; [ binaryNativeCode ];
# Includes CUDA and Intel MKL, but redistributions of the binary are not limited.
# https://docs.nvidia.com/cuda/eula/index.html
# https://www.intel.com/content/www/us/en/developer/articles/license/onemkl-license-faq.html
license = licenses.bsd3;
maintainers = with maintainers; [ junjihashimoto ];
platforms = [
"aarch64-darwin"
"x86_64-linux"
];
};
}

View File

@@ -0,0 +1,20 @@
version:
builtins.getAttr version {
"2.5.0" = {
aarch64-darwin-cpu = {
name = "libtorch-macos-arm64-2.5.0.zip";
url = "https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.5.0.zip";
hash = "sha256-4d9YKUuvAESBeG/WCUsQfEHwdB2z34grnlwWslj4970=";
};
x86_64-linux-cpu = {
name = "libtorch-cxx11-abi-shared-with-deps-2.5.0-cpu.zip";
url = "https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.5.0%2Bcpu.zip";
hash = "sha256-gUzPhc4Z8rTPhIm89pPoLP0Ww17ono+/xgMW46E/Tro=";
};
x86_64-linux-cuda = {
name = "libtorch-cxx11-abi-shared-with-deps-2.5.0-cu124.zip";
url = "https://download.pytorch.org/libtorch/cu124/libtorch-cxx11-abi-shared-with-deps-2.5.0%2Bcu124.zip";
hash = "sha256-UaX47GAwyZ6UmzgY85TeAHmy3u52pBHhiyM5NAz7ens=";
};
};
}

View File

@@ -0,0 +1,38 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p nix-prefetch-scripts
set -eou pipefail
version=$1
bucket="https://download.pytorch.org/libtorch"
CUDA_VERSION=cu124
url_and_key_list=(
"aarch64-darwin-cpu $bucket/cpu/libtorch-macos-arm64-${version}.zip libtorch-macos-arm64-${version}.zip"
"x86_64-linux-cpu $bucket/cpu/libtorch-cxx11-abi-shared-with-deps-${version}%2Bcpu.zip libtorch-cxx11-abi-shared-with-deps-${version}-cpu.zip"
"x86_64-linux-cuda $bucket/${CUDA_VERSION}/libtorch-cxx11-abi-shared-with-deps-${version}%2B${CUDA_VERSION}.zip libtorch-cxx11-abi-shared-with-deps-${version}-${CUDA_VERSION}.zip"
)
hashfile="binary-hashes-$version.nix"
echo " \"$version\" = {" >> $hashfile
for url_and_key in "${url_and_key_list[@]}"; do
key=$(echo "$url_and_key" | cut -d' ' -f1)
url=$(echo "$url_and_key" | cut -d' ' -f2)
name=$(echo "$url_and_key" | cut -d' ' -f3)
echo "prefetching ${url}..."
hash=$(nix --extra-experimental-features nix-command hash to-sri --type sha256 $(nix-prefetch-url --unpack "$url" --name "$name"))
echo " $key = {" >> $hashfile
echo " name = \"$name\";" >> $hashfile
echo " url = \"$url\";" >> $hashfile
echo " hash = \"$hash\";" >> $hashfile
echo " };" >> $hashfile
echo
done
echo " };" >> $hashfile
echo "done."

View File

@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.0)
find_package(Torch REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TORCH_CXX_FLAGS}")
add_executable(test test.cpp)
target_link_libraries(test "${TORCH_LIBRARIES}")

View File

@@ -0,0 +1,64 @@
{
lib,
stdenv,
cmake,
libtorch-bin,
linkFarm,
symlinkJoin,
cudaSupport,
cudaPackages ? { },
}:
let
inherit (cudaPackages) cudatoolkit cudnn;
cudatoolkit_joined = symlinkJoin {
name = "${cudatoolkit.name}-unsplit";
paths = [
cudatoolkit.out
cudatoolkit.lib
];
};
# We do not have access to /run/opengl-driver/lib in the sandbox,
# so use a stub instead.
cudaStub = linkFarm "cuda-stub" [
{
name = "libcuda.so.1";
path = "${cudatoolkit}/lib/stubs/libcuda.so";
}
];
in
stdenv.mkDerivation {
pname = "libtorch-test";
version = libtorch-bin.version;
src = lib.fileset.toSource {
root = ./.;
fileset = lib.fileset.unions [
./CMakeLists.txt
./test.cpp
];
};
nativeBuildInputs = [ cmake ];
buildInputs = [ libtorch-bin ] ++ lib.optionals cudaSupport [ cudnn ];
cmakeFlags = lib.optionals cudaSupport [ "-DCUDA_TOOLKIT_ROOT_DIR=${cudatoolkit_joined}" ];
doCheck = true;
installPhase = ''
touch $out
'';
checkPhase =
lib.optionalString cudaSupport ''
LD_LIBRARY_PATH=${cudaStub}''${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH \
''
+ ''
./test
'';
}

View File

@@ -0,0 +1,20 @@
#undef NDEBUG
#include <cassert>
#include <iostream>
#include <torch/torch.h>
int main() {
torch::Tensor tensor = torch::eye(3);
float checkData[] = {
1, 0, 0,
0, 1, 0,
0, 0, 1
};
torch::Tensor check = torch::from_blob(checkData, {3, 3});
assert(tensor.allclose(check));
}

View File

@@ -0,0 +1,344 @@
{
lib,
stdenv,
fetchFromGitHub,
perl,
which,
# Most packages depending on openblas expect integer width to match
# pointer width, but some expect to use 32-bit integers always
# (for compatibility with reference BLAS).
blas64 ? null,
# Multi-threaded applications must not call a threaded OpenBLAS
# (the only exception is when an application uses OpenMP as its
# *only* form of multi-threading). See
# https://github.com/OpenMathLib/OpenBLAS/wiki/Faq/4bded95e8dc8aadc70ce65267d1093ca7bdefc4c#multi-threaded
# https://github.com/OpenMathLib/OpenBLAS/issues/2543
# This flag builds a single-threaded OpenBLAS using the flags
# stated in thre.
singleThreaded ? false,
buildPackages,
# Select a specific optimization target (other than the default)
# See https://github.com/OpenMathLib/OpenBLAS/blob/develop/TargetList.txt
target ? null,
# Select whether DYNAMIC_ARCH is enabled or not.
dynamicArch ? null,
# enable AVX512 optimized kernels.
# These kernels have been a source of trouble in the past.
# Use with caution.
enableAVX512 ? false,
enableStatic ? stdenv.hostPlatform.isStatic,
enableShared ? !stdenv.hostPlatform.isStatic,
# for passthru.tests
ceres-solver,
giac,
octave,
opencv,
python3,
openmp ? null,
}:
let
blas64_ = blas64;
in
let
setTarget = x: if target == null then x else target;
setDynamicArch = x: if dynamicArch == null then x else dynamicArch;
# To add support for a new platform, add an element to this set.
configs = {
armv6l-linux = {
BINARY = 32;
TARGET = setTarget "ARMV6";
DYNAMIC_ARCH = setDynamicArch false;
USE_OPENMP = true;
};
armv7l-linux = {
BINARY = 32;
TARGET = setTarget "ARMV7";
DYNAMIC_ARCH = setDynamicArch false;
USE_OPENMP = true;
};
aarch64-darwin = {
BINARY = 64;
TARGET = setTarget "VORTEX";
DYNAMIC_ARCH = setDynamicArch true;
USE_OPENMP = false;
MACOSX_DEPLOYMENT_TARGET = "11.0";
};
aarch64-linux = {
BINARY = 64;
TARGET = setTarget "ARMV8";
DYNAMIC_ARCH = setDynamicArch true;
USE_OPENMP = true;
};
i686-linux = {
BINARY = 32;
TARGET = setTarget "P2";
DYNAMIC_ARCH = setDynamicArch true;
USE_OPENMP = true;
};
x86_64-darwin = {
BINARY = 64;
TARGET = setTarget "ATHLON";
DYNAMIC_ARCH = setDynamicArch true;
NO_AVX512 = !enableAVX512;
USE_OPENMP = false;
MACOSX_DEPLOYMENT_TARGET = "10.7";
};
x86_64-linux = {
BINARY = 64;
TARGET = setTarget "ATHLON";
DYNAMIC_ARCH = setDynamicArch true;
NO_AVX512 = !enableAVX512;
USE_OPENMP = !stdenv.hostPlatform.isMusl;
};
x86_64-windows = {
BINARY = 64;
TARGET = setTarget "ATHLON";
DYNAMIC_ARCH = setDynamicArch true;
NO_AVX512 = !enableAVX512;
USE_OPENMP = false;
};
powerpc64-linux = {
BINARY = 64;
TARGET = setTarget "POWER4";
DYNAMIC_ARCH = setDynamicArch false;
USE_OPENMP = !stdenv.hostPlatform.isMusl;
};
powerpc64le-linux = {
BINARY = 64;
TARGET = setTarget "POWER5";
DYNAMIC_ARCH = setDynamicArch true;
USE_OPENMP = !stdenv.hostPlatform.isMusl;
};
riscv64-linux = {
BINARY = 64;
TARGET = setTarget "RISCV64_GENERIC";
DYNAMIC_ARCH = setDynamicArch false;
USE_OPENMP = true;
};
loongarch64-linux = {
TARGET = setTarget "LA64_GENERIC";
DYNAMIC_ARCH = setDynamicArch false;
USE_OPENMP = true;
};
s390x-linux = {
BINARY = 64;
TARGET = setTarget "ZARCH_GENERIC";
DYNAMIC_ARCH = setDynamicArch true;
USE_OPENMP = true;
};
x86_64-freebsd = {
BINARY = 64;
TARGET = setTarget "ATHLON";
DYNAMIC_ARCH = setDynamicArch true;
NO_AVX512 = !enableAVX512;
USE_OPENMP = true;
};
};
in
let
config =
configs.${stdenv.hostPlatform.system}
or (throw "unsupported system: ${stdenv.hostPlatform.system}");
in
let
blas64 = if blas64_ != null then blas64_ else lib.hasPrefix "x86_64" stdenv.hostPlatform.system;
# Convert flag values to format OpenBLAS's build expects.
# `toString` is almost what we need other than bools,
# which we need to map {true -> 1, false -> 0}
# (`toString` produces empty string `""` for false instead of `0`)
mkMakeFlagValue =
val:
if !builtins.isBool val then
toString val
else if val then
"1"
else
"0";
mkMakeFlagsFromConfig = lib.mapAttrsToList (var: val: "${var}=${mkMakeFlagValue val}");
shlibExt = stdenv.hostPlatform.extensions.sharedLibrary;
in
stdenv.mkDerivation rec {
pname = "openblas";
version = "0.3.30";
outputs = [
"out"
"dev"
];
src = fetchFromGitHub {
owner = "OpenMathLib";
repo = "OpenBLAS";
rev = "v${version}";
hash = "sha256-foP2OXUL6ttgYvCxLsxUiVdkPoTvGiHomdNudbSUmSE=";
};
patches = [
# Remove this once https://github.com/OpenMathLib/OpenBLAS/issues/5414 is
# resolved.
./disable-sme-sgemm-kernel.patch
];
postPatch = ''
# cc1: error: invalid feature modifier 'sve2' in '-march=armv8.5-a+sve+sve2+bf16'
substituteInPlace Makefile.arm64 --replace "+sve2+bf16" ""
'';
inherit blas64;
# Some hardening features are disabled due to sporadic failures in
# OpenBLAS-based programs. The problem may not be with OpenBLAS itself, but
# with how these flags interact with hardening measures used downstream.
# In either case, OpenBLAS must only be used by trusted code--it is
# inherently unsuitable for security-conscious applications--so there should
# be no objection to disabling these hardening measures.
hardeningDisable = [
# don't modify or move the stack
"stackprotector"
"pic"
# don't alter index arithmetic
"strictoverflow"
# don't interfere with dynamic target detection
"relro"
"bindnow"
]
++ lib.optionals stdenv.hostPlatform.isAarch64 [
# "__builtin_clear_padding not supported for variable length aggregates"
# in aarch64-specific code
"trivialautovarinit"
];
nativeBuildInputs = [
perl
which
];
buildInputs = lib.optional (stdenv.cc.isClang && config.USE_OPENMP) openmp;
depsBuildBuild = [
buildPackages.gfortran
buildPackages.stdenv.cc
];
enableParallelBuilding = true;
makeFlags = mkMakeFlagsFromConfig (
config
// {
FC = "${stdenv.cc.targetPrefix}gfortran";
CC = "${stdenv.cc.targetPrefix}${if stdenv.cc.isClang then "clang" else "cc"}";
PREFIX = placeholder "out";
OPENBLAS_INCLUDE_DIR = "${placeholder "dev"}/include";
NUM_THREADS = 64;
INTERFACE64 = blas64;
NO_STATIC = !enableStatic;
NO_SHARED = !enableShared;
CROSS = stdenv.hostPlatform != stdenv.buildPlatform;
HOSTCC = "cc";
# Makefile.system only checks defined status
# This seems to be a bug in the openblas Makefile:
# on x86_64 it expects NO_BINARY_MODE=
# but on aarch64 it expects NO_BINARY_MODE=0
NO_BINARY_MODE =
if stdenv.hostPlatform.isx86_64 then
toString (stdenv.hostPlatform != stdenv.buildPlatform)
else
stdenv.hostPlatform != stdenv.buildPlatform;
# This disables automatic build job count detection (which honours neither enableParallelBuilding nor NIX_BUILD_CORES)
# and uses the main make invocation's job count, falling back to 1 if no parallelism is used.
# https://github.com/OpenMathLib/OpenBLAS/blob/v0.3.20/getarch.c#L1781-L1792
MAKE_NB_JOBS = 0;
}
// (lib.optionalAttrs stdenv.cc.isClang {
LDFLAGS = "-L${lib.getLib buildPackages.gfortran.cc}/lib"; # contains `libgfortran.so`; building with clang needs this, gcc has it implicit
})
// (lib.optionalAttrs singleThreaded {
# As described on https://github.com/OpenMathLib/OpenBLAS/wiki/Faq/4bded95e8dc8aadc70ce65267d1093ca7bdefc4c#multi-threaded
USE_THREAD = false;
USE_LOCKING = true; # available with openblas >= 0.3.7
USE_OPENMP = false; # openblas will refuse building with both USE_OPENMP=1 and USE_THREAD=0
})
);
# The default "all" target unconditionally builds the "tests" target.
buildFlags = lib.optionals (!doCheck) [ "shared" ];
doCheck = true;
checkTarget = "tests";
postInstall = ''
# Write pkgconfig aliases. Upstream report:
# https://github.com/OpenMathLib/OpenBLAS/issues/1740
for alias in blas cblas lapack; do
cat <<EOF > $out/lib/pkgconfig/$alias.pc
Name: $alias
Version: ${version}
Description: $alias provided by the OpenBLAS package.
Cflags: -I$dev/include
Libs: -L$out/lib -lopenblas
EOF
done
# Setup symlinks for blas / lapack
''
+ lib.optionalString stdenv.hostPlatform.isMinGW ''
ln -s $out/bin/*.dll $out/lib
''
+ lib.optionalString enableShared ''
ln -s $out/lib/libopenblas${shlibExt} $out/lib/libblas${shlibExt}
ln -s $out/lib/libopenblas${shlibExt} $out/lib/libcblas${shlibExt}
ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapack${shlibExt}
ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapacke${shlibExt}
''
+ lib.optionalString (stdenv.hostPlatform.isLinux && enableShared) ''
ln -s $out/lib/libopenblas${shlibExt} $out/lib/libblas${shlibExt}.3
ln -s $out/lib/libopenblas${shlibExt} $out/lib/libcblas${shlibExt}.3
ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapack${shlibExt}.3
ln -s $out/lib/libopenblas${shlibExt} $out/lib/liblapacke${shlibExt}.3
''
+ lib.optionalString enableStatic ''
ln -s $out/lib/libopenblas.a $out/lib/libblas.a
ln -s $out/lib/libopenblas.a $out/lib/libcblas.a
ln -s $out/lib/libopenblas.a $out/lib/liblapack.a
ln -s $out/lib/libopenblas.a $out/lib/liblapacke.a
'';
passthru.tests = {
inherit (python3.pkgs) numpy scipy scikit-learn;
inherit
ceres-solver
giac
octave
opencv
;
};
meta = with lib; {
description = "Basic Linear Algebra Subprograms";
license = licenses.bsd3;
homepage = "https://github.com/OpenMathLib/OpenBLAS";
platforms = attrNames configs;
maintainers = with maintainers; [ ttuegel ];
};
}

View File

@@ -0,0 +1,13 @@
diff --git a/interface/gemm.c b/interface/gemm.c
index c5182c266..7056422e1 100644
--- a/interface/gemm.c
+++ b/interface/gemm.c
@@ -436,7 +436,7 @@ void CNAME(enum CBLAS_ORDER order, enum CBLAS_TRANSPOSE TransA, enum CBLAS_TRANS
#endif
#if defined(ARCH_ARM64) && (defined(USE_SGEMM_KERNEL_DIRECT)||defined(DYNAMIC_ARCH))
#if defined(DYNAMIC_ARCH)
- if (support_sme1())
+ if (false)
#endif
if (beta == 0 && alpha == 1.0 && order == CblasRowMajor && TransA == CblasNoTrans && TransB == CblasNoTrans) {
SGEMM_DIRECT(m, n, k, a, lda, b, ldb, c, ldc);

View File

@@ -0,0 +1,121 @@
{
lib,
stdenv,
fetchFromGitHub,
gfortran,
blas,
lapack,
metis,
fixDarwinDylibNames,
gmp,
mpfr,
config,
enableCuda ? config.cudaSupport,
cudaPackages,
openmp ? null,
}@inputs:
let
stdenv = throw "Use effectiveStdenv instead";
effectiveStdenv = if enableCuda then cudaPackages.backendStdenv else inputs.stdenv;
in
effectiveStdenv.mkDerivation rec {
pname = "suitesparse";
version = "5.13.0";
outputs = [
"out"
"dev"
"doc"
];
src = fetchFromGitHub {
owner = "DrTimothyAldenDavis";
repo = "SuiteSparse";
rev = "v${version}";
sha256 = "sha256-Anen1YtXsSPhk8DpA4JtADIz9m8oXFl9umlkb4iImf8=";
};
nativeBuildInputs = [
]
++ lib.optionals effectiveStdenv.hostPlatform.isDarwin [
fixDarwinDylibNames
]
++ lib.optionals enableCuda [
cudaPackages.cuda_nvcc
];
# Use compatible indexing for lapack and blas used
buildInputs =
assert (blas.isILP64 == lapack.isILP64);
[
blas
lapack
metis
(lib.getLib gfortran.cc)
gmp
mpfr
]
++ lib.optionals effectiveStdenv.cc.isClang [
openmp
]
++ lib.optionals enableCuda [
cudaPackages.cuda_cudart
cudaPackages.cuda_cccl
cudaPackages.libcublas
];
preConfigure = ''
# Mongoose and GraphBLAS are packaged separately
sed -i "Makefile" -e '/GraphBLAS\|Mongoose/d'
'';
makeFlags = [
"INSTALL=${placeholder "out"}"
"INSTALL_INCLUDE=${placeholder "dev"}/include"
"JOBS=$(NIX_BUILD_CORES)"
"MY_METIS_LIB=-lmetis"
]
++ lib.optionals blas.isILP64 [
"CFLAGS=-DBLAS64"
]
++ lib.optionals enableCuda [
"CUDA_PATH=${cudaPackages.cuda_nvcc}"
"CUDART_LIB=${lib.getLib cudaPackages.cuda_cudart}/lib/libcudart.so"
"CUBLAS_LIB=${lib.getLib cudaPackages.libcublas}/lib/libcublas.so"
]
++ lib.optionals effectiveStdenv.hostPlatform.isDarwin [
# Unless these are set, the build will attempt to use `Accelerate` on darwin, see:
# https://github.com/DrTimothyAldenDavis/SuiteSparse/blob/v5.13.0/SuiteSparse_config/SuiteSparse_config.mk#L368
"BLAS=-lblas"
"LAPACK=-llapack"
];
env = {
# in GCC14 these two warnings were promoted to error
# let's make them warnings again to fix the build failure
NIX_CFLAGS_COMPILE = "-Wno-error=implicit-function-declaration -Wno-error=incompatible-pointer-types";
}
// lib.optionalAttrs effectiveStdenv.hostPlatform.isDarwin {
# Ensure that there is enough space for the `fixDarwinDylibNames` hook to
# update the install names of the output dylibs.
NIX_LDFLAGS = "-headerpad_max_install_names";
};
buildFlags = [
# Build individual shared libraries, not demos
"library"
];
meta = with lib; {
homepage = "http://faculty.cse.tamu.edu/davis/suitesparse.html";
description = "Suite of sparse matrix algorithms";
license = with licenses; [
bsd2
gpl2Plus
lgpl21Plus
];
maintainers = with maintainers; [ ttuegel ];
platforms = with platforms; unix;
};
}