From e20527b4cd479b7e7bd9030d29552135405a5f1a Mon Sep 17 00:00:00 2001 From: chn Date: Sun, 8 Oct 2023 13:33:32 +0800 Subject: [PATCH] add glad --- local/pkgs/default.nix | 3 ++- local/pkgs/glad/default.nix | 14 ++++++++++++++ local/pkgs/matplotplusplus/add-glad.patch | 13 ------------- local/pkgs/matplotplusplus/default.nix | 19 ++++--------------- 4 files changed, 20 insertions(+), 29 deletions(-) create mode 100644 local/pkgs/glad/default.nix delete mode 100644 local/pkgs/matplotplusplus/add-glad.patch diff --git a/local/pkgs/default.nix b/local/pkgs/default.nix index 4e3cb6e2..3cfe2ecf 100644 --- a/local/pkgs/default.nix +++ b/local/pkgs/default.nix @@ -28,9 +28,10 @@ concurrencpp = callPackage ./concurrencpp { stdenv = gcc13Stdenv; }; eigengdb = python3Packages.callPackage ./eigengdb {}; nodesoup = callPackage ./nodesoup {}; - matplotplusplus = callPackage ./matplotplusplus { inherit nodesoup; }; + matplotplusplus = callPackage ./matplotplusplus { inherit nodesoup glad; }; zpp-bits = callPackage ./zpp-bits {}; eigen = callPackage ./eigen {}; nameof = callPackage ./nameof {}; pslist = callPackage ./pslist {}; + glad = callPackage ./glad {}; } diff --git a/local/pkgs/glad/default.nix b/local/pkgs/glad/default.nix new file mode 100644 index 00000000..b3292e91 --- /dev/null +++ b/local/pkgs/glad/default.nix @@ -0,0 +1,14 @@ +{ lib, stdenv, fetchFromGitHub, cmake, python3 }: stdenv.mkDerivation rec +{ + pname = "glad"; + version = "0.1.36"; + src = fetchFromGitHub + { + owner = "Dav1dde"; + repo = "glad"; + rev = "v${version}"; + sha256 = "FtkPz0xchwmqE+QgS+nSJVYaAfJSTUmZsObV/IPypVQ="; + }; + cmakeFlags = [ "-DGLAD_REPRODUCIBLE=ON" "-DGLAD_INSTALL=ON" ]; + nativeBuildInputs = [ cmake python3 ]; +} diff --git a/local/pkgs/matplotplusplus/add-glad.patch b/local/pkgs/matplotplusplus/add-glad.patch deleted file mode 100644 index d974b843..00000000 --- a/local/pkgs/matplotplusplus/add-glad.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/source/matplot/CMakeLists.txt b/source/matplot/CMakeLists.txt -index fe9ad53..4007fae 100644 ---- a/source/matplot/CMakeLists.txt -+++ b/source/matplot/CMakeLists.txt -@@ -221,7 +221,7 @@ if (MATPLOTPP_BUILD_EXPERIMENTAL_OPENGL_BACKEND) - if (NOT GLAD_FOUND AND NOT TARGET glad) - # Use CPM only if not found, to avoid ODR violations - # find_package(GLAD REQUIRE) would suffice if it worked well -- FetchContent_Declare(glad GIT_REPOSITORY https://github.com/Dav1dde/glad.git GIT_TAG v0.1.36) -+ FetchContent_Declare(glad SOURCE_DIR @glad@) - FetchContent_MakeAvailable(glad) - else () - # FindGLAD does not usually create a target, so we create an interface target diff --git a/local/pkgs/matplotplusplus/default.nix b/local/pkgs/matplotplusplus/default.nix index 78d76d99..db5a85ac 100644 --- a/local/pkgs/matplotplusplus/default.nix +++ b/local/pkgs/matplotplusplus/default.nix @@ -1,17 +1,7 @@ { stdenv, fetchFromGitHub, cmake, pkg-config, substituteAll, - gnuplot, libjpeg, libtiff, zlib, libpng, lapack, blas, fftw, opencv, nodesoup, cimg, glfw, libGL, python3 -}: -let - glad = fetchFromGitHub - { - owner = "Dav1dde"; - repo = "glad"; - rev = "v0.1.36"; - sha256 = "FtkPz0xchwmqE+QgS+nSJVYaAfJSTUmZsObV/IPypVQ="; - }; - python = python3.withPackages (pythonPackages: with pythonPackages; [ glad ]); -in stdenv.mkDerivation rec + gnuplot, libjpeg, libtiff, zlib, libpng, lapack, blas, fftw, opencv, nodesoup, cimg, glfw, libGL, python3, glad +}: stdenv.mkDerivation { pname = "matplotplusplus"; version = "1.2.0"; @@ -28,7 +18,6 @@ in stdenv.mkDerivation rec "-DMATPLOTPP_WITH_SYSTEM_NODESOUP=ON" "-DMATPLOTPP_WITH_SYSTEM_CIMG=ON" "-DMATPLOTPP_BUILD_EXPERIMENTAL_OPENGL_BACKEND=ON" "-DGLAD_REPRODUCIBLE=ON" ]; - patches = [(substituteAll { src = ./add-glad.patch; inherit glad; })]; - buildInputs = [ gnuplot libjpeg libtiff zlib libpng lapack blas fftw opencv nodesoup cimg glfw libGL python ]; - nativeBuildInputs = [ cmake pkg-config python ]; + buildInputs = [ gnuplot libjpeg libtiff zlib libpng lapack blas fftw opencv nodesoup cimg glfw libGL glad ]; + nativeBuildInputs = [ cmake pkg-config python3 ]; }