diff options
Diffstat (limited to 'pkgs/applications/science/programming/scyther/default.nix')
-rw-r--r-- | pkgs/applications/science/programming/scyther/default.nix | 119 |
1 files changed, 58 insertions, 61 deletions
diff --git a/pkgs/applications/science/programming/scyther/default.nix b/pkgs/applications/science/programming/scyther/default.nix index 6e009067e4e4..beef26c6032a 100644 --- a/pkgs/applications/science/programming/scyther/default.nix +++ b/pkgs/applications/science/programming/scyther/default.nix @@ -1,12 +1,10 @@ -{ stdenv, lib, fetchFromGitHub, glibc, flex, bison, python27Packages, graphviz, cmake +{ stdenv, lib, buildEnv, callPackage_i686, fetchFromGitHub, python27Packages, graphviz , includeGUI ? true , includeProtocols ? true }: let version = "1.1.3"; -in -stdenv.mkDerivation { - name = "scyther-${version}"; + src = fetchFromGitHub { rev = "v${version}"; sha256 = "0rb4ha5bnjxnwj4f3hciq7kyj96fhw14hqbwl5kr9cdw8q62mx0h"; @@ -14,69 +12,68 @@ stdenv.mkDerivation { repo = "scyther"; }; - buildInputs = [ - cmake - glibc.static - flex - bison - ] ++ lib.optional includeGUI [ - python27Packages.wrapPython - ]; + 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; + }; - patchPhase = '' - # Since we're not in a git dir, the normal command this project uses to create this file wouldn't work - printf "%s\n" "#define TAGVERSION \"${version}\"" > src/version.h - '' + lib.optionalString includeGUI '' - file=gui/Scyther/Scyther.py - - # 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 \"$out/bin\"" + cli = callPackage_i686 ./cli.nix { + inherit version src meta; + }; - # Removes the Shebang from the file, as this would be wrapped wrongly - sed -i -e "1d" $file - ''; + gui = stdenv.mkDerivation { + name = "scyther-gui-${version}"; + inherit src meta; + buildInputs = [ + python27Packages.wrapPython + ]; - configurePhase = '' - (cd src && cmakeConfigurePhase) - ''; + patchPhase = '' + file=gui/Scyther/Scyther.py - propagatedBuildInputs = lib.optional includeGUI [ - python27Packages.wxPython - graphviz - ]; - - dontUseCmakeBuildDir = true; - cmakeFlags = [ "-DCMAKE_C_FLAGS=-std=gnu89" ]; + # 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\"" - installPhase = '' - mkdir -p "$out/bin" - cp src/scyther-linux "$out/bin/scyther-cli" - '' + lib.optionalString includeGUI '' - mkdir -p "$out/gui" - cp -r gui/* "$out/gui" - ln -s ../gui/scyther-gui.py "$out/bin/scyther-gui" - ln -s ../bin/scyther-cli "$out/bin/scyther-linux" - '' + lib.optionalString includeProtocols (if includeGUI then '' - ln -s ./gui/Protocols "$out/protocols" - '' else '' - mkdir -p "$out/protocols" - cp -r gui/Protocols/* "$out/protocols" - ''); + # Removes the Shebang from the file, as this would be wrapped wrongly + sed -i -e "1d" $file + ''; - postFixup = lib.optionalString includeGUI '' - wrapPythonProgramsIn "$out/gui" "$out $pythonPath" - ''; + dontBuild = true; - doInstallCheck = includeGUI; - installCheckPhase = '' - "$out/gui/scyther.py" "$src/gui/Protocols/Demo/ns3.spdl" - ''; + 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" + ''; - 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; + postFixup = '' + wrapPythonProgramsIn "$out/gui" "$out $pythonPath" + ''; + + doInstallCheck = true; + installCheckPhase = '' + "$out/gui/scyther.py" "$src/gui/Protocols/Demo/ns3.spdl" + ''; }; -} +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" + ''; + } |