-
-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
dev: Add Nix files for building dev environment and the package
- Loading branch information
Showing
4 changed files
with
305 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
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` | ||
libmysqlclient # for `mysql_config` | ||
netcdf # for `nc-config` | ||
pkg-config | ||
] ++ (with python3Packages; [ pytest python-dateutil numpy wxPython_4_2 ]) | ||
|
||
# from package buildInputs | ||
++ [ | ||
blas | ||
cairo | ||
ffmpeg | ||
fftw | ||
gdal | ||
geos | ||
libGLU | ||
libmysqlclient | ||
libpng | ||
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" | ||
# Force GRASS to create grassdata and config file in source code directory. | ||
export HOME=$(pwd) | ||
''; | ||
}; | ||
}; | ||
|
||
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,143 @@ | ||
{ lib | ||
, stdenv | ||
, makeWrapper | ||
, wrapGAppsHook | ||
|
||
, bison | ||
, blas | ||
, cairo | ||
, ffmpeg | ||
, fftw | ||
, flex | ||
, gdal | ||
, geos | ||
, libiconv | ||
, libmysqlclient | ||
, libpng | ||
, 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); | ||
}; | ||
|
||
patches = lib.optionals stdenv.isDarwin [ | ||
# Fix conversion of const char* to unsigned int. | ||
./clang-integer-conversion.patch | ||
]; | ||
|
||
# Correct mysql_config query | ||
postPatch = '' | ||
substituteInPlace configure --replace "--libmysqld-libs" "--libs" | ||
''; | ||
|
||
nativeBuildInputs = [ | ||
makeWrapper | ||
wrapGAppsHook | ||
|
||
bison | ||
flex | ||
gdal # for `gdal-config` | ||
geos # for `geos-config` | ||
libmysqlclient # for `mysql_config` | ||
netcdf # for `nc-config` | ||
pkg-config | ||
] ++ (with python3Packages; [ python-dateutil numpy wxPython_4_2 ]); | ||
|
||
buildInputs = [ | ||
blas | ||
cairo | ||
ffmpeg | ||
fftw | ||
gdal | ||
geos | ||
libmysqlclient | ||
libpng | ||
libtiff | ||
libxml2 | ||
netcdf | ||
pdal | ||
postgresql | ||
proj | ||
readline | ||
sqlite | ||
wxGTK32 | ||
zlib | ||
zstd | ||
] ++ lib.optionals stdenv.isDarwin [ libiconv ]; | ||
|
||
strictDeps = true; | ||
|
||
configureFlags = [ | ||
"--with-blas" | ||
"--with-geos" | ||
# It complains about missing libmysqld but doesn't really seem to need it | ||
"--with-mysql" | ||
"--with-mysql-includes=${lib.getDev libmysqlclient}/include/mysql" | ||
"--with-mysql-libs=${libmysqlclient}/lib/mysql" | ||
"--with-netcdf" | ||
"--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-pthread" | ||
"--with-readline" | ||
"--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 script run 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"; | ||
}; | ||
}) |