-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathdefault.nix
More file actions
103 lines (85 loc) · 2.46 KB
/
default.nix
File metadata and controls
103 lines (85 loc) · 2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{ cairo, callPackage, curl, fetchgit, gfortran, hdf5-fortran, imagemagick
, makeWrapper, netcdf, netcdfcxx4, netcdffortran, perl, stdenv, tcsh, xorg }:
let
NCL = callPackage ../NCL.nix { };
xlibs = with xorg; [
libXrender
libX11
libXaw
libXext
libXmu
libXt
libSM
libXpm
libICE
];
cairo-with-x11 = cairo.override { x11Support = true; };
in stdenv.mkDerivation rec {
pname = "ROMS-plot";
version = "0.0";
src = ../ROMS-plot;
nativeBuildInputs = [ makeWrapper ];
buildInputs = [
cairo-with-x11
curl
gfortran
hdf5-fortran
netcdf
netcdffortran
netcdfcxx4
perl
] ++ xlibs;
propagatedBuildInputs = [ NCL imagemagick tcsh ];
prePatch = let
compiler = if stdenv.isDarwin then
"src/Compilers/Darwin-gfortran.mk"
else
"src/Compilers/Linux-gfortran.mk";
in ''
substituteInPlace ${compiler} \
--replace "\$(shell which \''${FC})" "${gfortran}/bin/gfortran"
substituteInPlace ${compiler} \
--replace "/usr/bin/cpp" "${gfortran}/bin/cpp"
patchShebangs src/Bin/sfmakedepend
patchShebangs src/Bin/cpp_clean
'' + (if stdenv.isDarwin then ''
substituteInPlace ${compiler} \
--replace "LIBS += -L/opt/X11/lib -lX11" \
"LIBS += -L${cairo}/lib -lX11 -lcairo -lfreetype"
'' else ''
substituteInPlace ${compiler} \
--replace "LIBS += -L/usr/X11R6/lib64 -lX11" \
"LIBS += -L${cairo}/lib -lX11 -lcairo -lfreetype"
'');
patches = [ ./0001-On-master-any-make.patch ];
buildPhase = ''
mkdir -p $out/Build_plt
mkdir -p $out/bin
cd src
NCARG_ROOT=${NCL.out} \
NC_CONFIG=nf-config \
USE_NETCDF4=yes \
SCRATCH_DIR=$out/Build_plt \
PLT_LARGE=yes \
PLT_BINDIR=$out/bin \
make
'';
hardeningDisable = [ "format" ];
installPhase = ''
cp Bin/ncgm2gif.sh $out/bin/ncgm2gif.sh
cp Bin/ncgm2png.sh $out/bin/ncgm2png.sh
substituteInPlace $out/bin/ncgm2gif.sh \
--replace "#!/bin/csh" "#!${tcsh.out}/bin/tcsh"
substituteInPlace $out/bin/ncgm2png.sh \
--replace "#!/bin/csh" "#!${tcsh.out}/bin/tcsh"
substituteInPlace $out/bin/ncgm2gif.sh \
--replace "/opt/local/bin/convert" "${imagemagick.out}/bin/convert"
substituteInPlace $out/bin/ncgm2png.sh \
--replace "/opt/local/bin/convert" "${imagemagick.out}/bin/convert"
for i in $out/bin/*; do
echo "Wrapping ''${i}"
wrapProgram $i \
--set NCARG_ROOT ${NCL.out}
done
'';
}