package.nix (1717B)
1 { 2 lib, 3 stdenv, 4 fetchFromGitHub, 5 makeWrapper, 6 python3Packages, 7 }: 8 9 stdenv.mkDerivation (finalAttrs: { 10 pname = "mountains"; 11 version = "0-unstable-2025-10-16"; 12 13 src = fetchFromGitHub { 14 owner = "akirmse"; 15 repo = "mountains"; 16 rev = "f58bc6205ea2e6fc94e8185f8cc1a6cb442f33c5"; 17 hash = "sha256-WRL9pwzSb4NLAzweQJ4dcReEofRuGnMIV8W/cyOpga0="; 18 }; 19 20 sourceRoot = "${finalAttrs.src.name}/code"; 21 22 postPatch = '' 23 substituteInPlace Makefile \ 24 --replace-fail "ar -r" "${stdenv.cc.targetPrefix}ar -r" 25 substituteInPlace ../scripts/run_prominence.py \ 26 --replace-fail "'--binary_dir', default='release'" "'--binary_dir', default='$out/bin'" 27 ''; 28 29 nativeBuildInputs = [ makeWrapper ]; 30 31 makeFlags = [ 32 "CC:=$(CC)" 33 "LINK=$(CXX)" 34 ]; 35 36 env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isGNU "-Wno-error=stringop-overflow"; 37 38 installPhase = 39 let 40 pythonEnv = python3Packages.python.withPackages ( 41 p: with p; [ 42 gdal 43 ] 44 ); 45 in 46 '' 47 install -Dm755 release/{isolation,prominence,merge_divide_trees,filter_points,compute_parents} -t $out/bin 48 49 site_packages=$out/lib/${python3Packages.python.libPrefix}/site-packages 50 mkdir -p $site_packages 51 cp ../scripts/*.py $site_packages 52 53 makeWrapper ${pythonEnv.interpreter} $out/bin/run_prominence \ 54 --add-flags "$site_packages/run_prominence.py" 55 ''; 56 57 meta = { 58 description = "Code to compute the prominence and isolation of mountains from digital elevation data"; 59 homepage = "https://github.com/akirmse/mountains"; 60 license = lib.licenses.mit; 61 maintainers = [ lib.maintainers.sikmir ]; 62 platforms = lib.platforms.unix; 63 }; 64 })
