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

81 lines
2.1 KiB
Nix
Raw Normal View History

{ stdenv, lib, buildEnv, pkgsi686Linux, fetchFromGitHub, python27Packages, graphviz
2017-06-30 00:03:21 +02:00
, includeGUI ? true
, includeProtocols ? true
}:
let
version = "1.1.3";
2017-06-30 00:03:21 +02: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-30 00:03:21 +02:00
cli = pkgsi686Linux.callPackage ./cli.nix {
inherit version src meta;
};
2017-06-30 00:03:21 +02:00
gui = stdenv.mkDerivation {
2019-08-13 23:52:01 +02:00
pname = "scyther-gui";
inherit version;
inherit src meta;
buildInputs = [
python27Packages.wrapPython
];
2017-06-30 00:03:21 +02:00
patchPhase = ''
file=gui/Scyther/Scyther.py
2017-06-30 00:03:21 +02: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-30 00:03:21 +02:00
# Removes the Shebang from the file, as this would be wrapped wrongly
sed -i -e "1d" $file
'';
2017-06-30 00:03:21 +02:00
dontBuild = true;
2017-06-30 00:03:21 +02: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-30 00:03:21 +02:00
postFixup = ''
wrapPythonProgramsIn "$out/gui" "$out $pythonPath"
'';
doInstallCheck = true;
installCheckPhase = ''
"$out/gui/scyther.py" "$src/gui/Protocols/Demo/ns3.spdl"
'';
2017-06-30 00:03:21 +02: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"
'';
}