From 28446cc8f3235192f3cdf913653708653cbb8e7e Mon Sep 17 00:00:00 2001 From: qbisi Date: Wed, 7 May 2025 18:37:39 +0800 Subject: [PATCH 1/6] netgen: remove unused makeWrapper --- pkgs/by-name/ne/netgen/package.nix | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkgs/by-name/ne/netgen/package.nix b/pkgs/by-name/ne/netgen/package.nix index d034a54c7fdb..2061e545d972 100644 --- a/pkgs/by-name/ne/netgen/package.nix +++ b/pkgs/by-name/ne/netgen/package.nix @@ -3,7 +3,6 @@ stdenv, fetchFromGitHub, fetchpatch2, - makeWrapper, cmake, python3Packages, mpi, @@ -85,7 +84,6 @@ stdenv.mkDerivation (finalAttrs: { nativeBuildInputs = [ cmake - makeWrapper python3Packages.pybind11-stubgen ]; From f5e610a19ec0af88cc5b35d46b5e91f145643b6e Mon Sep 17 00:00:00 2001 From: qbisi Date: Fri, 9 May 2025 01:31:35 +0800 Subject: [PATCH 2/6] netgen: add downloadPage --- pkgs/by-name/ne/netgen/package.nix | 1 + 1 file changed, 1 insertion(+) diff --git a/pkgs/by-name/ne/netgen/package.nix b/pkgs/by-name/ne/netgen/package.nix index 2061e545d972..de4677aa0233 100644 --- a/pkgs/by-name/ne/netgen/package.nix +++ b/pkgs/by-name/ne/netgen/package.nix @@ -146,6 +146,7 @@ stdenv.mkDerivation (finalAttrs: { meta = { homepage = "https://ngsolve.org"; + downloadPage = "https://github.com/NGSolve/netgen"; description = "Atomatic 3d tetrahedral mesh generator"; license = with lib.licenses; [ lgpl2Plus From ab05101f5d3292a8aa143e1ef8bd812998c15c83 Mon Sep 17 00:00:00 2001 From: qbisi Date: Wed, 7 May 2025 18:53:13 +0800 Subject: [PATCH 3/6] netgen: add pythonImportsCheckHook --- pkgs/by-name/ne/netgen/package.nix | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkgs/by-name/ne/netgen/package.nix b/pkgs/by-name/ne/netgen/package.nix index de4677aa0233..ecbb9549c654 100644 --- a/pkgs/by-name/ne/netgen/package.nix +++ b/pkgs/by-name/ne/netgen/package.nix @@ -137,9 +137,12 @@ stdenv.mkDerivation (finalAttrs: { python3Packages.pytest python3Packages.pytest-check python3Packages.pytest-mpi + python3Packages.pythonImportsCheckHook mpiCheckPhaseHook ]; + pythonImportsCheck = [ "netgen" ]; + passthru = { inherit avxSupport avx2Support avx512Support; }; From 61cacc68ceb67a70c46236f773f3c87a0fdcaa86 Mon Sep 17 00:00:00 2001 From: qbisi Date: Wed, 7 May 2025 09:53:09 +0800 Subject: [PATCH 4/6] netgen: fix check on aarch64 platform --- pkgs/by-name/ne/netgen/package.nix | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/pkgs/by-name/ne/netgen/package.nix b/pkgs/by-name/ne/netgen/package.nix index ecbb9549c654..ac448ffda1ff 100644 --- a/pkgs/by-name/ne/netgen/package.nix +++ b/pkgs/by-name/ne/netgen/package.nix @@ -73,13 +73,19 @@ stdenv.mkDerivation (finalAttrs: { # when generating python stub file utilizing system python pybind11_stubgen module # cmake need to inherit pythonpath - postPatch = '' + postPatch = + '' substituteInPlace python/CMakeLists.txt \ --replace-fail ''\'''${CMAKE_INSTALL_PREFIX}/''${NG_INSTALL_DIR_PYTHON}' \ ''\'''${CMAKE_INSTALL_PREFIX}/''${NG_INSTALL_DIR_PYTHON}:$ENV{PYTHONPATH}' substituteInPlace ng/ng.tcl ng/onetcl.cpp \ --replace-fail "libnggui" "$out/lib/libnggui" + '' + + lib.optionalString (!stdenv.hostPlatform.isx86_64) '' + # mesh generation differs on x86_64 and aarch64 platform + # test_tutorials will fail on aarch64 platform + rm tests/pytest/test_tutorials.py ''; nativeBuildInputs = [ @@ -122,9 +128,7 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeBool "ENABLE_UNIT_TESTS" finalAttrs.finalPackage.doInstallCheck) ]; - # mesh generation differs on x86_64 and aarch64 platform - # tests will fail on aarch64 platform - doInstallCheck = stdenv.hostPlatform.isx86_64; + doInstallCheck = true; preInstallCheck = '' export PYTHONPATH=$out/${python3Packages.python.sitePackages}:$PYTHONPATH From 50224aa68acf1ec85a4828069618560ec9125d77 Mon Sep 17 00:00:00 2001 From: qbisi Date: Wed, 7 May 2025 09:53:41 +0800 Subject: [PATCH 5/6] netgen: add support for darwin platform --- pkgs/by-name/ne/netgen/package.nix | 45 ++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 14 deletions(-) diff --git a/pkgs/by-name/ne/netgen/package.nix b/pkgs/by-name/ne/netgen/package.nix index ac448ffda1ff..ce12ed56b20e 100644 --- a/pkgs/by-name/ne/netgen/package.nix +++ b/pkgs/by-name/ne/netgen/package.nix @@ -65,28 +65,31 @@ stdenv.mkDerivation (finalAttrs: { url = "${patchSource}/include_stdlib.patch"; hash = "sha256-W+NgGBuy/UmzVbPTSqR8FRUlyN/9dl9l9e9rxKklmIc="; }) - (fetchpatch2 { - url = "${patchSource}/fix-version.patch"; - hash = "sha256-CT98Wq3UufB81z/jYLiH9nXvt+QzoZ7210OeuFXCfmc="; - }) ]; # when generating python stub file utilizing system python pybind11_stubgen module # cmake need to inherit pythonpath postPatch = '' - substituteInPlace python/CMakeLists.txt \ - --replace-fail ''\'''${CMAKE_INSTALL_PREFIX}/''${NG_INSTALL_DIR_PYTHON}' \ - ''\'''${CMAKE_INSTALL_PREFIX}/''${NG_INSTALL_DIR_PYTHON}:$ENV{PYTHONPATH}' + sed -i '/-DBDIR=''\'''${CMAKE_CURRENT_BINARY_DIR}/a\ + -DNETGEN_VERSION_GIT=''\'''${NETGEN_VERSION_GIT} + ' CMakeLists.txt - substituteInPlace ng/ng.tcl ng/onetcl.cpp \ - --replace-fail "libnggui" "$out/lib/libnggui" + substituteInPlace python/CMakeLists.txt \ + --replace-fail ''\'''${CMAKE_INSTALL_PREFIX}/''${NG_INSTALL_DIR_PYTHON}' \ + ''\'''${CMAKE_INSTALL_PREFIX}/''${NG_INSTALL_DIR_PYTHON}:$ENV{PYTHONPATH}' + + substituteInPlace ng/ng.tcl ng/onetcl.cpp \ + --replace-fail "libnggui" "$out/lib/libnggui" + + substituteInPlace ng/Togl2.1/CMakeLists.txt \ + --replace-fail "/usr/bin/gcc" "$CC" '' + lib.optionalString (!stdenv.hostPlatform.isx86_64) '' # mesh generation differs on x86_64 and aarch64 platform # test_tutorials will fail on aarch64 platform rm tests/pytest/test_tutorials.py - ''; + ''; nativeBuildInputs = [ cmake @@ -115,6 +118,12 @@ stdenv.mkDerivation (finalAttrs: { cmakeFlags = [ (lib.cmakeFeature "NETGEN_VERSION_GIT" "v${finalAttrs.version}-0") + (lib.cmakeFeature "NG_INSTALL_DIR_BIN" "bin") + (lib.cmakeFeature "NG_INSTALL_DIR_LIB" "lib") + (lib.cmakeFeature "NG_INSTALL_DIR_CMAKE" "lib/cmake/${finalAttrs.pname}") + (lib.cmakeFeature "NG_INSTALL_DIR_PYTHON" python3Packages.python.sitePackages) + (lib.cmakeFeature "NG_INSTALL_DIR_RES" "share") + (lib.cmakeFeature "NG_INSTALL_DIR_INCLUDE" "include") (lib.cmakeFeature "CMAKE_CXX_FLAGS" archFlags) (lib.cmakeBool "USE_MPI" true) (lib.cmakeBool "USE_MPI4PY" true) @@ -128,6 +137,17 @@ stdenv.mkDerivation (finalAttrs: { (lib.cmakeBool "ENABLE_UNIT_TESTS" finalAttrs.finalPackage.doInstallCheck) ]; + __darwinAllowLocalNetworking = true; + + postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' + rm $out/bin/{Netgen1,startup.sh} + mkdir -p $out/Applications/${finalAttrs.pname}.app/Contents/{MacOS,Resouces} + substituteInPlace $out/Info.plist --replace-fail "Netgen1" "netgen" + mv $out/Info.plist $out/Applications/${finalAttrs.pname}.app/Contents + mv $out/Netgen.icns $out/Applications/${finalAttrs.pname}.app/Contents/Resouces + ln -s $out/bin/netgen $out/Applications/${finalAttrs.pname}.app/Contents/MacOS/netgen + ''; + doInstallCheck = true; preInstallCheck = '' @@ -163,10 +183,7 @@ stdenv.mkDerivation (finalAttrs: { boost publicDomain ]; - platforms = [ - "x86_64-linux" - "aarch64-linux" - ]; + platforms = lib.platforms.unix; mainProgram = "netgen"; maintainers = with lib.maintainers; [ qbisi ]; }; From aba655ff9d9c5d844523678db1cd62185c9b3b87 Mon Sep 17 00:00:00 2001 From: qbisi Date: Fri, 9 May 2025 02:20:18 +0800 Subject: [PATCH 6/6] netgen: add desktop item for linux platform --- pkgs/by-name/ne/netgen/package.nix | 51 ++++++++++++++++++++++++------ 1 file changed, 42 insertions(+), 9 deletions(-) diff --git a/pkgs/by-name/ne/netgen/package.nix b/pkgs/by-name/ne/netgen/package.nix index ce12ed56b20e..a58e521737db 100644 --- a/pkgs/by-name/ne/netgen/package.nix +++ b/pkgs/by-name/ne/netgen/package.nix @@ -3,6 +3,10 @@ stdenv, fetchFromGitHub, fetchpatch2, + libicns, + imagemagick, + makeDesktopItem, + copyDesktopItems, cmake, python3Packages, mpi, @@ -92,9 +96,11 @@ stdenv.mkDerivation (finalAttrs: { ''; nativeBuildInputs = [ + libicns + imagemagick cmake python3Packages.pybind11-stubgen - ]; + ] ++ lib.optional stdenv.hostPlatform.isLinux copyDesktopItems; buildInputs = [ metis @@ -139,14 +145,41 @@ stdenv.mkDerivation (finalAttrs: { __darwinAllowLocalNetworking = true; - postInstall = lib.optionalString stdenv.hostPlatform.isDarwin '' - rm $out/bin/{Netgen1,startup.sh} - mkdir -p $out/Applications/${finalAttrs.pname}.app/Contents/{MacOS,Resouces} - substituteInPlace $out/Info.plist --replace-fail "Netgen1" "netgen" - mv $out/Info.plist $out/Applications/${finalAttrs.pname}.app/Contents - mv $out/Netgen.icns $out/Applications/${finalAttrs.pname}.app/Contents/Resouces - ln -s $out/bin/netgen $out/Applications/${finalAttrs.pname}.app/Contents/MacOS/netgen - ''; + desktopItems = [ + (makeDesktopItem { + name = "netgen"; + exec = "netgen"; + comment = finalAttrs.meta.description; + desktopName = "Netgen Mesh Generator"; + genericName = "3D Mesh Generator"; + categories = [ "Science" ]; + icon = "netgen"; + }) + ]; + + postInstall = + lib.optionalString stdenv.hostPlatform.isDarwin '' + rm $out/bin/{Netgen1,startup.sh} + mkdir -p $out/Applications/${finalAttrs.pname}.app/Contents/{MacOS,Resouces} + substituteInPlace $out/Info.plist --replace-fail "Netgen1" "netgen" + mv $out/Info.plist $out/Applications/${finalAttrs.pname}.app/Contents + mv $out/Netgen.icns $out/Applications/${finalAttrs.pname}.app/Contents/Resouces + ln -s $out/bin/netgen $out/Applications/${finalAttrs.pname}.app/Contents/MacOS/netgen + '' + + lib.optionalString stdenv.hostPlatform.isLinux '' + # Extract pngs from the Apple icon image and create + # the missing ones from the 512x512 image. + icns2png --extract ../netgen.icns + for size in 16 24 32 48 64 128 256 512; do + mkdir -pv $out/share/icons/hicolor/"$size"x"$size"/apps + if [ -e netgen_"$size"x"$size"x32.png ] + then + mv netgen_"$size"x"$size"x32.png $out/share/icons/hicolor/"$size"x"$size"/apps/netgen.png + else + convert -resize "$size"x"$size" netgen_512x512x32.png $out/share/icons/hicolor/"$size"x"$size"/apps/netgen.png + fi + done; + ''; doInstallCheck = true;