Unverified Commit eae1f319 authored by Weijia Wang's avatar Weijia Wang Committed by GitHub
Browse files

gmt: fix build (#343919)

parents 05d71c7c fafffddc
Loading
Loading
Loading
Loading
+8 −4
Original line number Diff line number Diff line
{ 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 ]);
  };

}
})
+108 −0
Original line number Diff line number Diff line
@@ -4,39 +4,22 @@
  fetchFromGitHub,
  cmake,
  curl,
  Accelerate,
  CoreGraphics,
  CoreVideo,
  darwin,
  fftwSinglePrec,
  netcdf,
  libxml2,
  pcre,
  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
*/

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";
@@ -44,21 +27,30 @@ in stdenv.mkDerivation (finalAttrs: {
    hash = "sha256-KKIYhljCtk9t9CuvTLsSGvUkUwazWTm9ymBB3wLwSoI=";
  };

  nativeBuildInputs = [
    cmake
  ];
  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
      gdal
      netcdf'
      netcdf
      pcre
      dcw-gmt
      gshhg-gmt
    ]
    ++ (
      if stdenv.hostPlatform.isDarwin then
      if stdenv.isDarwin then
        with darwin.apple_sdk.frameworks;
        [
          Accelerate
          CoreGraphics
@@ -66,31 +58,36 @@ in stdenv.mkDerivation (finalAttrs: {
        ]
      else
        [
          glibc
          fftwSinglePrec
          blas
          lapack
        ]
    );

  propagatedBuildInputs = [
    ghostscript
  ];
  propagatedBuildInputs = [ ghostscript ];

  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"
      "-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")
    ]
    ++ (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 = {
    homepage = "https://www.generic-mapping-tools.org";
@@ -106,7 +103,6 @@ in stdenv.mkDerivation (finalAttrs: {
    '';
    platforms = lib.platforms.unix;
    license = lib.licenses.lgpl3Plus;
    maintainers = lib.teams.geospatial.members ++ (with lib.maintainers; [ tviti ]);
    maintainers = with lib.maintainers; [ tviti ];
  };

})
+8 −4
Original line number Diff line number Diff line
{ 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 ]);
  };

}
})
+0 −9
Original line number Diff line number Diff line
@@ -27746,15 +27746,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;
  };