spacefrogg-overlay/prism.nix

137 lines
4.1 KiB
Nix

{ stdenv, lib, fetchFromGitHub, jdk, lp_solve, lp_solve_java, makeWrapper
#, ltl2dstar, ltl2ba
, makeDesktopItem, python27 }:
let
src = fetchFromGitHub {
owner = "prismmodelchecker";
repo = "prism";
rev = "c2f637e177853b38fb8d9530e801e56d620e4466";
sha256 = "13xra91y542w808363wnqk9l7psnasy8c0sbkgmvxa6813i1i2i0";
};
version = "4.4-git";
cuddPrism = stdenv.mkDerivation rec {
name = "cudd-prism-${version}";
inherit version src;
buildInputs = [ jdk ];
configurePhase = "true";
buildPhase = ''
(
cd ./cudd
make clean JAVA_DIR="${jdk}"
)
(
cd ./prism
# will become cuddpackage
make cuddpackageforce JAVA_DIR="${jdk}"
)
'';
installPhase = ''
mkdir -p $out/{lib,include}
cd ./cudd
for dir in cudd dddmp epd mtr st util; do
cp ./$dir/lib$dir.a $out/lib
cp ./$dir/$dir.h $out/include
done
cp ./cudd/cuddInt.h $out/include
'';
meta.description = "Build of a Prism-adapted version of the CUDD library";
};
in stdenv.mkDerivation {
pname = "prism";
inherit version src;
buildInputs = [ jdk lp_solve_java cuddPrism lp_solve makeWrapper python27 ];
patchPhase = ''
(cd ./prism
substituteInPlace ./Makefile \
--replace "CFLAGS=\"\$(CFLAGS)\"" "CFLAGS=\"\$(CFLAGS) \$(NIX_CFLAGS_COMPILE)\"" \
--replace "CPPFLAGS=\"\$(CPPFLAGS)\"" "CPPFLAGS=\"\$(CPPFLAGS) \$(NIX_CFLAGS)\"" \
--replace "LDFLAGS=\"\$(LDFLAGS)\"" "LDFLAGS=\"\$(LDFLAGS)\"" \
--replace "LDFLAGS = \$(CUDD_XCFLAGS)" "LDFLAGS = -lc -lstdc++" \
--replace "@./install.sh silent" ":"
LPSOLVE_JAR=$(echo ${lp_solve_java}/lib/*.jar) #*/
for dir in automata dv hybrid jdd jltl2ba jltl2dstar mtbdd odd param parser pepa/compiler prism pta settings strat userinterface ; do
substituteInPlace ./src/$dir/Makefile \
--replace "PRISM_CLASSPATH = \"" "PRISM_CLASSPATH = $LPSOLVE_JAR:\""
done
substituteInPlace ./src/bin/prism.linux \
--replace "PRISM_DIR=/home/luser/prism" "PRISM_DIR=$out
PRISM_JAVA=\''${PRISM_JAVA-${jdk}/bin/java}" \
--replace "PRISM_CLASSPATH=" "PRISM_CLASSPATH=$LPSOLVE_JAR:" \
--replace "PRISM_LIB_PATH=" "PRISM_LIB_PATH=${lp_solve_java}/lib:"
substituteInPlace ./src/bin/xprism.linux \
--replace "PRISM_DIR=/home/luser/prism" "PRISM_DIR=$out
PRISM_JAVA=\''${PRISM_JAVA-${jdk}/bin/java}" \
--replace "PRISM_CLASSPATH=" "PRISM_CLASSPATH=$LPSOLVE_JAR:" \
--replace "PRISM_LIB_PATH=" "PRISM_LIB_PATH=${lp_solve_java}/lib:"
)
'';
configurePhase = "true";
buildPhase = ''
(
cd ./prism
make clean JAVA_DIR="${jdk}"
make make_dirs CUDD_DIR="${cuddPrism}" JAVA_DIR="${jdk}" JNI_H_DIR="${jdk}/include/linux" JNI_MD_H_DIR="${jdk}/include/linux"
)
'';
installPhase = ''
mkdir -p $out/{bin,lib,include,classes,images,share/applications,share/icons/hicolor/{256x256,128x128,64x64,48x48,32x32,24x24,16x16}/apps}
cd ./prism
make bin_scripts CUDD_DIR="${cuddPrism}" JAVA_DIR="${jdk}" JNI_H_DIR="${jdk}/include/linux" JNI_MD_H_DIR="${jdk}/include/linux"
cp -r lib include bin classes images $out
'' +
# ''
# cp etc/scripts/hoa/* $out/bin #*/
# for i in $out/bin/hoa-* ; do
# wrapProgram $i --prefix PATH : ${lib.makeBinPath [ ltl2dstar ltl2ba ]}
# done
# '' +
''
cp etc/scripts/prism-auto $out/bin
for i in etc/icons/p*.png ; do
SIZE=''${i#*/p}
SIZE=''${SIZE%.png}
cp $i $out/share/icons/hicolor/''${SIZE}x''${SIZE}/apps/xprism.png
done
ln -s ${makeDesktopItem {
name = "xprism";
desktopName = "XPrism Model Checker";
genericName = "Graphical frontend to Prism Model Checker";
exec = "xprism";
icon = "xprism";
categories = "Application;Science;Development;";
}}/share/applications/xprism.desktop $out/share/applications/xprism.desktop
'';
dontStrip = true;
meta = with lib; {
homepage = "http://www.prismmodelchecker.org/";
description = "Prism Probabilistic Model Checker";
license = licenses.gpl2;
maintainers = [ maintainers.spacefrogg ];
platforms = with platforms; linux;
};
}