<commit_before>x@{builderDefsPackage
  , fetchgit, perl, xulrunner, cmake, perlPackages, zip, unzip, pkgconfig
  , libpulseaudio, glib, gtk, pixman, nspr, nss, libXScrnSaver, scrnsaverproto
  , ...}:
builderDefsPackage
(a :  
let 
  helperArgNames = ["stdenv" "fetchurl" "builderDefsPackage"] ++ 
    ["fetchgit" "perlPackages"];

  buildInputs = map (n: builtins.getAttr n x)
    (builtins.attrNames (builtins.removeAttrs x helperArgNames)) ++ [
      a.perlPackages.SubName a.gtk a.glib
    ];
  sourceInfo = rec {
    baseName="oneteam";
    version="git-head";
    name="${baseName}-${version}";
    url="git://git.process-one.net/oneteam/oneteam.git";
    rev="066cd861ea4436bbe363f032c58a746a1cac7498";
    hash="972310d6ef20db7dc749d7d935aa50889afe2004db2a07409830e09ef639f30a";
    method="fetchgit";
  };
in
rec {
  srcDrv = a.fetchgit {
    url = sourceInfo.url;
    sha256 = sourceInfo.hash;
    rev = sourceInfo.rev;
  };

  src=srcDrv + "/";

  inherit (sourceInfo) name version;
  inherit buildInputs;

  /* doConfigure should be removed if not needed */
  phaseNames = ["goComponents" "setVars" "fixComponents" "doCmake" 
    "doMakeInstall" "goBack" "buildApp" "doDeploy"];

  fixComponents = a.fullDepEntry ''
    sed -e '1i#include <netinet/in.h>' -i src/rtp/otRTPDecoder.cpp src/rtp/otRTPEncoder.cpp
  '' ["minInit" "doUnpack"];

  setVars=a.noDepEntry ''
    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${nspr.dev}/include/nspr"
  '';

  cmakeBuildDir="cmake-build";
  cmakeFlags=["-D XPCOM_GECKO_SDK=${xulrunner}/lib/xulrunner-devel-${xulrunner.version}"];

  goComponents=a.fullDepEntry "cd src/components" ["doUnpack"];
  goBack=a.noDepEntry "cd ../../..";

  buildApp=a.fullDepEntry ''
    perl build.pl XULAPP 1
  '' ["addInputs"];

  doDeploy = a.fullDepEntry ''
    TARGET_DIR="$out/share/oneteam/app"
    BUILD_DIR="$PWD"
    mkdir -p "$TARGET_DIR"
    cd "$TARGET_DIR"
    unzip "$BUILD_DIR/oneteam.xulapp"
    mkdir -p "$out/bin"
    echo "#! ${a.stdenv.shell}" > "$out/bin/oneteam"
    echo "\"${xulrunner}/bin/xulrunner\" \"$TARGET_DIR/application.ini\"" > "$out/bin/oneteam"
    chmod a+x "$out/bin/oneteam"
    mkdir -p "$out/share/doc"
    cp -r "$BUILD_DIR/docs" "$out/share/doc/oneteam"
  '' ["defEnsureDir"];

  meta = {
    description = "An XMPP client";
    maintainers = with a.lib.maintainers;
    [
      raskin
    ];
    license = a.lib.licenses.gpl2;
    homepage="http://oneteam.im";
  };
  passthru = {
    updateInfo = {
      downloadPage = "git://git.process-one.net/oneteam/oneteam.git";
    };
  };
}) x
<commit_msg>oneteam: port to stdenv.mkDerivation<commit_after>{ stdenv, fetchFromGitHub
, perl, xulrunner, cmake, perlPackages, zip, unzip, pkgconfig
, libpulseaudio, glib, gtk, pixman, nspr, nss, libXScrnSaver
, scrnsaverproto
}:

stdenv.mkDerivation rec {
  name = "oneteam-unstable-2013-02-21";

  src = fetchFromGitHub {
    repo = "oneteam";
    owner = "processone";
    rev = "c51bc545c3a32db4ea8b96e43b84fcfc6b8d3d2a";
    sha256 = "19104fwdaf0nnsr5w755fg8wwww5sh96wmn939gxa5ah155nf2w3";
  };

  nativeBuildInputs = [ pkgconfig cmake zip unzip ];

  buildInputs =
    [ perl xulrunner libpulseaudio glib gtk pixman nspr
      nss libXScrnSaver scrnsaverproto
    ] ++ [ perlPackages.SubName gtk glib ];

  postPatch = ''
    sed -e '1i#include <netinet/in.h>' -i src/rtp/otRTPDecoder.cpp src/rtp/otRTPEncoder.cpp
  '';

  cmakeBuildDir = "cmake-build";
  cmakeFlags = ["-D XPCOM_GECKO_SDK=${xulrunner}/lib/xulrunner-devel-${xulrunner.version}"];

  buildPhase = ''
    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I${nspr.dev}/include/nspr"
    cd src/components
    perl build.pl XULAPP 1
    cd ../../
  '';

  installPhase = ''
    TARGET_DIR="$out/share/oneteam/app"
    BUILD_DIR="$PWD"
    mkdir -p "$TARGET_DIR"
    cd "$TARGET_DIR"
    unzip "$BUILD_DIR/oneteam.xulapp"
    mkdir -p "$out/bin"
    echo "#! ${stdenv.shell}" > "$out/bin/oneteam"
    echo "\"${xulrunner}/bin/xulrunner\" \"$TARGET_DIR/application.ini\"" > "$out/bin/oneteam"
    chmod a+x "$out/bin/oneteam"
    mkdir -p "$out/share/doc"
    cp -r "$BUILD_DIR/docs" "$out/share/doc/oneteam"
  '';

  meta = {
    description = "An XMPP client";
    maintainers = with stdenv.lib.maintainers; [ raskin ];
    license = stdenv.lib.licenses.gpl2;
    homepage="http://oneteam.im";
  };

  passthru = {
    updateInfo = {
      downloadPage = "git://github.com/processone/oneteam";
    };
  };
}
{'fraction_non_alphanumeric': 0.15795403334835512, 'fraction_numerical': 0.029517800811176206, 'mean_word_length': 3.479313824419778, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '375523', 'n_tokens_mistral': 1872, 'n_tokens_neox': 1769, 'n_words': 284}