From 4bbec8c443077492947a54e25411718457284a80 Mon Sep 17 00:00:00 2001 From: wxt <3264117476@qq.com> Date: Mon, 23 Sep 2024 15:39:04 +0800 Subject: [PATCH 1/2] gmt: move to by-name; run nixfmt; dcw-gmt: move to by-name; run nixfmt; gshhg-gis: move to by-name; run nixfmt --- .../dc/dcw-gmt/package.nix} | 12 ++-- .../gm/gmt/package.nix} | 66 +++++++++---------- .../gs/gshhg-gmt/package.nix} | 12 ++-- pkgs/top-level/all-packages.nix | 9 --- 4 files changed, 47 insertions(+), 52 deletions(-) rename pkgs/{applications/gis/gmt/dcw.nix => by-name/dc/dcw-gmt/package.nix} (87%) rename pkgs/{applications/gis/gmt/default.nix => by-name/gm/gmt/package.nix} (65%) rename pkgs/{applications/gis/gmt/gshhg.nix => by-name/gs/gshhg-gmt/package.nix} (86%) diff --git a/pkgs/applications/gis/gmt/dcw.nix b/pkgs/by-name/dc/dcw-gmt/package.nix similarity index 87% rename from pkgs/applications/gis/gmt/dcw.nix rename to pkgs/by-name/dc/dcw-gmt/package.nix index 092e86edcb66..efa697b2926a 100644 --- a/pkgs/applications/gis/gmt/dcw.nix +++ b/pkgs/by-name/dc/dcw-gmt/package.nix @@ -1,10 +1,14 @@ -{ lib, stdenv, fetchurl }: +{ + lib, + stdenv, + fetchurl, +}: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "dcw-gmt"; version = "2.1.2"; src = fetchurl { - url = "ftp://ftp.soest.hawaii.edu/gmt/dcw-gmt-${version}.tar.gz"; + url = "ftp://ftp.soest.hawaii.edu/gmt/dcw-gmt-${finalAttrs.version}.tar.gz"; sha256 = "sha256-S7hA0HXIuj4UrrQc8XwkI2v/eHVmMU+f91irmXd0XZk="; }; @@ -29,4 +33,4 @@ stdenv.mkDerivation rec { maintainers = lib.teams.geospatial.members ++ (with lib.maintainers; [ tviti ]); }; -} +}) diff --git a/pkgs/applications/gis/gmt/default.nix b/pkgs/by-name/gm/gmt/package.nix similarity index 65% rename from pkgs/applications/gis/gmt/default.nix rename to pkgs/by-name/gm/gmt/package.nix index 2f2528ff5bb9..afd1464aeba6 100644 --- a/pkgs/applications/gis/gmt/default.nix +++ b/pkgs/by-name/gm/gmt/package.nix @@ -1,15 +1,12 @@ { lib, stdenv, - fetchFromGitHub, + fetchurl, cmake, curl, - Accelerate, - CoreGraphics, - CoreVideo, + darwin, fftwSinglePrec, netcdf, - libxml2, pcre, gdal, blas, @@ -19,46 +16,34 @@ dcw-gmt, gshhg-gmt, }: - /* The onus is on the user to also install: - ffmpeg for webm or mp4 output - graphicsmagick for gif output */ -let - # Certainly not an ideal situation, See: - # https://github.com/NixOS/nixpkgs/pull/340707#issuecomment-2361894717 - netcdf' = netcdf.override { - libxml2 = libxml2.override { - enableHttp = true; - }; - }; -in stdenv.mkDerivation (finalAttrs: { +stdenv.mkDerivation (finalAttrs: { pname = "gmt"; - version = "6.5.0"; - src = fetchFromGitHub { - owner = "GenericMappingTools"; - repo = "gmt"; - rev = "refs/tags/${finalAttrs.version}"; - hash = "sha256-KKIYhljCtk9t9CuvTLsSGvUkUwazWTm9ymBB3wLwSoI="; + version = "6.4.0"; + src = fetchurl { + url = "https://github.com/GenericMappingTools/gmt/releases/download/${finalAttrs.version}/gmt-${finalAttrs.version}-src.tar.gz"; + sha256 = "sha256-0mfAx9b7MMnqfgKe8n2tsm/9e5LLS0cD+aO6Do85Ohs="; }; - nativeBuildInputs = [ - cmake - ]; + nativeBuildInputs = [ cmake ]; buildInputs = [ curl gdal - netcdf' + netcdf pcre dcw-gmt gshhg-gmt ] ++ ( - if stdenv.hostPlatform.isDarwin then + if stdenv.isDarwin then + with darwin.apple_sdk.frameworks; [ Accelerate CoreGraphics @@ -73,9 +58,7 @@ in stdenv.mkDerivation (finalAttrs: { ] ); - propagatedBuildInputs = [ - ghostscript - ]; + propagatedBuildInputs = [ ghostscript ]; cmakeFlags = [ @@ -86,13 +69,24 @@ in stdenv.mkDerivation (finalAttrs: { "-DGSHHG_ROOT=${gshhg-gmt.out}/share/gshhg-gmt" "-DCOPY_DCW:BOOL=FALSE" "-DDCW_ROOT=${dcw-gmt.out}/share/dcw-gmt" + "-DGDAL_ROOT=${gdal.out}" + "-DNETCDF_ROOT=${netcdf.out}" + "-DPCRE_ROOT=${pcre.out}" "-DGMT_INSTALL_TRADITIONAL_FOLDERNAMES:BOOL=FALSE" "-DGMT_ENABLE_OPENMP:BOOL=TRUE" "-DGMT_INSTALL_MODULE_LINKS:BOOL=FALSE" "-DLICENSE_RESTRICTED=LGPL" # "GPL" and "no" also valid - ]; + ] + ++ ( + with stdenv; + lib.optionals (!isDarwin) [ + "-DFFTW3_ROOT=${fftwSinglePrec.dev}" + "-DLAPACK_LIBRARY=${lapack}/lib/liblapack.so" + "-DBLAS_LIBRARY=${blas}/lib/libblas.so" + ] + ); - meta = { + meta = with lib; { homepage = "https://www.generic-mapping-tools.org"; description = "Tools for manipulating geographic and cartesian data sets"; longDescription = '' @@ -104,9 +98,11 @@ in stdenv.mkDerivation (finalAttrs: { transformations and includes supporting data such as coastlines, rivers, and political boundaries and optionally country polygons. ''; - platforms = lib.platforms.unix; - license = lib.licenses.lgpl3Plus; - maintainers = lib.teams.geospatial.members ++ (with lib.maintainers; [ tviti ]); + platforms = [ + "x86_64-linux" + "x86_64-darwin" + ]; + license = licenses.lgpl3Plus; + maintainers = with maintainers; [ tviti ]; }; - }) diff --git a/pkgs/applications/gis/gmt/gshhg.nix b/pkgs/by-name/gs/gshhg-gmt/package.nix similarity index 86% rename from pkgs/applications/gis/gmt/gshhg.nix rename to pkgs/by-name/gs/gshhg-gmt/package.nix index d51f1dbbcb5a..c17378d5ec1b 100644 --- a/pkgs/applications/gis/gmt/gshhg.nix +++ b/pkgs/by-name/gs/gshhg-gmt/package.nix @@ -1,10 +1,14 @@ -{ lib, stdenv, fetchurl }: +{ + lib, + stdenv, + fetchurl, +}: -stdenv.mkDerivation rec { +stdenv.mkDerivation (finalAttrs: { pname = "gshhg-gmt"; version = "2.3.7"; src = fetchurl { - url = "ftp://ftp.soest.hawaii.edu/gmt/gshhg-gmt-${version}.tar.gz"; + url = "ftp://ftp.soest.hawaii.edu/gmt/gshhg-gmt-${finalAttrs.version}.tar.gz"; sha256 = "9bb1a956fca0718c083bef842e625797535a00ce81f175df08b042c2a92cfe7f"; }; @@ -28,4 +32,4 @@ stdenv.mkDerivation rec { maintainers = lib.teams.geospatial.members ++ (with lib.maintainers; [ tviti ]); }; -} +}) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 082c351099b5..bd496238d27c 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -27779,15 +27779,6 @@ with pkgs; ### APPLICATIONS / GIS - gmt = callPackage ../applications/gis/gmt { - inherit (darwin.apple_sdk.frameworks) - Accelerate CoreGraphics CoreVideo; - }; - - gshhg-gmt = callPackage ../applications/gis/gmt/gshhg.nix { }; - - dcw-gmt = callPackage ../applications/gis/gmt/dcw.nix { }; - grass = callPackage ../applications/gis/grass { stdenv = if stdenv.hostPlatform.isDarwin then overrideSDK stdenv "11.0" else stdenv; }; From fafffddcf966213b6cf62f05c78f77ee53c3b58f Mon Sep 17 00:00:00 2001 From: wxt <3264117476@qq.com> Date: Mon, 23 Sep 2024 15:47:44 +0800 Subject: [PATCH 2/2] gmt: 6.4.0 -> 6.5.0; fix build --- pkgs/by-name/gm/gmt/package.nix | 84 ++++++++++++++++----------------- 1 file changed, 42 insertions(+), 42 deletions(-) diff --git a/pkgs/by-name/gm/gmt/package.nix b/pkgs/by-name/gm/gmt/package.nix index afd1464aeba6..381fd67aa4f1 100644 --- a/pkgs/by-name/gm/gmt/package.nix +++ b/pkgs/by-name/gm/gmt/package.nix @@ -1,7 +1,7 @@ { lib, stdenv, - fetchurl, + fetchFromGitHub, cmake, curl, darwin, @@ -11,27 +11,34 @@ gdal, blas, lapack, - glibc, ghostscript, dcw-gmt, gshhg-gmt, + libxml2, }: -/* - The onus is on the user to also install: - - ffmpeg for webm or mp4 output - - graphicsmagick for gif output -*/ - stdenv.mkDerivation (finalAttrs: { pname = "gmt"; - version = "6.4.0"; - src = fetchurl { - url = "https://github.com/GenericMappingTools/gmt/releases/download/${finalAttrs.version}/gmt-${finalAttrs.version}-src.tar.gz"; - sha256 = "sha256-0mfAx9b7MMnqfgKe8n2tsm/9e5LLS0cD+aO6Do85Ohs="; + version = "6.5.0"; + + src = fetchFromGitHub { + owner = "GenericMappingTools"; + repo = "gmt"; + rev = "refs/tags/${finalAttrs.version}"; + hash = "sha256-KKIYhljCtk9t9CuvTLsSGvUkUwazWTm9ymBB3wLwSoI="; }; nativeBuildInputs = [ cmake ]; + env = { + NIX_LDFLAGS = "-lxml2 -L${lib.getLib (libxml2.override { enableHttp = true; })}/lib"; + NIX_CFLAGS_COMPILE = + lib.optionalString stdenv.cc.isClang "-Wno-implicit-function-declaration " + + lib.optionalString ( + stdenv.isDarwin + && lib.versionOlder (darwin.apple_sdk.MacOSX-SDK.version or darwin.apple_sdk.sdk.version) "13.3" + ) "-D__LAPACK_int=int"; + }; + buildInputs = [ curl @@ -51,7 +58,6 @@ stdenv.mkDerivation (finalAttrs: { ] else [ - glibc fftwSinglePrec blas lapack @@ -62,31 +68,28 @@ stdenv.mkDerivation (finalAttrs: { cmakeFlags = [ - "-DGMT_DOCDIR=share/doc/gmt" - "-DGMT_MANDIR=share/man" - "-DGMT_LIBDIR=lib" - "-DCOPY_GSHHG:BOOL=FALSE" - "-DGSHHG_ROOT=${gshhg-gmt.out}/share/gshhg-gmt" - "-DCOPY_DCW:BOOL=FALSE" - "-DDCW_ROOT=${dcw-gmt.out}/share/dcw-gmt" - "-DGDAL_ROOT=${gdal.out}" - "-DNETCDF_ROOT=${netcdf.out}" - "-DPCRE_ROOT=${pcre.out}" - "-DGMT_INSTALL_TRADITIONAL_FOLDERNAMES:BOOL=FALSE" - "-DGMT_ENABLE_OPENMP:BOOL=TRUE" - "-DGMT_INSTALL_MODULE_LINKS:BOOL=FALSE" - "-DLICENSE_RESTRICTED=LGPL" # "GPL" and "no" also valid + (lib.cmakeFeature "GMT_DOCDIR" "share/doc/gmt") + (lib.cmakeFeature "GMT_MANDIR" "share/man") + (lib.cmakeFeature "GMT_LIBDIR" "lib") + (lib.cmakeBool "COPY_GSHHG" false) + (lib.cmakeFeature "GSHHG_ROOT" "${gshhg-gmt.out}/share/gshhg-gmt") + (lib.cmakeBool "COPY_DCW" false) + (lib.cmakeFeature "DCW_ROOT" "${dcw-gmt.out}/share/dcw-gmt") + (lib.cmakeFeature "GDAL_ROOT" "${gdal.out}") + (lib.cmakeFeature "NETCDF_ROOT" "${netcdf.out}") + (lib.cmakeFeature "PCRE_ROOT" "${pcre.out}") + (lib.cmakeBool "GMT_INSTALL_TRADITIONAL_FOLDERNAMES" false) + (lib.cmakeBool "GMT_ENABLE_OPENMP" true) + (lib.cmakeBool "GMT_INSTALL_MODULE_LINKS" false) + (lib.cmakeFeature "LICENSE_RESTRICTED" "LGPL") ] - ++ ( - with stdenv; - lib.optionals (!isDarwin) [ - "-DFFTW3_ROOT=${fftwSinglePrec.dev}" - "-DLAPACK_LIBRARY=${lapack}/lib/liblapack.so" - "-DBLAS_LIBRARY=${blas}/lib/libblas.so" - ] - ); + ++ (lib.optionals (!stdenv.isDarwin) [ + (lib.cmakeFeature "FFTW3_ROOT" "${fftwSinglePrec.dev}") + (lib.cmakeFeature "LAPACK_LIBRARY" "${lib.getLib lapack}/lib/liblapack.so") + (lib.cmakeFeature "BLAS_LIBRARY" "${lib.getLib blas}/lib/libblas.so") + ]); - meta = with lib; { + meta = { homepage = "https://www.generic-mapping-tools.org"; description = "Tools for manipulating geographic and cartesian data sets"; longDescription = '' @@ -98,11 +101,8 @@ stdenv.mkDerivation (finalAttrs: { transformations and includes supporting data such as coastlines, rivers, and political boundaries and optionally country polygons. ''; - platforms = [ - "x86_64-linux" - "x86_64-darwin" - ]; - license = licenses.lgpl3Plus; - maintainers = with maintainers; [ tviti ]; + platforms = lib.platforms.unix; + license = lib.licenses.lgpl3Plus; + maintainers = with lib.maintainers; [ tviti ]; }; })