nixpkgs/pkgs/applications/science/programming/scyther/default.nix

80 lines
2.0 KiB
Nix
Raw Normal View History

{ stdenv, lib, buildEnv, callPackage_i686, fetchFromGitHub, python27Packages, graphviz
2017-06-29 23:03:21 +01:00
, includeGUI ? true
, includeProtocols ? true
}:
let
version = "1.1.3";
2017-06-29 23:03:21 +01:00
src = fetchFromGitHub {
rev = "v${version}";
sha256 = "0rb4ha5bnjxnwj4f3hciq7kyj96fhw14hqbwl5kr9cdw8q62mx0h";
owner = "cascremers";
repo = "scyther";
};
meta = with lib; {
description = "Scyther is a tool for the automatic verification of security protocols.";
homepage = https://www.cs.ox.ac.uk/people/cas.cremers/scyther/;
license = licenses.gpl2;
maintainers = with maintainers; [ infinisil ];
platforms = platforms.linux;
};
2017-06-29 23:03:21 +01:00
cli = callPackage_i686 ./cli.nix {
inherit version src meta;
};
2017-06-29 23:03:21 +01:00
gui = stdenv.mkDerivation {
name = "scyther-gui-${version}";
inherit src meta;
buildInputs = [
python27Packages.wrapPython
];
2017-06-29 23:03:21 +01:00
patchPhase = ''
file=gui/Scyther/Scyther.py
2017-06-29 23:03:21 +01:00
# By default the scyther binary is looked for in the directory of the python script ($out/gui), but we want to have it look where our cli package is
substituteInPlace $file --replace "return getMyDir()" "return \"${cli}/bin\""
2017-06-29 23:03:21 +01:00
# Removes the Shebang from the file, as this would be wrapped wrongly
sed -i -e "1d" $file
'';
2017-06-29 23:03:21 +01:00
dontBuild = true;
2017-06-29 23:03:21 +01:00
propagatedBuildInputs = [
python27Packages.wxPython
graphviz
];
installPhase = ''
mkdir -p "$out"/gui "$out"/bin
cp -r gui/* "$out"/gui
ln -s "$out"/gui/scyther-gui.py "$out/bin/scyther-gui"
'';
2017-06-29 23:03:21 +01:00
postFixup = ''
wrapPythonProgramsIn "$out/gui" "$out $pythonPath"
'';
doInstallCheck = true;
installCheckPhase = ''
"$out/gui/scyther.py" "$src/gui/Protocols/Demo/ns3.spdl"
'';
2017-06-29 23:03:21 +01:00
};
in
buildEnv {
name = "scyther-${version}";
inherit meta;
paths = [ cli ] ++ lib.optional includeGUI gui;
pathsToLink = [ "/bin" ];
postBuild = ''
rm "$out/bin/scyther-linux"
'' + lib.optionalString includeProtocols ''
mkdir -p "$out/protocols"
cp -rv ${src}/protocols/* "$out/protocols"
'';
}