NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
17.62k stars 13.77k forks source link

Package request: GeoDa #314005

Open sikmir opened 4 months ago

sikmir commented 4 months ago

Project description

An introduction to spatial data analysis.

Metadata


Add a :+1: reaction to issues you find important.

TomaSajt commented 4 months ago

Here's how far I got

There are many missing symbol errors, probably due to this needing a very old gdal version and wxGTK being out of date. Not sure how to continue, so I 'll leave this here for anyone that wants to continue.

{
  lib,
  stdenv,
  fetchzip,
  fetchFromGitHub,
  substituteAll,
  cmake,
  boost,
  wxGTK32,
  curl,
  gdal,
  eigen,
  libGL,
  libGLU,
  spectra,
  webkitgtk,
  blas,
  lapack,
  libf2c,
}:

let
  # this is a modified version of json_spirit specifically for GeoDa
  json-spirit = stdenv.mkDerivation {
    pname = "json-spirit";
    version = "4.0.8";
    src = fetchzip {
      url = "https://github.com/GeoDaCenter/software/releases/download/v2000/json_spirit_v4.08.zip";
      hash = "sha256-TuOJk0XZGjQyz6HiKwYsIG9/qHsbrI3hqktW0Fe6LxA=";
    };
    nativeBuildInputs = [ cmake ];
    buildInputs = [ boost ];
    postInstall = ''
      mkdir $out/include/json_spirit
      mv $out/include/*.h $out/include/json_spirit
    '';
  };

  spectra' = spectra.overrideAttrs rec {
    version = "0.9.0";
    src = fetchFromGitHub {
      owner = "yixuan";
      repo = "spectra";
      rev = "v${version}";
      hash = "sha256-/0RufHauMrMqddbQsEiIZ58p9IzM57v0anTFHZ7XijA=";
    };
  };
in
stdenv.mkDerivation (finalAttrs: {
  pname = "geoda";
  version = "1.22.0.6";
  src = fetchFromGitHub {
    owner = "GeoDaCenter";
    repo = "geoda";
    rev = "v${finalAttrs.version}";
    hash = "sha256-Fc2mgfSJhM1Vci6ZzkUbf/8UFEGXMyZTnCL+X8ujxzQ=";
  };

  # Note:
  # weirdly, the GeoDamake.opt file is in .gitignore, but was not removed from the sources
  # so you'll need to remove the file from .gitignore to regenerate this patch
  patches = [
    (substituteAll {
      src = ./make.patch;
      json_spirit = json-spirit;
      libf2c = libf2c;
    })
  ];

  stictDeps = true;

  nativeBuildInputs = [ wxGTK32 ];

  buildInputs = [
    wxGTK32 # probably not the correct version
    boost
    curl
    gdal
    json-spirit
    eigen
    libGL
    libGLU
    spectra'
    blas
    lapack
    webkitgtk
  ];

  env.NIX_CFLAGS_COMPILE = "-I${lib.getDev eigen}/include/eigen3";

  buildPhase = ''
    runHook preBuild

    mkdir o
    cd BuildTools/ubuntu
    export GEODA_HOME=$(pwd)
    make default app -j$NIX_BUILD_CORES

    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall

    dir -R

    runHook postInstall
  '';

  meta = {
    description = "An introduction to spatial data analysis";
    homepage = "http://geodacenter.github.io/";
    license = lib.licenses.gpl3Plus;
    maintainers = with lib.maintainers; [ ];
  };
})

make.patch

diff --git a/GeoDamake.opt b/GeoDamake.opt
index 101b289..8b50d93 100644
--- a/GeoDamake.opt
+++ b/GeoDamake.opt
@@ -2,21 +2,17 @@ GeoDa_ROOT    =   $(GEODA_HOME)/../..

 TARGET      = GeoDa

-CC =   /usr/bin/gcc
-CXX =  /usr/bin/g++
-LD =   /usr/bin/g++
-RM =   /bin/rm -f
+CC =   gcc
+CXX    =   g++
+LD =   g++
+RM =   rm -f

-WXLIBS  = $(shell $(GEODA_HOME)/libraries/bin/wx-config --libs xrc,stc,richtext,ribbon,propgrid,aui,gl,html,webview,qa,adv,core,xml,net,base)
-WX_HEADER = $(shell $(GEODA_HOME)/libraries/bin/wx-config --cppflags)
+WXLIBS  = $(shell wx-config --libs xrc,stc,richtext,ribbon,propgrid,aui,gl,html,webview,qa,adv,core,xml,net,base)
+WX_HEADER = $(shell wx-config --cppflags)

 LIBS = $(WXLIBS) \
-        $(GEODA_HOME)/temp/CLAPACK-3.2.1/lapack.a \
-        $(GEODA_HOME)/temp/CLAPACK-3.2.1/libf2c.a \
-        $(GEODA_HOME)/temp/CLAPACK-3.2.1/blas.a \
-        $(GEODA_HOME)/temp/boost/stage/lib/libboost_date_time.a \
-        $(GEODA_HOME)/temp/boost/stage/lib/libboost_thread.a \
-        $(GEODA_HOME)/temp/boost/stage/lib/libboost_system.a \
-        $(GEODA_HOME)/libraries/lib/libjson_spirit.a \
+        @libf2c@/lib/libf2c.a \
+        @json_spirit@/lib/libjson_spirit.a \
+        -llapack -lblas -lboost_date_time -lboost_thread -lboost_system -lGL -lGLU \
         -L$(GEODA_HOME)/libraries/lib -lgdal -lcurl -L/usr/lib/x86_64-linux-gnu -lz -lwebkit2gtk-4.0 -lEGL -ljavascriptcoregtk-4.0
 # Note: Library -lrtmp causes a missing library problem at runtime on
 #       Ubuntu 14.10 and later.