From 75fde4130d4caa08561be31cb8e6058fcf71fb07 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Fri, 30 Jun 2017 00:03:21 +0200 Subject: [PATCH 1/2] scyther: init at 1.1.3 --- .../science/programming/scyther/default.nix | 82 +++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 84 insertions(+) create mode 100644 pkgs/applications/science/programming/scyther/default.nix diff --git a/pkgs/applications/science/programming/scyther/default.nix b/pkgs/applications/science/programming/scyther/default.nix new file mode 100644 index 00000000000..6e009067e4e --- /dev/null +++ b/pkgs/applications/science/programming/scyther/default.nix @@ -0,0 +1,82 @@ +{ stdenv, lib, fetchFromGitHub, glibc, flex, bison, python27Packages, graphviz, cmake +, includeGUI ? true +, includeProtocols ? true +}: +let + version = "1.1.3"; +in +stdenv.mkDerivation { + name = "scyther-${version}"; + src = fetchFromGitHub { + rev = "v${version}"; + sha256 = "0rb4ha5bnjxnwj4f3hciq7kyj96fhw14hqbwl5kr9cdw8q62mx0h"; + owner = "cascremers"; + repo = "scyther"; + }; + + buildInputs = [ + cmake + glibc.static + flex + bison + ] ++ lib.optional includeGUI [ + python27Packages.wrapPython + ]; + + 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\"" + + # Removes the Shebang from the file, as this would be wrapped wrongly + sed -i -e "1d" $file + ''; + + configurePhase = '' + (cd src && cmakeConfigurePhase) + ''; + + propagatedBuildInputs = lib.optional includeGUI [ + python27Packages.wxPython + graphviz + ]; + + dontUseCmakeBuildDir = true; + cmakeFlags = [ "-DCMAKE_C_FLAGS=-std=gnu89" ]; + + 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" + ''); + + postFixup = lib.optionalString includeGUI '' + wrapPythonProgramsIn "$out/gui" "$out $pythonPath" + ''; + + doInstallCheck = includeGUI; + installCheckPhase = '' + "$out/gui/scyther.py" "$src/gui/Protocols/Demo/ns3.spdl" + ''; + + 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; + }; +} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 593fb7d3a36..9c52320c83e 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17852,6 +17852,8 @@ with pkgs; plm = callPackage ../applications/science/programming/plm { }; + scyther = callPackage_i686 ../applications/science/programming/scyther { }; + ### SCIENCE/LOGIC abc-verifier = callPackage ../applications/science/logic/abc {}; From 313b8b7e4bc232880b6732aa990b681eee45f628 Mon Sep 17 00:00:00 2001 From: Silvan Mosberger Date: Sun, 23 Jul 2017 03:17:38 +0200 Subject: [PATCH 2/2] scyther: Separated into two derivations --- .../science/programming/scyther/cli.nix | 32 +++++ .../science/programming/scyther/default.nix | 123 +++++++++--------- pkgs/top-level/all-packages.nix | 2 +- 3 files changed, 93 insertions(+), 64 deletions(-) create mode 100644 pkgs/applications/science/programming/scyther/cli.nix diff --git a/pkgs/applications/science/programming/scyther/cli.nix b/pkgs/applications/science/programming/scyther/cli.nix new file mode 100644 index 00000000000..152b7121774 --- /dev/null +++ b/pkgs/applications/science/programming/scyther/cli.nix @@ -0,0 +1,32 @@ +{ stdenv, glibc, flex, bison, cmake +, version, src, meta }: +stdenv.mkDerivation { + name = "scyther-cli-${version}"; + + inherit src meta; + + buildInputs = [ + cmake + glibc.static + flex + bison + ]; + + 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 + ''; + + configurePhase = '' + (cd src && cmakeConfigurePhase) + ''; + + dontUseCmakeBuildDir = true; + cmakeFlags = [ "-DCMAKE_C_FLAGS=-std=gnu89" ]; + + installPhase = '' + mkdir -p "$out/bin" + mv src/scyther-linux "$out/bin/scyther-cli" + ln -s "$out/bin/scyther-cli" "$out/bin/scyther-linux" + ''; +} diff --git a/pkgs/applications/science/programming/scyther/default.nix b/pkgs/applications/science/programming/scyther/default.nix index 6e009067e4e..beef26c6032 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,64 +12,6 @@ stdenv.mkDerivation { repo = "scyther"; }; - buildInputs = [ - cmake - glibc.static - flex - bison - ] ++ lib.optional includeGUI [ - python27Packages.wrapPython - ]; - - 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\"" - - # Removes the Shebang from the file, as this would be wrapped wrongly - sed -i -e "1d" $file - ''; - - configurePhase = '' - (cd src && cmakeConfigurePhase) - ''; - - propagatedBuildInputs = lib.optional includeGUI [ - python27Packages.wxPython - graphviz - ]; - - dontUseCmakeBuildDir = true; - cmakeFlags = [ "-DCMAKE_C_FLAGS=-std=gnu89" ]; - - 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" - ''); - - postFixup = lib.optionalString includeGUI '' - wrapPythonProgramsIn "$out/gui" "$out $pythonPath" - ''; - - doInstallCheck = includeGUI; - installCheckPhase = '' - "$out/gui/scyther.py" "$src/gui/Protocols/Demo/ns3.spdl" - ''; - 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/; @@ -79,4 +19,61 @@ stdenv.mkDerivation { maintainers = with maintainers; [ infinisil ]; platforms = platforms.linux; }; -} + + cli = callPackage_i686 ./cli.nix { + inherit version src meta; + }; + + gui = stdenv.mkDerivation { + name = "scyther-gui-${version}"; + inherit src meta; + buildInputs = [ + python27Packages.wrapPython + ]; + + patchPhase = '' + 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 \"${cli}/bin\"" + + # Removes the Shebang from the file, as this would be wrapped wrongly + sed -i -e "1d" $file + ''; + + dontBuild = true; + + 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" + ''; + + 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" + ''; + } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 9c52320c83e..5f85bdc86c7 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -17852,7 +17852,7 @@ with pkgs; plm = callPackage ../applications/science/programming/plm { }; - scyther = callPackage_i686 ../applications/science/programming/scyther { }; + scyther = callPackage ../applications/science/programming/scyther { }; ### SCIENCE/LOGIC