-
-
Notifications
You must be signed in to change notification settings - Fork 327
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
packaging: Add Nix files for creating development environment and the…
… package (#3889)
- Loading branch information
Showing
4 changed files
with
288 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
/emacs.desktop | ||
*~ | ||
*.lock | ||
!flake.lock | ||
*.pyc | ||
OBJ.* | ||
locale/scriptstrings/* | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
description = "GRASS GIS"; | ||
|
||
nixConfig = { | ||
bash-prompt = "\\[\\033[1m\\][grass-dev]\\[\\033\[m\\]\\040\\w >\\040"; | ||
}; | ||
|
||
inputs = { | ||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; | ||
}; | ||
|
||
outputs = inputs@{ flake-parts, ... }: | ||
flake-parts.lib.mkFlake { inherit inputs; } { | ||
|
||
systems = [ "x86_64-linux" ]; | ||
|
||
perSystem = { config, self', inputs', pkgs, system, ... }: { | ||
|
||
packages.grass = pkgs.callPackage ./package.nix { }; | ||
|
||
devShells.default = pkgs.mkShell { | ||
buildInputs = | ||
# from package nativeBuildInputs | ||
with pkgs; [ | ||
bison | ||
flex | ||
gdal # for `gdal-config` | ||
geos # for `geos-config` | ||
netcdf # for `nc-config` | ||
pkg-config | ||
] ++ (with python3Packages; [ pytest python-dateutil numpy wxPython_4_2 ]) | ||
|
||
# from package buildInputs | ||
++ [ | ||
blas | ||
cairo | ||
ffmpeg | ||
fftw | ||
freetype | ||
gdal | ||
geos | ||
lapack | ||
libGLU | ||
libpng | ||
libsvm | ||
libtiff | ||
libxml2 | ||
netcdf | ||
pdal | ||
postgresql | ||
proj | ||
readline | ||
sqlite | ||
wxGTK32 | ||
zlib | ||
zstd | ||
] ++ lib.optionals stdenv.isDarwin [ libiconv ]; | ||
|
||
shellHook = '' | ||
echo -e "\nWelcome to a GRASS development environment !" | ||
echo "Build GRASS using following commands:" | ||
echo | ||
echo " 1. ./configure --prefix=\$(pwd)/app" | ||
echo " 2. make -j$(nproc)" | ||
echo " 3. make install" | ||
echo | ||
echo "Run tests:" | ||
echo | ||
echo " 1. export PYTHONPATH=\$(app/bin/grass --config python_path):\$PYTHONPATH" | ||
echo " 2. export LD_LIBRARY_PATH=\$(app/bin/grass --config path)/lib:\$LD_LIBRARY_PATH" | ||
echo " 3. pytest" | ||
echo | ||
echo "Note: run 'nix flake update' from time to time to update dependencies." | ||
''; | ||
}; | ||
}; | ||
|
||
flake = { }; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
{ lib | ||
, stdenv | ||
, makeWrapper | ||
, wrapGAppsHook | ||
|
||
, withOpenGL ? true | ||
|
||
, bison | ||
, blas | ||
, cairo | ||
, ffmpeg | ||
, fftw | ||
, flex | ||
, freetype | ||
, gdal | ||
, geos | ||
, lapack | ||
, libGLU | ||
, libiconv | ||
, libpng | ||
, libsvm | ||
, libtiff | ||
, libxml2 | ||
, netcdf | ||
, pdal | ||
, pkg-config | ||
, postgresql | ||
, proj | ||
, python3Packages | ||
, readline | ||
, sqlite | ||
, wxGTK32 | ||
, zlib | ||
, zstd | ||
|
||
}: | ||
|
||
stdenv.mkDerivation (finalAttrs: { | ||
pname = "grass"; | ||
version = "dev"; | ||
|
||
src = lib.cleanSourceWith { | ||
src = ./.; | ||
filter = path: type: | ||
! (lib.hasSuffix ".nix" path); | ||
}; | ||
|
||
nativeBuildInputs = [ | ||
makeWrapper | ||
wrapGAppsHook | ||
|
||
bison | ||
flex | ||
gdal # for `gdal-config` | ||
geos # for `geos-config` | ||
netcdf # for `nc-config` | ||
pkg-config | ||
] ++ (with python3Packages; [ python-dateutil numpy wxPython_4_2 ]); | ||
|
||
buildInputs = [ | ||
blas | ||
cairo | ||
ffmpeg | ||
fftw | ||
freetype | ||
gdal | ||
geos | ||
lapack | ||
libpng | ||
libsvm | ||
libtiff | ||
libxml2 | ||
netcdf | ||
pdal | ||
postgresql | ||
proj | ||
readline | ||
sqlite | ||
wxGTK32 | ||
zlib | ||
zstd | ||
] ++ lib.optionals withOpenGL [ libGLU ] | ||
++ lib.optionals stdenv.isDarwin [ libiconv ]; | ||
|
||
strictDeps = true; | ||
|
||
configureFlags = [ | ||
"--with-blas" | ||
"--with-cairo-ldflags=-lfontconfig" | ||
"--with-cxx" | ||
"--with-fftw" | ||
"--with-freetype" | ||
"--with-geos" | ||
"--with-gdal" | ||
"--with-lapack" | ||
"--with-libsvm" | ||
"--with-nls" | ||
"--with-openmp" | ||
"--with-pdal" | ||
"--with-postgres" | ||
"--with-postgres-libs=${postgresql.lib}/lib/" | ||
"--with-proj-includes=${proj.dev}/include" | ||
"--with-proj-libs=${proj}/lib" | ||
"--with-proj-share=${proj}/share/proj" | ||
"--with-sqlite" | ||
"--with-zstd" | ||
"--without-bzlib" | ||
"--without-mysql" | ||
"--without-odbc" | ||
] ++ lib.optionals (! withOpenGL) [ | ||
"--without-opengl" | ||
] ++ lib.optionals stdenv.isDarwin [ | ||
"--without-cairo" | ||
"--without-freetype" | ||
"--without-x" | ||
]; | ||
|
||
# Otherwise a very confusing "Can't load GDAL library" error | ||
makeFlags = lib.optional stdenv.isDarwin "GDAL_DYNAMIC="; | ||
|
||
# Ensures that the python scripts running at build time are actually | ||
# executable; otherwise, patchShebangs ignores them. | ||
postConfigure = '' | ||
for f in $(find . -name '*.py'); do | ||
chmod +x $f | ||
done | ||
patchShebangs */ | ||
''; | ||
|
||
postInstall = '' | ||
wrapProgram $out/bin/grass \ | ||
--set PYTHONPATH $PYTHONPATH \ | ||
--set GRASS_PYTHON ${python3Packages.python.interpreter} \ | ||
--suffix LD_LIBRARY_PATH ':' '${gdal}/lib' | ||
ln -s $out/grass*/lib $out/lib | ||
ln -s $out/grass*/include $out/include | ||
''; | ||
|
||
enableParallelBuilding = true; | ||
|
||
meta = with lib; { | ||
description = "GIS software suite used for geospatial data management and analysis, image processing, graphics and maps production, spatial modeling, and visualization"; | ||
homepage = "https://grass.osgeo.org/"; | ||
license = licenses.gpl2Plus; | ||
maintainers = with maintainers; teams.geospatial.members; | ||
platforms = platforms.all; | ||
mainProgram = "grass"; | ||
}; | ||
}) |