{ runCommand, lib, makeWrapper, python3
, archivers ? [ python3.pkgs.mailman-hyperkitty ]
}:

let
  inherit (python3.pkgs) makePythonPath mailman;
in

runCommand "${mailman.name}-wrapped" {
  inherit (mailman) meta;
  buildInputs = [ makeWrapper ];
  passthru = mailman.passthru // { unwrapped = mailman; };
} ''
  mkdir -p "$out/bin"
  cd "${mailman}/bin"
  for exe in *; do
    makeWrapper "${mailman}/bin/$exe" "$out/bin/$exe" \
        --set PYTHONPATH ${makePythonPath ([ mailman python3.pkgs.urllib3 ] ++ archivers)}
  done
''

Revert "mailman-wrapper: crazy hack to work around the missing urllib3 dependency"

{ runCommand, lib, makeWrapper, python3
, archivers ? [ python3.pkgs.mailman-hyperkitty ]
}:

let
  inherit (python3.pkgs) makePythonPath mailman;
in

runCommand "${mailman.name}-wrapped" {
  inherit (mailman) meta;
  buildInputs = [ makeWrapper ];
  passthru = mailman.passthru // { unwrapped = mailman; };
} ''
  mkdir -p "$out/bin"
  cd "${mailman}/bin"
  for exe in *; do
    makeWrapper "${mailman}/bin/$exe" "$out/bin/$exe" \
        --set PYTHONPATH ${makePythonPath ([ mailman ] ++ archivers)}
  done
''


{ stdenv, fetchgit, openssl }:

let
  version = "3.1.2";

in stdenv.mkDerivation rec {
  name = "wrk-${version}";

  src = fetchgit {
    url = "https://github.com/wg/wrk.git";
    rev = "a52c770204a732aa63e1bb6eb241a70949e3a2a9";
    sha256 = "0b81lg251ivi94f7kfgz8ws4xns5p7hw5qiwjwwlc3dimjgrg387";
  };

  NIX_CFLAGS_COMPILE = "-I${openssl}/include";
  NIX_CFLAGS_LINK = "-L${openssl}/lib";

  installPhase = ''
    mkdir -p $out/bin
    cp wrk $out/bin
  '';

  meta = with stdenv.lib; {
    description = "HTTP benchmarking tool";
    homepage = http://github.com/wg/wrk;
    longDescription = ''
      wrk is a modern HTTP benchmarking tool capable of generating
      significant load when run on a single multi-core CPU. It
      combines a multithreaded design with scalable event notification
      systems such as epoll and kqueue.
    '';
    license = licenses.asl20;
    maintainers = with maintainers; [ ragge ];
    platforms = platforms.linux;
  };
}

Update from 3.1.2 to 4.0.0 (master)

{ stdenv, fetchgit, openssl }:

let
  version = "4.0.0";

in stdenv.mkDerivation rec {
  name = "wrk-${version}";

  src = fetchgit {
    url = "https://github.com/wg/wrk.git";
    rev = "7cdede916a53da253c995767a92eec36a245a2cc";
    sha256 = "0m8i5pk2rj40v28bzrskkzw54v9jqdby52dwfcypannhlhgqnhy2";
  };

  buildInputs = [ openssl ];

  installPhase = ''
    mkdir -p $out/bin
    cp wrk $out/bin
  '';

  meta = with stdenv.lib; {
    description = "HTTP benchmarking tool";
    homepage = http://github.com/wg/wrk;
    longDescription = ''
      wrk is a modern HTTP benchmarking tool capable of generating
      significant load when run on a single multi-core CPU. It
      combines a multithreaded design with scalable event notification
      systems such as epoll and kqueue.
    '';
    license = licenses.asl20;
    maintainers = with maintainers; [ ragge ];
    platforms = platforms.linux;
  };
}


{ lib, stdenv, fetchurl }:

stdenv.mkDerivation {
  name = "yes-no";

  src = fetchurl {
    url = "https://github.com/emacsmirror/emacswiki.org/blob/185fdc34fb1e02b43759ad933d3ee5646b0e78f8/yes-no.el";
    sha256 = "1k0nn619i82jiqm48k5nk6b8cv2rggh0i5075nhc85a2s9pwhx32";
  };

  dontUnpack = true;

  installPhase = ''
    install -d $out/share/emacs/site-lisp
    install $src $out/share/emacs/site-lisp/yes-no.el
  '';

  meta = with lib; {
    description = "Specify use of `y-or-n-p' or `yes-or-no-p' on a case-by-case basis";
    homepage = "https://www.emacswiki.org/emacs/yes-no.el";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ jcs090218 ];
    platforms = platforms.all;
  };
}

Use trivialPackage instead of stdenv.mkDerivation

{ lib, fetchurl, trivialBuild }:

trivialBuild {
  pname = "yes-no";
  version = "0";

  src = fetchurl {
    url = "https://github.com/emacsmirror/emacswiki.org/blob/185fdc34fb1e02b43759ad933d3ee5646b0e78f8/yes-no.el";
    sha256 = "1k0nn619i82jiqm48k5nk6b8cv2rggh0i5075nhc85a2s9pwhx32";
  };

  dontUnpack = true;

  installPhase = ''
    install -d $out/share/emacs/site-lisp
    install $src $out/share/emacs/site-lisp/yes-no.el
  '';

  meta = with lib; {
    description = "Specify use of `y-or-n-p' or `yes-or-no-p' on a case-by-case basis";
    homepage = "https://www.emacswiki.org/emacs/yes-no.el";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ jcs090218 ];
    platforms = platforms.all;
  };
}


{ stdenv, fetchurl, gnu-efi, unzip, pkgconfig, utillinux, libxslt, docbook_xsl, docbook_xml_dtd_42 }:

stdenv.mkDerivation rec {
  name = "gummiboot-43";

  buildInputs = [ gnu-efi pkgconfig libxslt utillinux ];

  # Sigh, gummiboot should be able to find this in buildInputs
  configureFlags = [
    "--with-efi-includedir=${gnu-efi}/include"
    "--with-efi-libdir=${gnu-efi}/lib"
    "--with-efi-ldsdir=${gnu-efi}/lib"
  ];

  src = fetchurl {
    url = http://pkgs.fedoraproject.org/repo/pkgs/gummiboot/gummiboot-43.tar.xz/c9b46a3504a2f7e335404a1475818d98/gummiboot-43.tar.xz;
    sha256 = "1hwaan3985ap9r5ncf9bykbaixbm0xn4x09silssngwfl2srn4iv";
  };

  meta = {
    description = "A simple UEFI boot manager which executes configured EFI images";

    homepage = http://freedesktop.org/wiki/Software/gummiboot;

    license = stdenv.lib.licenses.lgpl21Plus;

    platforms = [ "x86_64-linux" "i686-linux" ];

    maintainers = [ stdenv.lib.maintainers.shlevy ];
  };
}

Update gummiboot to the latest

{ stdenv, fetchurl, gnu-efi, unzip, pkgconfig, utillinux, libxslt, docbook_xsl, docbook_xml_dtd_42 }:

stdenv.mkDerivation rec {
  name = "gummiboot-45";

  buildInputs = [ gnu-efi pkgconfig libxslt utillinux ];

  # Sigh, gummiboot should be able to find this in buildInputs
  configureFlags = [
    "--with-efi-includedir=${gnu-efi}/include"
    "--with-efi-libdir=${gnu-efi}/lib"
    "--with-efi-ldsdir=${gnu-efi}/lib"
  ];

  src = fetchurl {
    url = http://pkgs.fedoraproject.org/repo/pkgs/gummiboot/gummiboot-45.tar.xz/5d4957390e959cb9f325b87712ddd3f1/gummiboot-45.tar.xz;
    md5 = "5d4957390e959cb9f325b87712ddd3f1";
  };

  meta = {
    description = "A simple UEFI boot manager which executes configured EFI images";

    homepage = http://freedesktop.org/wiki/Software/gummiboot;

    license = stdenv.lib.licenses.lgpl21Plus;

    platforms = [ "x86_64-linux" "i686-linux" ];

    maintainers = [ stdenv.lib.maintainers.shlevy ];
  };
}


{ stdenv
, fetchurl
}:

let
  version = "5.1.0";
in
stdenv.mkDerivation rec {
  name = "jemalloc-${version}";

  src = fetchurl {
    url = "https://github.com/jemalloc/jemalloc/releases/download/${version}/"
      + "${name}.tar.bz2";
    sha256 = "5396e61cc6103ac393136c309fae09e44d74743c86f90e266948c50f3dbb7268";
  };

  disableStatic = false;

  meta = with stdenv.lib; {
    homepage = http://www.canonware.com/jemalloc/index.html;
    description = "General purpose malloc(3) implementation";
    license = licenses.bsd2;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}

Make it possible to build with a function prefix

{ stdenv
, fetchurl

, functionPrefix ? null
}:

let
  version = "5.1.0";

  inherit (stdenv.lib)
    optionals;
in
stdenv.mkDerivation rec {
  name = "jemalloc-${version}";

  src = fetchurl {
    url = "https://github.com/jemalloc/jemalloc/releases/download/${version}/"
      + "${name}.tar.bz2";
    sha256 = "5396e61cc6103ac393136c309fae09e44d74743c86f90e266948c50f3dbb7268";
  };

  configureFlags = optionals (functionPrefix != null) [
    "--with-jemalloc-prefix=${functionPrefix}"
  ];

  disableStatic = false;

  meta = with stdenv.lib; {
    homepage = http://www.canonware.com/jemalloc/index.html;
    description = "General purpose malloc(3) implementation";
    license = licenses.bsd2;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}


{ fetchurl, stdenv, perl }:

stdenv.mkDerivation rec {
  name = "namazu-2.0.18";

  src = fetchurl {
    url = "http://namazu.org/stable/${name}.tar.gz";
    sha256 = "12i5z830yh5sw3087gmna44742gcw2q7lpj6b94k8fj0h45cm26j";
  };

  buildInputs = [ perl ];

  # First install the `File::MMagic' Perl module.
  # !!! this shouldn't refer to Perl 5.10.0!
  preConfigure = ''
    ( cd File-MMagic &&				\
      perl Makefile.PL				\
        LIB="$out/lib/perl5/site_perl/5.10.0"	\
        INSTALLSITEMAN3DIR="$out/man" &&	\
      make && make install )
    export PERL5LIB="$out/lib/site_perl/5.10.0:$PERL5LIB"
  '';

  doCheck = true;

  meta = {
    description = "Namazu, a full-text search engine";

    longDescription = ''
      Namazu is a full-text search engine intended for easy use.  Not
      only does it work as a small or medium scale Web search engine,
      but also as a personal search system for email or other files.
    '';

    license = "GPLv2+";
    homepage = http://namazu.org/;
  };
}

Fix builds, broken in r15324.

{ fetchurl, stdenv, perl }:

stdenv.mkDerivation rec {
  name = "namazu-2.0.18";

  src = fetchurl {
    url = "http://namazu.org/stable/${name}.tar.gz";
    sha256 = "12i5z830yh5sw3087gmna44742gcw2q7lpj6b94k8fj0h45cm26j";
  };

  buildInputs = [ perl ];

  # First install the `File::MMagic' Perl module.
  # !!! this shouldn't refer to Perl 5.10.0!
  preConfigure = ''
    ( cd File-MMagic &&				\
      perl Makefile.PL				\
        LIB="$out/lib/perl5/site_perl/5.10.0"	\
        INSTALLSITEMAN3DIR="$out/man" &&	\
      make && make install )
    export PERL5LIB="$out/lib/perl5/site_perl/5.10.0:$PERL5LIB"
  '';

  doCheck = true;

  meta = {
    description = "Namazu, a full-text search engine";

    longDescription = ''
      Namazu is a full-text search engine intended for easy use.  Not
      only does it work as a small or medium scale Web search engine,
      but also as a personal search system for email or other files.
    '';

    license = "GPLv2+";
    homepage = http://namazu.org/;
  };
}


{ stdenv, fetchurl, boost, cmake, ilmbase, libjpeg, libpng, libtiff
, opencolorio, openexr, unzip
}:

stdenv.mkDerivation rec {
  name = "oiio-${version}";
  version = "1.4.15";

  src = fetchurl {
    url = "https://github.com/OpenImageIO/oiio/archive/Release-${version}.zip";
    sha256 = "1fc5v3qmrzf9qx765fd15r2dc3ccrz4xf4f9q4cwsrspmaxqyqzs";
  };

  buildInputs = [
    boost cmake ilmbase libjpeg libpng libtiff opencolorio openexr
    unzip
  ];

  cmakeFlags = [
    "-DUSE_PYTHON=OFF"
  ];

  buildPhase = ''
    make ILMBASE_HOME=${ilmbase} OPENEXR_HOME=${openexr} USE_PYTHON=0 \
      INSTALLDIR=$out dist_dir=
  '';

  meta = with stdenv.lib; {
    homepage = http://www.openimageio.org;
    description = "A library and tools for reading and writing images";
    license = licenses.bsd3;
    maintainers = [ maintainers.goibhniu ];
    platforms = platforms.linux;
  };
}

Update to 1.4.16 and fix name

{ stdenv, fetchurl, boost, cmake, ilmbase, libjpeg, libpng, libtiff
, opencolorio, openexr, unzip
}:

stdenv.mkDerivation rec {
  name = "openimageio-${version}";
  version = "1.4.16";

  src = fetchurl {
    url = "https://github.com/OpenImageIO/oiio/archive/Release-${version}.zip";
    sha256 = "0f9gspsjhniz992c04dm4lvffzz7zjqn1n34nqn6c32r498kimcj";
  };

  buildInputs = [
    boost cmake ilmbase libjpeg libpng libtiff opencolorio openexr
    unzip
  ];

  cmakeFlags = [
    "-DUSE_PYTHON=OFF"
  ];

  buildPhase = ''
    make ILMBASE_HOME=${ilmbase} OPENEXR_HOME=${openexr} USE_PYTHON=0 \
      INSTALLDIR=$out dist_dir=
  '';

  enableParallelBuilding = true;

  meta = with stdenv.lib; {
    homepage = http://www.openimageio.org;
    description = "A library and tools for reading and writing images";
    license = licenses.bsd3;
    maintainers = [ maintainers.goibhniu ];
    platforms = platforms.linux;
  };
}


{ stdenv, fetchurl, zlib, nettools }:

stdenv.mkDerivation rec {
  name = "iodine-0.6.0-rc1";

  src = fetchurl {
    url = "http://code.kryo.se/iodine/${name}.tar.gz";
    sha256 = "dacf950198b68fd1dae09fe980080155b0c75718f581c08e069eee0c1b6c5e60";
  };

  buildInputs = [ zlib ];

  patchPhase = ''sed -i "s,/sbin/ifconfig,${nettools}/sbin/ifconfig,; s,/sbin/route,${nettools}/sbin/route," src/tun.c'';

  installFlags = "prefix=\${out}";

  meta = {
    homepage = http://code.kryo.se/iodine/;
    description = "Tool to tunnel IPv4 data through a DNS server";
    license = "ISC";
  };
}

Fix iptables and route path to bin instead of sbin

{ stdenv, fetchurl, zlib, nettools }:

stdenv.mkDerivation rec {
  name = "iodine-0.6.0-rc1";

  src = fetchurl {
    url = "http://code.kryo.se/iodine/${name}.tar.gz";
    sha256 = "dacf950198b68fd1dae09fe980080155b0c75718f581c08e069eee0c1b6c5e60";
  };

  buildInputs = [ zlib ];

  patchPhase = ''sed -i "s,/sbin/ifconfig,${nettools}/bin/ifconfig,; s,/sbin/route,${nettools}/bin/route," src/tun.c'';

  installFlags = "prefix=\${out}";

  meta = {
    homepage = http://code.kryo.se/iodine/;
    description = "Tool to tunnel IPv4 data through a DNS server";
    license = "ISC";
  };
}


{ pkgs ? (import <nixpkgs> {}) }:

let
  env = with pkgs.rustPlatform; [
    rustc
    cargo
  ];
in

pkgs.stdenv.mkDerivation rec {
    name = "unfug.org";
    src = ./.;
    version = "0.0.0";

    buildInputs = [ env ];

}

Fix the actual project name

{ pkgs ? (import <nixpkgs> {}) }:

let
  env = with pkgs.rustPlatform; [
    rustc
    cargo
  ];
in

pkgs.stdenv.mkDerivation rec {
    name = "imag";
    src = ./.;
    version = "0.0.0";

    buildInputs = [ env ];

}


{ lib, python3Packages, fetchFromGitHub }:

python3Packages.buildPythonApplication rec {
  pname = "ntfy";
  version = "2.7.0";

  src = fetchFromGitHub {
    owner = "dschep";
    repo = "ntfy";
    rev = "v${version}";
    sha256 = "09f02cn4i1l2aksb3azwfb70axqhn7d0d0vl2r6640hqr74nc1cv";
  };

  checkInputs = with python3Packages; [
    mock
  ];

  propagatedBuildInputs = with python3Packages; [
    requests ruamel_yaml appdirs
    sleekxmpp dnspython
    emoji
    psutil
    matrix-client
    dbus-python
    ntfy-webpush
  ];

  checkPhase = ''
    HOME=$(mktemp -d) ${python3Packages.python.interpreter} setup.py test
  '';

  meta = with lib; {
    description = "A utility for sending notifications, on demand and when commands finish";
    homepage = "http://ntfy.rtfd.org/";
    license = licenses.gpl3;
    maintainers = with maintainers; [ jfrankenau kamilchm ];
  };
}

Patch Slack integration to work again.

{ lib, python3Packages, fetchFromGitHub, fetchpatch }:

python3Packages.buildPythonApplication rec {
  pname = "ntfy";
  version = "2.7.0";

  src = fetchFromGitHub {
    owner = "dschep";
    repo = "ntfy";
    rev = "v${version}";
    sha256 = "09f02cn4i1l2aksb3azwfb70axqhn7d0d0vl2r6640hqr74nc1cv";
  };

  checkInputs = with python3Packages; [
    mock
  ];

  propagatedBuildInputs = with python3Packages; [
    requests ruamel_yaml appdirs
    sleekxmpp dnspython
    emoji
    psutil
    matrix-client
    dbus-python
    ntfy-webpush
    slack-sdk
  ];

  patches = [
    # Fix Slack integration no longer working.
    # From https://github.com/dschep/ntfy/pull/229 - "Swap Slacker for Slack SDK"
    (fetchpatch {
      name = "ntfy-Swap-Slacker-for-Slack-SDK.patch";
      url = "https://github.com/dschep/ntfy/commit/2346e7cfdca84c8f1afc7462a92145c1789deb3e.patch";
      sha256 = "13k7jbsdx0jx7l5s8whirric76hml5bznkfcxab5xdp88q52kpk7";
    })
  ];

  checkPhase = ''
    HOME=$(mktemp -d) ${python3Packages.python.interpreter} setup.py test
  '';

  meta = with lib; {
    description = "A utility for sending notifications, on demand and when commands finish";
    homepage = "http://ntfy.rtfd.org/";
    license = licenses.gpl3;
    maintainers = with maintainers; [ jfrankenau kamilchm ];
  };
}


with import <nixpkgs> {};

stdenv.mkDerivation {
  name = "jasmin-0";
  src = ./.;
  buildInputs = [ ]
    ++ (with python3Packages; [ python pyyaml ])
    ++ (with coqPackages_8_6; [ coq mathcomp ])
    ++ (with ocamlPackages; [ ocaml findlib ocaml_batteries menhir zarith ])
    ;
}

Make explicit the dependency to ocamlbuild

with import <nixpkgs> {};

stdenv.mkDerivation {
  name = "jasmin-0";
  src = ./.;
  buildInputs = [ ]
    ++ (with python3Packages; [ python pyyaml ])
    ++ (with coqPackages_8_6; [ coq mathcomp ])
    ++ (with ocamlPackages; [ ocaml findlib ocamlbuild ocaml_batteries menhir zarith ])
    ;
}


{ buildGoModule, fetchFromGitHub, lib }:

buildGoModule rec {
  pname = "gotify-cli";
  version = "2.1.1";

  src = fetchFromGitHub {
    owner = "gotify";
    repo = "cli";
    rev = "v${version}";
    sha256 = "131gs6xzfggnrzq5jgyky23zvcmhx3q3hd17xvqxd02s2i9x1mg4";
  };

  vendorSha256 = "1lhhsf944gm1p6qxn05g2s3hdnra5dggj7pdrdq6qr6r2xg7f5qh";

  doCheck = false;

  postInstall = ''
    mv $out/bin/cli $out/bin/gotify
  '';

  meta = with lib; {
    license = licenses.mit;
    homepage = "https://github.com/gotify/cli";
    description = "A command line interface for pushing messages to gotify/server.";
    maintainers = with maintainers; [ ma27 ];
  };
}

Add version and commit to ldflags

{ buildGoModule, fetchFromGitHub, lib }:

buildGoModule rec {
  pname = "gotify-cli";
  version = "2.1.1";

  src = fetchFromGitHub {
    owner = "gotify";
    repo = "cli";
    rev = "v${version}";
    sha256 = "131gs6xzfggnrzq5jgyky23zvcmhx3q3hd17xvqxd02s2i9x1mg4";
  };

  vendorSha256 = "1lhhsf944gm1p6qxn05g2s3hdnra5dggj7pdrdq6qr6r2xg7f5qh";

  doCheck = false;

  postInstall = ''
    mv $out/bin/cli $out/bin/gotify
  '';

  buildFlagsArray = [
    "-ldflags=-X main.Version=${version} -X main.Commit=${version} -X main.BuildDate=1970-01-01"
  ];

  meta = with lib; {
    license = licenses.mit;
    homepage = "https://github.com/gotify/cli";
    description = "A command line interface for pushing messages to gotify/server.";
    maintainers = with maintainers; [ ma27 ];
  };
}


# this is the config for my own user.
#
{ config, pkgs, ... }:

{
  users.users.kyle = {
    isNormalUser = true;
    extraGroups = [ "audio" "wheel" ]; # Enable ‘sudo’ for the user.
    initialHashedPassword =
      "$6$hYiIwvTIv$2Z3lBfOQYi4IymaU2CLW2UwJcLfAvtEt1zAw5LJ/qtWQ/rnDEVLmwtaTJW4iUfRAH9QjzV10rHm06wgqvSXWt1";
    shell = pkgs.zsh;
    openssh.authorizedKeys.keys = [
      # juice ssh for android
      "ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBCY48p/4M/8CcfQgq/4J/bYRflVQ2MFovineycMxsEorlW50oOm1SJ8nn2qAAE75bxgbqbmFPBNdV1JUx/9DAnTITqw13lKdb09M2c59NQN6LjaL1SUbboiSxiwv6hHtAg== JuiceSSH"
    ];
  };
}

Add Kyle to docker group

# this is the config for my own user.
#
{ config, pkgs, ... }:

{
  users.users.kyle = {
    isNormalUser = true;
    extraGroups = [ "audio" "docker" "wheel" ]; # Enable ‘sudo’ for the user.
    initialHashedPassword =
      "$6$hYiIwvTIv$2Z3lBfOQYi4IymaU2CLW2UwJcLfAvtEt1zAw5LJ/qtWQ/rnDEVLmwtaTJW4iUfRAH9QjzV10rHm06wgqvSXWt1";
    shell = pkgs.zsh;
    openssh.authorizedKeys.keys = [
      # juice ssh for android
      "ecdsa-sha2-nistp384 AAAAE2VjZHNhLXNoYTItbmlzdHAzODQAAAAIbmlzdHAzODQAAABhBCY48p/4M/8CcfQgq/4J/bYRflVQ2MFovineycMxsEorlW50oOm1SJ8nn2qAAE75bxgbqbmFPBNdV1JUx/9DAnTITqw13lKdb09M2c59NQN6LjaL1SUbboiSxiwv6hHtAg== JuiceSSH"
    ];
  };
}


{ stdenv, fetchFromGitHub, autoreconfHook, perl }:

stdenv.mkDerivation rec {
  pname = "glog";
  version = "0.4.0";

  src = fetchFromGitHub {
    owner = "google";
    repo = "glog";
    rev = "v${version}";
    sha256 = "1xd3maiipfbxmhc9rrblc5x52nxvkwxp14npg31y5njqvkvzax9b";
  };

  nativeBuildInputs = [ autoreconfHook ];

  checkInputs = [ perl ];
  doCheck = false; # fails with "Mangled symbols (28 out of 380) found in demangle.dm"

  meta = with stdenv.lib; {
    homepage = https://github.com/google/glog;
    license = licenses.bsd3;
    description = "Library for application-level logging";
    platforms = platforms.unix;
  };
}

Add upstream patch to fix tests with musl.

{ stdenv, lib, fetchFromGitHub, fetchpatch, autoreconfHook, perl }:

stdenv.mkDerivation rec {
  pname = "glog";
  version = "0.4.0";

  src = fetchFromGitHub {
    owner = "google";
    repo = "glog";
    rev = "v${version}";
    sha256 = "1xd3maiipfbxmhc9rrblc5x52nxvkwxp14npg31y5njqvkvzax9b";
  };

  patches = lib.optionals stdenv.hostPlatform.isMusl [
    # TODO: Remove at next release that includes this commit.
    (fetchpatch {
      name = "glog-Fix-symbolize_unittest-for-musl-builds.patch";
      url = "https://github.com/google/glog/commit/834dd780bf1fe0704b8ed0350ca355a55f711a9f.patch";
      sha256 = "0k4lanxg85anyvjsj3mh93bcgds8gizpiamcy2zvs3yyfjl40awn";
    })
  ];

  nativeBuildInputs = [ autoreconfHook ];

  checkInputs = [ perl ];
  doCheck = false; # fails with "Mangled symbols (28 out of 380) found in demangle.dm"

  meta = with stdenv.lib; {
    homepage = https://github.com/google/glog;
    license = licenses.bsd3;
    description = "Library for application-level logging";
    platforms = platforms.unix;
  };
}


{ stdenv, buildPythonPackage, fetchFromGitHub
, six, ecdsa, rsa, future, pytest, cryptography, pycryptodome
}:

buildPythonPackage rec {
  pname = "python-jose";
  version = "3.0.0";

  # no tests in PyPI tarball
  src = fetchFromGitHub {
    owner = "mpdavis";
    repo = "python-jose";
    rev = version;
    sha256 = "1dq8v87abqxv07wi403ywjk9jg1da125fviycqzki48cjxx0dhwj";
  };

  checkInputs = [
    pytest
    # optional dependencies, but needed in tests
    cryptography pycryptodome
  ];
  checkPhase = ''
    py.test
  '';

  propagatedBuildInputs = [ six ecdsa rsa future ];

  meta = with stdenv.lib; {
    homepage = https://github.com/mpdavis/python-jose;
    description = "A JOSE implementation in Python";
    license = licenses.mit;
    maintainers = [ maintainers.jhhuh ];
  };
}

Revert "python.pkgs.python-jose: 2.0.2 -> 3.0.0"

{ stdenv, buildPythonPackage, fetchFromGitHub
, future, six, ecdsa, pycryptodome, pytest, cryptography
}:

buildPythonPackage rec {
  pname = "python-jose";
  version = "2.0.2";

  # no tests in PyPI tarball
  src = fetchFromGitHub {
    owner = "mpdavis";
    repo = "python-jose";
    # 2.0.2 not tagged on GitHub
    # see https://github.com/mpdavis/python-jose/issues/86
    rev = "28cc6719eceb89129eed59c25f7bdac015665bdd";
    sha256 = "03wkq2rszy0rzy5gygsh4s7i6ls8zflgbcvxnflvmh7nis7002fp";
  };

  checkInputs = [
    pytest
    cryptography # optional dependency, but needed in tests
  ];
  checkPhase = ''
    py.test
  '';

  propagatedBuildInputs = [ future six ecdsa pycryptodome ];

  meta = with stdenv.lib; {
    homepage = https://github.com/mpdavis/python-jose;
    description = "A JOSE implementation in Python";
    license = licenses.mit;
    maintainers = [ maintainers.jhhuh ];
  };
}


{ sources ? null }:
let
  deps = import ./nix/deps.nix { inherit sources; };
  pkgs = deps.pkgs;
  caBundle = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";

in pkgs.mkShell {
  name = "ekklesia-portal";
  buildInputs = deps.shellInputs;
  # A pure nix shell breaks SSL for git and nix tools which is fixed by setting the path to the certificate bundle.
  shellHook = ''
    export LOCALE_ARCHIVE=${deps.glibcLocales}/lib/locale/locale-archive
    export PYTHONPATH=./src:../ekklesia-common/src
    export PATH=${deps.shellPath}:$PATH
    export NIX_SSL_CERT_FILE=${caBundle}
    export SSL_CERT_FILE=${caBundle}
    export SASS_PATH=${deps.sassPath}
    export JS_PATH=${deps.jsPath}
    export WEBFONTS_PATH=${deps.webfontsPath}
  '';
}

Set LOCALE_ARCHIVE only on glibc systems

{ sources ? null }:
let
  deps = import ./nix/deps.nix { inherit sources; };
  inherit (deps) pkgs;
  inherit (pkgs) lib stdenv;
  caBundle = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";

in pkgs.mkShell {
  name = "ekklesia-portal";
  buildInputs = deps.shellInputs;
  # A pure nix shell breaks SSL for git and nix tools which is fixed by setting
  # the path to the certificate bundle.
  shellHook = ''
    export JS_PATH=${deps.jsPath}
    export NIX_SSL_CERT_FILE=${caBundle}
    export PATH=${deps.shellPath}:$PATH
    export PYTHONPATH=./src:../ekklesia-common/src
    export SASS_PATH=${deps.sassPath}
    export SSL_CERT_FILE=${caBundle}
    export WEBFONTS_PATH=${deps.webfontsPath}
  '' +
  lib.optionalString (pkgs.stdenv.hostPlatform.libc == "glibc") ''
    export LOCALE_ARCHIVE=${deps.glibcLocales}/lib/locale/locale-archive
  '';
}


{ lib, buildGoModule, fetchFromGitLab }:

buildGoModule rec {
  pname = "bluewalker";
  version = "0.3.0";

  src = fetchFromGitLab {
    owner = "jtaimisto";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-spuJRiNiaBV4EsetUq8vUfR6ejUNZxLhVzS3AZZyrrQ=";
  };

  vendorSha256 = "189qs6vmx63vwsjmc4qgf1y8xjsi7x6l1f5c3kd8j8jnagl26z4h";

  ldflags = [ # omit some things for a smaller binary
    "-w" # omit the DWARF symbol table
    "-s" # omit symbol table and debug info
  ];

  meta = with lib; {
    description = "Simple command line Bluetooth LE scanner";
    homepage = src.meta.homepage;
    changelog = "https://gitlab.com/jtaimisto/${pname}/-/raw/master/CHANGELOG";
    license = licenses.bsd2;
    maintainers = with maintainers; [ cimm ];
    platforms = platforms.linux;
  };
}

Remove obvious comments from ldflags

{ lib, buildGoModule, fetchFromGitLab }:

buildGoModule rec {
  pname = "bluewalker";
  version = "0.3.0";

  src = fetchFromGitLab {
    owner = "jtaimisto";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-spuJRiNiaBV4EsetUq8vUfR6ejUNZxLhVzS3AZZyrrQ=";
  };

  vendorSha256 = "189qs6vmx63vwsjmc4qgf1y8xjsi7x6l1f5c3kd8j8jnagl26z4h";

  ldflags = [
    "-w"
    "-s"
  ];

  meta = with lib; {
    description = "Simple command line Bluetooth LE scanner";
    homepage = src.meta.homepage;
    changelog = "https://gitlab.com/jtaimisto/${pname}/-/raw/master/CHANGELOG";
    license = licenses.bsd2;
    maintainers = with maintainers; [ cimm ];
    platforms = platforms.linux;
  };
}


{ config, pkgs, ... }:

with pkgs.lib;

{

  options.services.hardware.pommed = {
    enable = mkOption {
      default = false;
       description = ''
        Whether to use the pommed tool to handle Apple laptop keyboard hotkeys.
      '';
    };

    configFile = mkOption {
      default = builtins.toPath "${pkgs.pommed}/etc/pommed.conf";
      description = ''
        The contents of the pommed.conf file.
      '';
    };
  };

  config = mkIf config.services.hardware.pommed.enable {
    environment.systemPackages = [ pkgs.polkit ];

    environment.etc = [
      { source = config.services.hardware.pommed.configFile;
        target = "pommed.conf";
      }
    ];

    services.dbus.packages = [ pkgs.pommed ];

    jobs.pommed = { name = "pommed";

      description = "Pommed hotkey management";

      startOn = "started dbus";

      postStop = "rm -f /var/run/pommed.pid";

      exec = "${pkgs.pommed}/bin/pommed";

      daemonType = "fork";

      path = [ pkgs.eject ];
    };
  };
}

Remove unnecessary toPath that breaks with recent nixUnstable

{ config, pkgs, ... }:

with pkgs.lib;

{

  options.services.hardware.pommed = {
    enable = mkOption {
      default = false;
       description = ''
        Whether to use the pommed tool to handle Apple laptop keyboard hotkeys.
      '';
    };

    configFile = mkOption {
      default = "${pkgs.pommed}/etc/pommed.conf";
      description = ''
        The contents of the pommed.conf file.
      '';
    };
  };

  config = mkIf config.services.hardware.pommed.enable {
    environment.systemPackages = [ pkgs.polkit ];

    environment.etc = [
      { source = config.services.hardware.pommed.configFile;
        target = "pommed.conf";
      }
    ];

    services.dbus.packages = [ pkgs.pommed ];

    jobs.pommed = { name = "pommed";

      description = "Pommed hotkey management";

      startOn = "started dbus";

      postStop = "rm -f /var/run/pommed.pid";

      exec = "${pkgs.pommed}/bin/pommed";

      daemonType = "fork";

      path = [ pkgs.eject ];
    };
  };
}


# generic builder for Emacs packages

{ lib, stdenv, emacs, texinfo }:

with lib;

{ pname
, version ? null

, buildInputs ? []
, packageRequires ? []

, meta ? {}

, ...
}@args:

let

  defaultMeta = {
    broken = false;
    platforms = emacs.meta.platforms;
  } // optionalAttrs ((args.src.meta.homepage or "") != "") {
    homepage = args.src.meta.homepage;
  };

in

stdenv.mkDerivation ({
  name = "emacs-${pname}${optionalString (version != null) "-${version}"}";

  unpackCmd = ''
    case "$curSrc" in
      *.el)
        # keep original source filename without the hash
        local filename=$(basename "$curSrc")
        filename="''${filename:33}"
        cp $curSrc $filename
        chmod +w $filename
        sourceRoot="."
        ;;
      *)
        _defaultUnpack "$curSrc"
        ;;
    esac
  '';

  buildInputs = [emacs texinfo] ++ packageRequires ++ buildInputs;
  propagatedBuildInputs = packageRequires;
  propagatedUserEnvPkgs = packageRequires;

  setupHook = ./setup-hook.sh;

  doCheck = false;

  meta = defaultMeta // meta;
}

// removeAttrs args [ "buildInputs" "packageRequires"
                      "meta"
                    ])

Add native builds for nativeComp enabled emacsen

# generic builder for Emacs packages

{ lib, stdenv, emacs, texinfo }:

with lib;

{ pname
, version ? null

, buildInputs ? []
, packageRequires ? []

, meta ? {}

, ...
}@args:

let

  defaultMeta = {
    broken = false;
    platforms = emacs.meta.platforms;
  } // optionalAttrs ((args.src.meta.homepage or "") != "") {
    homepage = args.src.meta.homepage;
  };

in

stdenv.mkDerivation ({
  name = "emacs-${pname}${optionalString (version != null) "-${version}"}";

  unpackCmd = ''
    case "$curSrc" in
      *.el)
        # keep original source filename without the hash
        local filename=$(basename "$curSrc")
        filename="''${filename:33}"
        cp $curSrc $filename
        chmod +w $filename
        sourceRoot="."
        ;;
      *)
        _defaultUnpack "$curSrc"
        ;;
    esac
  '';

  buildInputs = [emacs texinfo] ++ packageRequires ++ buildInputs;
  propagatedBuildInputs = packageRequires;
  propagatedUserEnvPkgs = packageRequires;

  setupHook = ./setup-hook.sh;

  doCheck = false;

  meta = defaultMeta // meta;
}

// lib.optionalAttrs (emacs.nativeComp or false) {

  LIBRARY_PATH = "${lib.getLib stdenv.cc.libc}/lib";

  postInstall = ''
    find $out/share/emacs -type f -name '*.el' -print0 | xargs -0 -n 1 -I {} -P $NIX_BUILD_CORES sh -c "emacs --batch -f batch-native-compile {} || true"
  '';

}

// removeAttrs args [ "buildInputs" "packageRequires"
                      "meta"
                    ])


{ fetchFromGitHub, stdenv, autoreconfHook, ncurses }:

stdenv.mkDerivation rec {
  name = "htop-1.0.3-186-gf2c053a";

  src = fetchFromGitHub {
    sha256 = "017aihyg0bjli1hlvcqgqxpwzy2ayvwv6byhqd97n9sqfkmi9i0p";
    rev = "f2c053a88497f3ad5ae786c16ecf1275212c13be";
    repo = "htop";
    owner = "hishamhm";
  };

  buildInputs = [ ncurses ];
  nativeBuildInputs = [ autoreconfHook ];

  meta = {
    description = "An interactive process viewer for Linux";
    homepage = "http://htop.sourceforge.net";
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [ rob simons relrod ];
  };
}

Update to fix issues with ncurses 6.0

{ fetchFromGitHub, stdenv, autoreconfHook, ncurses }:

stdenv.mkDerivation rec {
  name = "htop-1.0.3-584-8f07868f";

  src = fetchFromGitHub {
    sha256 = "0s7l9v7n7hw32hznvdq2sykyxgb30hmzycwcjxw8f0c2mww61xcd";
    rev = "8f07868fefeb844a852fab704c0763b0e9a9bf01";
    repo = "htop";
    owner = "hishamhm";
  };

  buildInputs = [ ncurses ];
  nativeBuildInputs = [ autoreconfHook ];

  meta = {
    description = "An interactive process viewer for Linux";
    homepage = "http://htop.sourceforge.net";
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [ rob simons relrod ];
  };
}


{ stdenv
, fetchurl
, perl

, acl
, gmp
, selinuxSupport? false, libselinux, libsepol
}:

let
  inherit (stdenv.lib) optionals;
in
stdenv.mkDerivation rec {
  name = "coreutils-8.25";

  src = fetchurl {
    url = "mirror://gnu/coreutils/${name}.tar.xz";
    sha256 = "11yfrnb94xzmvi4lhclkcmkqsbhww64wf234ya1aacjvg82prrii";
  };

  nativeBuildInputs = [
    perl
  ];

  buildInputs = [
    acl
    gmp
  ] ++ optionals selinuxSupport [
    libselinux
    libsepol
  ];

  doCheck = true;

  meta = with stdenv.lib; {
    homepage = http://www.gnu.org/software/coreutils/;
    description = "The basic file, shell and text manipulation utilities of the GNU operating system";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      i686-linux
      ++ x86_64-linux;
  };
}

Make priority higher than other providers

{ stdenv
, fetchurl
, perl

, acl
, gmp
, selinuxSupport? false, libselinux, libsepol
}:

let
  inherit (stdenv.lib) optionals;
in
stdenv.mkDerivation rec {
  name = "coreutils-8.25";

  src = fetchurl {
    url = "mirror://gnu/coreutils/${name}.tar.xz";
    sha256 = "11yfrnb94xzmvi4lhclkcmkqsbhww64wf234ya1aacjvg82prrii";
  };

  nativeBuildInputs = [
    perl
  ];

  buildInputs = [
    acl
    gmp
  ] ++ optionals selinuxSupport [
    libselinux
    libsepol
  ];

  doCheck = true;

  meta = with stdenv.lib; {
    homepage = http://www.gnu.org/software/coreutils/;
    description = "The basic file, shell and text manipulation utilities of the GNU operating system";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      i686-linux
      ++ x86_64-linux;
    priority = 20;  # This should have a higher priority than everything
  };
}


import (fetchTarball {
  url = "https://github.com/NixOS/nixpkgs/archive/17812e653d89c46d68b7b10e290b1c16758f4e47.tar.gz";
  sha256 = "1zcb70dyfqc8l2ywpbvxmpfshapdi0g365m3rhmwpagqg47pnyxs";
})

Update ref for ocamlformat 0.15

import (fetchTarball {
  url = "https://github.com/NixOS/nixpkgs/archive/3c0e3697520cbe7d9eb3a64bfd87de840bf4aa77.tar.gz";
  sha256 = "1vx7kyaq0i287dragjgfdj94ggwr3ky2b7bq32l8rkd2k3vc3gl5";
})


{ stdenv
, fetchurl
, coreutils
}:

stdenv.mkDerivation rec {
  name = "findutils-4.6.0";

  src = fetchurl {
    url = "mirror://gnu/findutils/${name}.tar.gz";
    sha256 = "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y";
  };

  doCheck = true;

  # Remove any references to the bootstrap tools
  preFixup = ''
    sed -i "s,$NIX_STORE.*/sort,${coreutils}/bin/sort,g" $out/bin/updatedb
  '';

  meta = with stdenv.lib; {
    homepage = http://www.gnu.org/software/findutils/;
    description = "GNU Find Utilities, the basic directory searching utilities of the GNU operating system";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = platforms.all;
  };
}

Remove sed hack for buildInput

{ stdenv
, fetchurl
, coreutils
}:

stdenv.mkDerivation rec {
  name = "findutils-4.6.0";

  src = fetchurl {
    url = "mirror://gnu/findutils/${name}.tar.gz";
    sha256 = "178nn4dl7wbcw499czikirnkniwnx36argdnqgz4ik9i6zvwkm6y";
  };

  # We don't want to depend on bootstrap-tools
  # This input forces the build system to use our
  # newly built coreutils instead.
  buildInputs = [
    coreutils
  ];

  doCheck = true;

  meta = with stdenv.lib; {
    homepage = http://www.gnu.org/software/findutils/;
    description = "GNU Find Utilities, the basic directory searching utilities of the GNU operating system";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      i686-linux
      ++ x86_64-linux;
  };
}


{ stdenv, lib, fetchFromGitHub, cmake }:

# This was originally called mkl-dnn, then it was renamed to dnnl, and it has
# just recently been renamed again to oneDNN. See here for details:
# https://github.com/oneapi-src/oneDNN#oneapi-deep-neural-network-library-onednn
stdenv.mkDerivation rec {
  pname = "oneDNN";
  version = "2.5.2";

  src = fetchFromGitHub {
    owner = "oneapi-src";
    repo = "oneDNN";
    rev = "v${version}";
    sha256 = "sha256-HBCuSZkApd/6UkAxz/KDFb/gyX2SI1S2GwgXAXSTU/c=";
  };

  outputs = [ "out" "dev" "doc" ];

  nativeBuildInputs = [ cmake ];

  # Tests fail on some Hydra builders, because they do not support SSE4.2.
  doCheck = false;

  meta = with lib; {
    description = "oneAPI Deep Neural Network Library (oneDNN)";
    homepage = "https://01.org/oneDNN";
    changelog = "https://github.com/oneapi-src/oneDNN/releases/tag/v${version}";
    license = licenses.asl20;
    platforms = platforms.all;
    maintainers = with maintainers; [ alexarice bhipple ];
  };
}

Revert "oneDNN: 2.3.2 -> 2.5.2"

{ stdenv, lib, fetchFromGitHub, cmake }:

# This was originally called mkl-dnn, then it was renamed to dnnl, and it has
# just recently been renamed again to oneDNN. See here for details:
# https://github.com/oneapi-src/oneDNN#oneapi-deep-neural-network-library-onednn
stdenv.mkDerivation rec {
  pname = "oneDNN";
  version = "2.7.1";

  src = fetchFromGitHub {
    owner = "oneapi-src";
    repo = "oneDNN";
    rev = "v${version}";
    sha256 = "sha256-HBCuSZkApd/6UkAxz/KDFb/gyX2SI1S2GwgXAXSTU/c=";
  };

  outputs = [ "out" "dev" "doc" ];

  nativeBuildInputs = [ cmake ];

  # Tests fail on some Hydra builders, because they do not support SSE4.2.
  doCheck = false;

  meta = with lib; {
    description = "oneAPI Deep Neural Network Library (oneDNN)";
    homepage = "https://01.org/oneDNN";
    changelog = "https://github.com/oneapi-src/oneDNN/releases/tag/v${version}";
    license = licenses.asl20;
    platforms = platforms.all;
    maintainers = with maintainers; [ alexarice bhipple ];
  };
}


{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder

# Python dependencies
, openpyxl
, pandas
, pandas-stubs
, requests
, tqdm
, wandb

# Check dependencies
, pytest-mock
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "openai";
  version = "0.16.0";

  disabled = pythonOlder "3.7.1";

  # Use GitHub source since PyPi source does not include tests
  src = fetchFromGitHub {
    owner = "openai";
    repo = "openai-python";
    rev = "v${version}";
    sha256 = "sha256-9BxFOiGIf3Cy7OU0as6onV5ltECInM9wwCr+qCMuPbU=";
  };

  propagatedBuildInputs = [
    openpyxl
    pandas
    pandas-stubs
    requests
    tqdm
    wandb
  ];

  pythonImportsCheck = [ "openai" ];
  checkInputs = [ pytestCheckHook pytest-mock ];
  pytestFlagsArray = [ "openai/tests" ];
  OPENAI_API_KEY = "sk-foo";
  disabledTestPaths = [
    "openai/tests/test_endpoints.py" # requires a real API key
    "openai/tests/test_file_cli.py"
  ];

  meta = with lib; {
    description = "Python client library for the OpenAI API";
    homepage = "https://github.com/openai/openai-python";
    license = licenses.mit;
    maintainers = [ maintainers.malo ];
  };
}

Revert "openai: add python3Packages.wandb dependency"

{ lib
, buildPythonPackage
, fetchFromGitHub
, pythonOlder

# Python dependencies
, openpyxl
, pandas
, pandas-stubs
, requests
, tqdm

# Check dependencies
, pytest-mock
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "openai";
  version = "0.16.0";

  disabled = pythonOlder "3.7.1";

  # Use GitHub source since PyPi source does not include tests
  src = fetchFromGitHub {
    owner = "openai";
    repo = "openai-python";
    rev = "v${version}";
    sha256 = "sha256-9BxFOiGIf3Cy7OU0as6onV5ltECInM9wwCr+qCMuPbU=";
  };

  propagatedBuildInputs = [
    openpyxl
    pandas
    pandas-stubs
    requests
    tqdm
  ];

  pythonImportsCheck = [ "openai" ];
  checkInputs = [ pytestCheckHook pytest-mock ];
  pytestFlagsArray = [ "openai/tests" ];
  OPENAI_API_KEY = "sk-foo";
  disabledTestPaths = [
    "openai/tests/test_endpoints.py" # requires a real API key
    "openai/tests/test_file_cli.py"
  ];

  meta = with lib; {
    description = "Python client library for the OpenAI API";
    homepage = "https://github.com/openai/openai-python";
    license = licenses.mit;
    maintainers = [ maintainers.malo ];
  };
}


{ lib, stdenv, fetchFromGitHub, ctags, perl, elfutils, vtable-dumper }:

stdenv.mkDerivation rec {
  pname = "abi-dumper";
  version = "1.2";

  src = fetchFromGitHub {
    owner = "lvc";
    repo = "abi-dumper";
    rev = version;
    sha256 = "1i00rfnddrrb9lb1l6ib19g3a76pyasl9lb7rqz2p998gav1gjp2";
  };

  patchPhase = ''
    substituteInPlace abi-dumper.pl \
      --replace eu-readelf ${elfutils}/bin/eu-readelf \
      --replace vtable-dumper ${vtable-dumper}/bin/vtable-dumper \
      --replace '"ctags"' '"${ctags}/bin/ctags"'
  '';

  nativeBuildInputs = [ perl ];

  preBuild = "mkdir -p $out";
  makeFlags = [ "prefix=$(out)" ];

  meta = with lib; {
    homepage = "https://github.com/lvc/abi-dumper";
    description = "Dump ABI of an ELF object containing DWARF debug info";
    license = licenses.lgpl21;
    maintainers = [ maintainers.bhipple ];
    platforms = platforms.all;
  };
}

Revert "abi-dumper: fix cross compilation"

{ lib, stdenv, fetchFromGitHub, ctags, perl, elfutils, vtable-dumper }:

stdenv.mkDerivation rec {
  pname = "abi-dumper";
  version = "1.2";

  src = fetchFromGitHub {
    owner = "lvc";
    repo = "abi-dumper";
    rev = version;
    sha256 = "1i00rfnddrrb9lb1l6ib19g3a76pyasl9lb7rqz2p998gav1gjp2";
  };

  patchPhase = ''
    substituteInPlace abi-dumper.pl \
      --replace eu-readelf ${elfutils}/bin/eu-readelf \
      --replace vtable-dumper ${vtable-dumper}/bin/vtable-dumper \
      --replace '"ctags"' '"${ctags}/bin/ctags"'
  '';

  buildInputs = [ elfutils ctags perl vtable-dumper ];

  preBuild = "mkdir -p $out";
  makeFlags = [ "prefix=$(out)" ];

  meta = with lib; {
    homepage = "https://github.com/lvc/abi-dumper";
    description = "Dump ABI of an ELF object containing DWARF debug info";
    license = licenses.lgpl21;
    maintainers = [ maintainers.bhipple ];
    platforms = platforms.all;
  };
}


# This function downloads and normalizes a patch/diff file.
# This is primarily useful for dynamically generated patches,
# such as GitHub's or cgit's, where the non-significant content parts
# often change with updating of git or cgit.
# stripLen acts as the -p parameter when applying a patch.

{ lib, fetchurl, patchutils }:
{ stripLen ? 0, extraPrefix ? null, excludes ? [], ... }@args:

fetchurl ({
  postFetch = ''
    tmpfile="$TMPDIR/${args.sha256}"
    "${patchutils}/bin/lsdiff" "$out" \
      | sort -u | sed -e 's/[*?]/\\&/g' \
      | xargs -I{} \
        "${patchutils}/bin/filterdiff" \
        --include={} \
        --strip=${toString stripLen} \
        ${lib.optionalString (extraPrefix != null) ''
           --addoldprefix=a/${extraPrefix} \
           --addnewprefix=b/${extraPrefix} \
        ''} \
        --clean "$out" > "$tmpfile"
    ${patchutils}/bin/filterdiff \
      -p1 \
      ${builtins.toString (builtins.map (x: "-x ${x}") excludes)} \
      "$tmpfile" > "$out"
    ${args.postFetch or ""}
  '';
} // builtins.removeAttrs args ["stripLen" "extraPrefix" "excludes" "postFetch"])

Add includes to compliment excludes, and require that both not be non-empty.

# This function downloads and normalizes a patch/diff file.
# This is primarily useful for dynamically generated patches,
# such as GitHub's or cgit's, where the non-significant content parts
# often change with updating of git or cgit.
# stripLen acts as the -p parameter when applying a patch.

{ lib, fetchurl, patchutils }:
{ stripLen ? 0, extraPrefix ? null, excludes ? [], includes ? [], ... }@args:

fetchurl ({
  postFetch = ''
    tmpfile="$TMPDIR/${args.sha256}"
    "${patchutils}/bin/lsdiff" "$out" \
      | sort -u | sed -e 's/[*?]/\\&/g' \
      | xargs -I{} \
        "${patchutils}/bin/filterdiff" \
        --include={} \
        --strip=${toString stripLen} \
        ${lib.optionalString (extraPrefix != null) ''
           --addoldprefix=a/${extraPrefix} \
           --addnewprefix=b/${extraPrefix} \
        ''} \
        --clean "$out" > "$tmpfile"
    ${patchutils}/bin/filterdiff \
      -p1 \
      ${builtins.toString (builtins.map (x: "-x ${x}") excludes)} \
      ${builtins.toString (builtins.map (x: "-i ${x}") includes)} \
      "$tmpfile" > "$out"
    ${args.postFetch or ""}
  '';
  meta.broken = excludes != [] && includes != [];
} // builtins.removeAttrs args ["stripLen" "extraPrefix" "excludes" "includes" "postFetch"])


{ stdenv, fetchurl, flex, bison }:

stdenv.mkDerivation rec {
  name = "libpcap-1.9.0";

  src = fetchurl {
    url = "https://www.tcpdump.org/release/${name}.tar.gz";
    sha256 = "06bhydl4vr4z9c3vahl76f2j96z1fbrcl7wwismgs4sris08inrf";
  };

  nativeBuildInputs = [ flex bison ];

  # We need to force the autodetection because detection doesn't
  # work in pure build enviroments.
  configureFlags = [
    ("--with-pcap=" + {
      linux = "linux";
      darwin = "bpf";
    }.${stdenv.hostPlatform.parsed.kernel.name})
  ] ++ stdenv.lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [
    "ac_cv_linux_vers=2"
  ];

  dontStrip = stdenv.hostPlatform != stdenv.buildPlatform;

  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
    substituteInPlace configure --replace " -arch i386" ""
  '';

  preInstall = ''mkdir -p $out/bin'';

  meta = with stdenv.lib; {
    homepage = https://www.tcpdump.org;
    description = "Packet Capture Library";
    platforms = platforms.unix;
    maintainers = with maintainers; [ fpletz ];
    license = licenses.bsd3;
  };
}

Add missing include, fix w/musl

{ stdenv, fetchurl, flex, bison }:

stdenv.mkDerivation rec {
  name = "libpcap-1.9.0";

  src = fetchurl {
    url = "https://www.tcpdump.org/release/${name}.tar.gz";
    sha256 = "06bhydl4vr4z9c3vahl76f2j96z1fbrcl7wwismgs4sris08inrf";
  };

  nativeBuildInputs = [ flex bison ];

  # We need to force the autodetection because detection doesn't
  # work in pure build enviroments.
  configureFlags = [
    ("--with-pcap=" + {
      linux = "linux";
      darwin = "bpf";
    }.${stdenv.hostPlatform.parsed.kernel.name})
  ] ++ stdenv.lib.optionals (stdenv.hostPlatform == stdenv.buildPlatform) [
    "ac_cv_linux_vers=2"
  ];

  dontStrip = stdenv.hostPlatform != stdenv.buildPlatform;

  prePatch = stdenv.lib.optionalString stdenv.isDarwin ''
    substituteInPlace configure --replace " -arch i386" ""
  '' + ''
    sed -i '1i#include <limits.h>' pcap-usb-linux.c
  '';

  preInstall = ''mkdir -p $out/bin'';

  meta = with stdenv.lib; {
    homepage = https://www.tcpdump.org;
    description = "Packet Capture Library";
    platforms = platforms.unix;
    maintainers = with maintainers; [ fpletz ];
    license = licenses.bsd3;
  };
}


{ config, pkgs, nixpkgs, lib, ... }:
let
  nixFlakes = (pkgs.writeScriptBin "nixFlakes" ''
      exec ${pkgs.nixUnstable}/bin/nix --experimental-features "nix-command flakes" "$@"
    '');
in {
  imports = [
    ../common.nix
    ../common-linux.nix
  ];

  services.emacs.enable = true;

  programs.zsh.shellAliases.bat = "batcat";

  home.packages = with pkgs; [
    zlib
    dmenu
    autorandr
    arandr
    picom
    espeak
    blink1-tool
    flameshot
    nyxt
    byzanz
    xrectsel
    dunst
    libnotify
    gnome-icon-theme
    _1password
    nixFlakes
    xmonad-with-packages
    sass
    esbuild
    pavucontrol
  ];

  home.file.".xsessionrc".text = ''
    export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$HOME/.local/bin:$PATH
    xset r rate 200 50
    '';

  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "1password"
    "skypeforlinux"
    "slack"
    "spotify"
    "spotify-unwrapped"
    "vscode"
    "vscode-with-extensions"
    "zoom"
  ];
}

Add mysql and vscode on debian host

{ config, pkgs, nixpkgs, lib, ... }:
let
  nixFlakes = (pkgs.writeScriptBin "nixFlakes" ''
      exec ${pkgs.nixUnstable}/bin/nix --experimental-features "nix-command flakes" "$@"
    '');
in {
  imports = [
    ../common.nix
    ../common-linux.nix
  ];

  services.emacs.enable = true;

  programs.zsh.shellAliases.bat = "batcat";

  home.packages = with pkgs; [
    zlib
    dmenu
    autorandr
    arandr
    picom
    espeak
    blink1-tool
    flameshot
    nyxt
    byzanz
    xrectsel
    dunst
    libnotify
    gnome-icon-theme
    _1password
    nixFlakes
    xmonad-with-packages
    sass
    esbuild
    pavucontrol
    mysql
    vscode
  ];

  home.file.".xsessionrc".text = ''
    export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$HOME/.local/bin:$PATH
    xset r rate 200 50
    '';

  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "1password"
    "skypeforlinux"
    "slack"
    "spotify"
    "spotify-unwrapped"
    "vscode"
    "vscode-with-extensions"
    "zoom"
  ];
}


# VirtualBox server
{ config, pkgs, ... }:

with pkgs.lib;

let

  cfg = config.services.virtualbox;

in

{

  ###### interface

  options = {

    services.virtualbox = {

      enable = mkOption {
        default = false;
        description = "Whether to enable the VirtualBox service and other guest additions.";
      };

    };

  };

  ###### implementation

  config = mkIf cfg.enable {

    environment.systemPackages = [ ];

    boot.extraModulePackages = [ pkgs.linuxPackages.virtualboxGuestAdditions ];

    jobs.virtualbox =
      { description = "VirtualBox service";

        startOn = "started udev";

        exec = "${pkgs.linuxPackages.virtualboxGuestAdditions}/sbin/VBoxService";
      };

  };

}

Make VirtualBox Guest Additions use the configured kernel.

# VirtualBox server
{ config, pkgs, ... }:

with pkgs.lib;

let

  cfg = config.services.virtualbox;
  kernel = config.boot.kernelPackages;

in

{

  ###### interface

  options = {

    services.virtualbox = {

      enable = mkOption {
        default = false;
        description = "Whether to enable the VirtualBox service and other guest additions.";
      };

    };

  };

  ###### implementation

  config = mkIf cfg.enable {

    environment.systemPackages = [ ];

    boot.extraModulePackages = [ kernel.virtualboxGuestAdditions ];

    jobs.virtualbox =
      { description = "VirtualBox service";

        startOn = "started udev";

        exec = "${kernel.virtualboxGuestAdditions}/sbin/VBoxService";
      };

  };

}


{ stdenv
, fetchurl
, libtsm
, systemd
, libxkbcommon
, libdrm
, mesa
, pango
, pixman
, pkgconfig
, docbook_xsl
, libxslt
}:

stdenv.mkDerivation rec {
  name = "kmscon-8";

  src = fetchurl {
    url = "http://www.freedesktop.org/software/kmscon/releases/${name}.tar.xz";
    sha256 = "0axfwrp3c8f4gb67ap2sqnkn75idpiw09s35wwn6kgagvhf1rc0a";
  };

  buildInputs = [
    libtsm
    systemd
    libxkbcommon
    libdrm
    mesa
    pango
    pixman
    pkgconfig
    docbook_xsl
    libxslt
  ];

  configureFlags = [
    "--enable-multi-seat"
    "--disable-debug"
    "--enable-optimizations"
    "--with-renderers=bbulk,gltex,pixman"
  ];

  meta = {
    description = "KMS/DRM based System Console";
    homepage = "http://www.freedesktop.org/wiki/Software/kmscon/";
    license = stdenv.lib.licenses.mit;
    platforms = stdenv.lib.platforms.linux;
  };
}

Fix build against systemd 230

{ stdenv
, fetchurl
, libtsm
, systemd
, libxkbcommon
, libdrm
, mesa
, pango
, pixman
, pkgconfig
, docbook_xsl
, libxslt
}:

stdenv.mkDerivation rec {
  name = "kmscon-8";

  src = fetchurl {
    url = "http://www.freedesktop.org/software/kmscon/releases/${name}.tar.xz";
    sha256 = "0axfwrp3c8f4gb67ap2sqnkn75idpiw09s35wwn6kgagvhf1rc0a";
  };

  buildInputs = [
    libtsm
    systemd
    libxkbcommon
    libdrm
    mesa
    pango
    pixman
    pkgconfig
    docbook_xsl
    libxslt
  ];

  # FIXME: Remove as soon as kmscon > 8 comes along.
  postPatch = ''
    sed -i -e 's/libsystemd-daemon libsystemd-login/libsystemd/g' configure
  '';

  configureFlags = [
    "--enable-multi-seat"
    "--disable-debug"
    "--enable-optimizations"
    "--with-renderers=bbulk,gltex,pixman"
  ];

  meta = {
    description = "KMS/DRM based System Console";
    homepage = "http://www.freedesktop.org/wiki/Software/kmscon/";
    license = stdenv.lib.licenses.mit;
    platforms = stdenv.lib.platforms.linux;
  };
}


{ stdenv, fetchurl, pam, glibc }:

stdenv.mkDerivation rec {
  name = "shadow-4.1.4.2";

  src = fetchurl {
    url = "http://pkg-shadow.alioth.debian.org/releases/${name}.tar.bz2";
    sha256 = "1449ny7pdnwkavg92wvibapnkgdq5pas38nvl1m5xa37g5m7z64p";
  };

  buildInputs = [ pam ];

  patches = [ ./no-sanitize-env.patch ./su-name.patch ./keep-path.patch ];

  preBuild =
    ''
      substituteInPlace lib/nscd.c --replace /usr/sbin/nscd ${glibc}/sbin/nscd
    '';

  meta = {
    homepage = http://pkg-shadow.alioth.debian.org/;
    description = "Suite containing authentication-related tools such as passwd and su";
  };
}

Make Linux-PAM optional; allow cross-compilation.

{ stdenv, fetchurl, pam ? null, glibcCross ? null }:

let
  glibc = if stdenv ? cross
          then glibcCross
          else stdenv.glibc;
in
stdenv.mkDerivation rec {
  name = "shadow-4.1.4.2";

  src = fetchurl {
    url = "http://pkg-shadow.alioth.debian.org/releases/${name}.tar.bz2";
    sha256 = "1449ny7pdnwkavg92wvibapnkgdq5pas38nvl1m5xa37g5m7z64p";
  };

  buildInputs = stdenv.lib.optional (pam != null && stdenv.isLinux) pam;

  patches = [ ./no-sanitize-env.patch ./su-name.patch ./keep-path.patch ];

  # Assume System V `setpgrp (void)', which is the default on GNU variants
  # (`AC_FUNC_SETPGRP' is not cross-compilation capable.)
  preConfigure = "export ac_cv_func_setpgrp_void=yes";

  preBuild = assert glibc != null;
    ''
      substituteInPlace lib/nscd.c --replace /usr/sbin/nscd ${glibc}/sbin/nscd
    '';

  meta = {
    homepage = http://pkg-shadow.alioth.debian.org/;
    description = "Suite containing authentication-related tools such as passwd and su";
  };
}


{ substituteAll
, perl
, shadow
, util-linux
, configurationDirectory ? "/etc/nixos-containers"
, stateDirectory ? "/var/lib/nixos-containers"
}:

substituteAll {
    name = "nixos-container";
    dir = "bin";
    isExecutable = true;
    src = ./nixos-container.pl;
    perl = perl.withPackages (p: [ p.FileSlurp ]);
    su = "${shadow.su}/bin/su";
    utillinux = util-linux;

    inherit configurationDirectory stateDirectory;

    postInstall = ''
      t=$out/share/bash-completion/completions
      mkdir -p $t
      cp ${./nixos-container-completion.sh} $t/nixos-container
    '';
}

Add tests to passthru for CI

{ substituteAll
, perl
, shadow
, util-linux
, configurationDirectory ? "/etc/nixos-containers"
, stateDirectory ? "/var/lib/nixos-containers"
, nixosTests
}:

substituteAll {
    name = "nixos-container";
    dir = "bin";
    isExecutable = true;
    src = ./nixos-container.pl;
    perl = perl.withPackages (p: [ p.FileSlurp ]);
    su = "${shadow.su}/bin/su";
    utillinux = util-linux;

    inherit configurationDirectory stateDirectory;

    passthru = {
      tests = {
        inherit (nixosTests)
          containers-imperative
          containers-ip
          containers-tmpfs
          containers-ephemeral
          ;
      };
    };

    postInstall = ''
      t=$out/share/bash-completion/completions
      mkdir -p $t
      cp ${./nixos-container-completion.sh} $t/nixos-container
    '';
}


{stdenv, fetchurl, zlib, openssl, libre, librem}:
stdenv.mkDerivation rec {
  version = "0.4.2";
  name = "restund-${version}";
  src=fetchurl {
    url = "http://www.creytiv.com/pub/restund-${version}.tar.gz";
    sha256 = "db5260939d40cb2ce531075bef02b9d6431067bdd52f3168a6f25246bdf7b9f2";
  };
  buildInputs = [zlib openssl libre librem];
  makeFlags = [
    "LIBRE_MK=${libre}/share/re/re.mk"
    "LIBRE_INC=${libre}/include/re"
    "LIBRE_SO=${libre}/lib"
    "LIBREM_PATH=${librem}"
    ''PREFIX=$(out)''
  ]
  ++ stdenv.lib.optional (stdenv.gcc.gcc != null) "SYSROOT_ALT=${stdenv.gcc.gcc}"
  ++ stdenv.lib.optional (stdenv.gcc.libc != null) "SYSROOT=${stdenv.gcc.libc}"
  ;
  meta = {
    homepage = "http://www.creytiv.com/restund.html";
    platforms = with stdenv.lib.platforms; linux;
    maintainers = with stdenv.lib.maintainers; [raskin];
    license = with stdenv.lib.licenses; bsd3;
  };
}

Add support for authentication via user list in MySQL to restund

{stdenv, fetchurl, zlib, openssl, libre, librem, mysql}:
stdenv.mkDerivation rec {
  version = "0.4.2";
  name = "restund-${version}";
  src=fetchurl {
    url = "http://www.creytiv.com/pub/restund-${version}.tar.gz";
    sha256 = "db5260939d40cb2ce531075bef02b9d6431067bdd52f3168a6f25246bdf7b9f2";
  };
  buildInputs = [zlib openssl libre librem mysql];
  makeFlags = [
    "LIBRE_MK=${libre}/share/re/re.mk"
    "LIBRE_INC=${libre}/include/re"
    "LIBRE_SO=${libre}/lib"
    "LIBREM_PATH=${librem}"
    ''PREFIX=$(out)''
    "USE_MYSQL=1"
  ]
  ++ stdenv.lib.optional (stdenv.gcc.gcc != null) "SYSROOT_ALT=${stdenv.gcc.gcc}"
  ++ stdenv.lib.optional (stdenv.gcc.libc != null) "SYSROOT=${stdenv.gcc.libc}"
  ;
  NIX_LDFLAGS='' -L${mysql}/lib/mysql '';
  meta = {
    homepage = "http://www.creytiv.com/restund.html";
    platforms = with stdenv.lib.platforms; linux;
    maintainers = with stdenv.lib.maintainers; [raskin];
    license = with stdenv.lib.licenses; bsd3;
  };
}


{ stdenv, fetchurl, libarchive }:

stdenv.mkDerivation rec {
  name = "microcode-intel-${version}";
  version = "20180108";

  src = fetchurl {
    url = "https://downloadmirror.intel.com/27431/eng/microcode-${version}.tgz";
    sha256 = "0c214238mjks07zwif07f4041c74jil522sy78r4kjs6lniilgq6";
  };

  buildInputs = [ libarchive ];

  sourceRoot = ".";

  buildPhase = ''
    gcc -O2 -Wall -o intel-microcode2ucode ${./intel-microcode2ucode.c}
    ./intel-microcode2ucode microcode.dat
  '';

  installPhase = ''
    mkdir -p $out kernel/x86/microcode
    mv microcode.bin kernel/x86/microcode/GenuineIntel.bin
    echo kernel/x86/microcode/GenuineIntel.bin | bsdcpio -o -H newc -R 0:0 > $out/intel-ucode.img
  '';

  meta = with stdenv.lib; {
    homepage = http://www.intel.com/;
    description = "Microcode for Intel processors";
    license = licenses.unfreeRedistributableFirmware;
    maintainers = with maintainers; [ wkennington ];
    platforms = platforms.linux;
  };
}

Revert "microcodeIntel: 20171117 -> 20170108"

{ stdenv, fetchurl, libarchive }:

stdenv.mkDerivation rec {
  name = "microcode-intel-${version}";
  version = "20171117";

  src = fetchurl {
    url = "https://downloadmirror.intel.com/27337/eng/microcode-${version}.tgz";
    sha256 = "1p14ypbg28bdkbza6dx6dpjrdr5p13vmgrh2cw0y1v2qzalivgck";
  };

  buildInputs = [ libarchive ];

  sourceRoot = ".";

  buildPhase = ''
    gcc -O2 -Wall -o intel-microcode2ucode ${./intel-microcode2ucode.c}
    ./intel-microcode2ucode microcode.dat
  '';

  installPhase = ''
    mkdir -p $out kernel/x86/microcode
    mv microcode.bin kernel/x86/microcode/GenuineIntel.bin
    echo kernel/x86/microcode/GenuineIntel.bin | bsdcpio -o -H newc -R 0:0 > $out/intel-ucode.img
  '';

  meta = with stdenv.lib; {
    homepage = http://www.intel.com/;
    description = "Microcode for Intel processors";
    license = licenses.unfreeRedistributableFirmware;
    maintainers = with maintainers; [ wkennington ];
    platforms = platforms.linux;
  };
}


{stdenv, fetchurl, ocaml, findlib}:

let
  ocaml_version = (builtins.parseDrvName ocaml.name).version;
in

stdenv.mkDerivation {
  name = "ounit-1.1.0";

  src = fetchurl {
    url = http://forge.ocamlcore.org/frs/download.php/495/ounit-1.1.0.tar.gz;
    sha256 = "12vybg9xlw5c8ip23p8cljfzhkdsm25482sf1yh46fcqq8p2jmqx";
  };

  buildInputs = [ocaml findlib];

  dontAddPrefix = true;

  doCheck = true;

  checkTarget = "test";

  createFindlibDestdir = true;

  meta = {
    homepage = http://www.xs4all.nl/~mmzeeman/ocaml/;
    description = "Unit test framework for OCaml";
    license = "MIT/X11";
    platforms = ocaml.meta.platforms;
    maintainers = [
      stdenv.lib.maintainers.z77z
    ];
  };
}

Update ounit to version 1.1.2

{stdenv, fetchurl, ocaml, findlib}:

let
  ocaml_version = (builtins.parseDrvName ocaml.name).version;
in

stdenv.mkDerivation {
  name = "ounit-1.1.2";

  src = fetchurl {
    url = http://forge.ocamlcore.org/frs/download.php/886/ounit-1.1.2.tar.gz;
    sha256 = "e6bc1b0cdbb5b5552d85bee653e23aafe20bb97fd7cd229c867d01ff999888e3";
  };

  buildInputs = [ocaml findlib];

  dontAddPrefix = true;

  doCheck = true;

  checkTarget = "test";

  createFindlibDestdir = true;

  meta = {
    homepage = http://www.xs4all.nl/~mmzeeman/ocaml/;
    description = "Unit test framework for OCaml";
    license = stdenv.lib.licenses.mit;
    platforms = ocaml.meta.platforms;
    maintainers = [
      stdenv.lib.maintainers.z77z
    ];
  };
}


{ stdenv, fetchurl, openssl, libpcap, python
, enableStatic ? false
}:

stdenv.mkDerivation rec {
  name = "vde2-2.3.2";

  src = fetchurl {
    url = "mirror://sourceforge/vde/vde2/2.3.1/${name}.tar.gz";
    sha256 = "14xga0ib6p1wrv3hkl4sa89yzjxv7f1vfqaxsch87j6scdm59pr2";
  };

  buildInputs = [ openssl libpcap python ];

  # Avoid qemu rebuild; feel free to replace with optional
  configureFlags = if enableStatic then [ "--enable-static" ] else null;

  meta = {
    homepage = http://vde.sourceforge.net/;
    description = "Virtual Distributed Ethernet, an Ethernet compliant virtual network";
  };
}

Revert "vde2: support static build"

{ stdenv, fetchurl, openssl, libpcap, python }:

stdenv.mkDerivation rec {
  name = "vde2-2.3.2";

  src = fetchurl {
    url = "mirror://sourceforge/vde/vde2/2.3.1/${name}.tar.gz";
    sha256 = "14xga0ib6p1wrv3hkl4sa89yzjxv7f1vfqaxsch87j6scdm59pr2";
  };

  buildInputs = [ openssl libpcap python ];

  meta = {
    homepage = http://vde.sourceforge.net/;
    description = "Virtual Distributed Ethernet, an Ethernet compliant virtual network";
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "apache-activemq-${version}";
  version = "5.8.0";

  src = fetchurl {
    url = "mirror://apache/activemq/apache-activemq/${version}/${name}-bin.tar.gz";
    sha256 = "12a1lmmqapviqdgw307jm07vw1z5q53r56pkbp85w9wnqwspjrbk";
  };

  phases = [ "unpackPhase" "installPhase" ];

  installPhase = ''
    ensureDir $out
    mv LICENSE lib $out/
    for j in `find $out/lib -name "*.jar"`; do
      cp="''${cp:+"$cp:"}$j";
    done
    echo "CLASSPATH=$cp" > $out/lib/classpath.env
  '';

  meta = {
    homepage = http://activemq.apache.org/;
    description = ''
      Messaging and Integration Patterns server written in Java.
      This nixpkg supplies the jar-files packaged in activemq's
      binary distribution.
    '';
    license = stdenv.lib.licenses.asl20;
  };

}

Copy everything from the dist to the store

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "apache-activemq-${version}";
  version = "5.8.0";

  src = fetchurl {
    url = "mirror://apache/activemq/apache-activemq/${version}/${name}-bin.tar.gz";
    sha256 = "12a1lmmqapviqdgw307jm07vw1z5q53r56pkbp85w9wnqwspjrbk";
  };

  phases = [ "unpackPhase" "installPhase" ];

  installPhase = ''
    ensureDir $out
    mv * $out/
    for j in `find $out/lib -name "*.jar"`; do
      cp="''${cp:+"$cp:"}$j";
    done
    echo "CLASSPATH=$cp" > $out/lib/classpath.env
  '';

  meta = {
    homepage = http://activemq.apache.org/;
    description = ''
      Messaging and Integration Patterns server written in Java.
    '';
    license = stdenv.lib.licenses.asl20;
  };

}


{ stdenv, fetchurl, pkgconfig, libusb1, libiconv }:

stdenv.mkDerivation rec {
  name = "libmtp-1.1.18";

  src = fetchurl {
    url = "mirror://sourceforge/libmtp/${name}.tar.gz";
    sha256 = "1w41l93yi0dmw218daiw36rylkc8rammxx37csh1ij24q18gx03j";
  };

  outputs = [ "bin" "dev" "out" ];

  buildInputs = [ libiconv ];
  propagatedBuildInputs = [ libusb1 ];
  nativeBuildInputs = [ pkgconfig ];

  # tried to install files to /lib/udev, hopefully OK
  configureFlags = [ "--with-udev=$$bin/lib/udev" ];

  meta = with stdenv.lib; {
    homepage = "http://libmtp.sourceforge.net";
    description = "An implementation of Microsoft's Media Transfer Protocol";
    longDescription = ''
      libmtp is an implementation of Microsoft's Media Transfer Protocol (MTP)
      in the form of a library suitable primarily for POSIX compliant operating
      systems. We implement MTP Basic, the stuff proposed for standardization.
      '';
    platforms = platforms.unix;
    license = licenses.lgpl21;
  };
}

Switch to Github, allow building from repo.

{ stdenv, fetchFromGitHub, autoconf, automake, gettext, libtool, pkgconfig
, libusb1
, libiconv
}:

stdenv.mkDerivation rec {
  pname = "libmtp";
  version = "1.1.18";

  src = fetchFromGitHub {
    owner = "libmtp";
    repo = "libmtp";
    rev = "libmtp-${builtins.replaceStrings [ "." ] [ "-" ] version}";
    sha256 = "0lniy0xq397zddlhsv6n4qjn0wwakli5p3ydzxmbzn0z0jgngjja";
  };

  outputs = [ "bin" "dev" "out" ];

  nativeBuildInputs = [
    autoconf
    automake
    gettext
    libtool
    pkgconfig
  ];

  buildInputs = [
    libiconv
  ];

  propagatedBuildInputs = [
    libusb1
  ];

  preConfigure = ''
    ./autogen.sh
  '';

  # tried to install files to /lib/udev, hopefully OK
  configureFlags = [ "--with-udev=$$bin/lib/udev" ];

  meta = with stdenv.lib; {
    homepage = "http://libmtp.sourceforge.net";
    description = "An implementation of Microsoft's Media Transfer Protocol";
    longDescription = ''
      libmtp is an implementation of Microsoft's Media Transfer Protocol (MTP)
      in the form of a library suitable primarily for POSIX compliant operating
      systems. We implement MTP Basic, the stuff proposed for standardization.
      '';
    platforms = platforms.unix;
    license = licenses.lgpl21;
  };
}


{ stdenv, fetchurl, boost, gtkmm, lv2, pkgconfig, python }:

stdenv.mkDerivation rec {
  name = "lvtk-${version}";
  version = "1.1.1";

  src = fetchurl {
    url = "http://lvtoolkit.org/code/browse/lvtk/snapshot/${name}.tar.gz";
    sha256 = "161l4n3a2kar2r5mn3zz6dbj1p2s6361ainrka3s74518z7yf42w";
  };

  buildInputs = [ boost gtkmm lv2 pkgconfig python ];

  configurePhase = ''
    python waf configure --prefix=$out --boost-includes=${boost}/include
  '';

  buildPhase = "python waf";

  installPhase = "python waf install";

  meta = with stdenv.lib; {
    description = "A set C++ wrappers around the LV2 C API";
    homepage = http://lvtoolkit.org;
    license = licenses.gpl3;
    maintainers = [ maintainers.goibhniu ];
    platforms = platforms.linux;
  };
}

Upgrade to 1.2.0 and switch to github tarball

{ stdenv, fetchurl, boost, gtkmm, lv2, pkgconfig, python }:

stdenv.mkDerivation rec {
  name = "lvtk-${version}";
  version = "1.2.0";

  src = fetchurl {
    url = "https://github.com/lvtk/lvtk/archive/${version}.tar.gz";
    sha256 = "03nbj2cqcklqwh50zj2gwm07crh5iwqbpxbpzwbg5hvgl4k4rnjd";
  };

  buildInputs = [ boost gtkmm lv2 pkgconfig python ];

  configurePhase = ''
    python waf configure --prefix=$out --boost-includes=${boost}/include
  '';

  buildPhase = "python waf";

  installPhase = "python waf install";

  meta = with stdenv.lib; {
    description = "A set C++ wrappers around the LV2 C API";
    homepage = http://lvtoolkit.org;
    license = licenses.gpl3;
    maintainers = [ maintainers.goibhniu ];
    platforms = platforms.linux;
  };
}


{ stdenv, fetchurl, autoconf, automake, libtool, pkgconfig, glib, syslogng
, eventlog, perl, python, yacc, riemann_c_client, libivykis, protobufc }:

stdenv.mkDerivation rec {
  name = "syslog-ng-incubator-${version}";

  version = "0.3.1";

  src = fetchurl {
    url = "https://github.com/balabit/syslog-ng-incubator/archive/${name}.tar.gz";
    sha256 = "0zr0vlp7cq3qfhqhalf7rdyd54skswxnc9j9wi8sfmz3psy3vd4y";
  };

  buildInputs = [
    autoconf automake libtool pkgconfig glib syslogng eventlog perl python
    yacc riemann_c_client libivykis protobufc
  ];

  preConfigure = "autoreconf -i";

  configureFlags = [
    "--without-ivykis"
    "--with-riemann"
    "--with-module-dir=$(out)/lib/syslog-ng"
  ];

  meta = with stdenv.lib; {
    homepage = "https://github.com/balabit/syslog-ng-incubator";
    description = "A collection of tools and modules for syslog-ng";
    license = licenses.gpl2;
    maintainers = [ maintainers.rickynils ];
    platforms = platforms.linux;
  };
}

Update from 0.3.1 to 0.3.3

{ stdenv, fetchurl, autoconf, automake, libtool, pkgconfig, glib, syslogng
, eventlog, perl, python, yacc, riemann_c_client, libivykis, protobufc }:

stdenv.mkDerivation rec {
  name = "syslog-ng-incubator-${version}";

  version = "0.3.3";

  src = fetchurl {
    url = "https://github.com/balabit/syslog-ng-incubator/archive/${name}.tar.gz";
    sha256 = "1yx2gdq1vhrcp113hxgl66z5df4ya9nznvq00nvy4v9yn8wf9fb8";
  };

  buildInputs = [
    autoconf automake libtool pkgconfig glib syslogng eventlog perl python
    yacc riemann_c_client libivykis protobufc
  ];

  preConfigure = "autoreconf -i";

  configureFlags = [
    "--without-ivykis"
    "--with-riemann"
    "--with-module-dir=$(out)/lib/syslog-ng"
  ];

  meta = with stdenv.lib; {
    homepage = "https://github.com/balabit/syslog-ng-incubator";
    description = "A collection of tools and modules for syslog-ng";
    license = licenses.gpl2;
    maintainers = [ maintainers.rickynils ];
    platforms = platforms.linux;
  };
}


{ lib, stdenv, fetchFromGitHub, cmake, fetchpatch }:

stdenv.mkDerivation rec {
  pname = "aws-c-common";
  version = "0.3.11";

  src = fetchFromGitHub {
    owner = "awslabs";
    repo = pname;
    rev = "v${version}";
    sha256 = "0a7hi4crnc3j1j39qcnd44zqdfwzw1xghcf80marx5vdf1qdzy6p";
  };

  nativeBuildInputs = [ cmake ];

  # can be removed once https://github.com/awslabs/aws-c-common/pull/735 gets merged, and version bumped
  patches = [
    (fetchpatch {
      name = "fix-re-export-of-target.patch";
      url = "https://github.com/awslabs/aws-c-common/pull/735/commits/3fca5c629ce0c4d66f50f7152685f3fe73941cb4.patch";
      sha256 = "056f9kyg1c4lwjq8n0r28w1n3zbwrwpi1wbqabk99gaayg46x35a";
    })
  ];

  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin
    "-Wno-nullability-extension -Wno-typedef-redefinition";

  meta = with lib; {
    description = "AWS SDK for C common core";
    homepage = "https://github.com/awslabs/aws-c-common";
    license = licenses.asl20;
    platforms = platforms.unix;
    maintainers = with maintainers; [ orivej eelco ];
  };
}

Revert "aws-c-common: fix build with cmake 3.19"

{ lib, stdenv, fetchFromGitHub, cmake }:

stdenv.mkDerivation rec {
  pname = "aws-c-common";
  version = "0.3.11";

  src = fetchFromGitHub {
    owner = "awslabs";
    repo = pname;
    rev = "v${version}";
    sha256 = "0a7hi4crnc3j1j39qcnd44zqdfwzw1xghcf80marx5vdf1qdzy6p";
  };

  nativeBuildInputs = [ cmake ];

  NIX_CFLAGS_COMPILE = lib.optionalString stdenv.isDarwin
    "-Wno-nullability-extension -Wno-typedef-redefinition";

  meta = with lib; {
    description = "AWS SDK for C common core";
    homepage = "https://github.com/awslabs/aws-c-common";
    license = licenses.asl20;
    platforms = platforms.unix;
    maintainers = with maintainers; [ orivej eelco ];
  };
}


{stdenv, fetchurl, pkgconfig, glib, gperf}:
let
  s = # Generated upstream information
  rec {
    baseName="eudev";
    version="2.1.1";
    name="${baseName}-${version}";
    url="http://dev.gentoo.org/~blueness/eudev/eudev-${version}.tar.gz";
    sha256="0shf5vqiz9fdxl95aa1a8vh0xjxwim3psc39wr2xr8lnahf11vva";
  };
  buildInputs = [
    glib pkgconfig gperf
  ];
in
stdenv.mkDerivation {
  inherit (s) name version;
  inherit buildInputs;
  src = fetchurl {
    inherit (s) url sha256;
  };
  meta = {
    inherit (s) version;
    description = ''An udev fork by Gentoo'';
    license = stdenv.lib.licenses.gpl2Plus ;
    maintainers = [stdenv.lib.maintainers.raskin];
    platforms = stdenv.lib.platforms.linux;
    homepage = ''http://www.gentoo.org/proj/en/eudev/'';
    downloadPage = ''http://dev.gentoo.org/~blueness/eudev/'';
    updateWalker = true;
  };
}

Allow eudev to find blkid

{stdenv, fetchurl, pkgconfig, glib, gperf, utillinux}:
let
  s = # Generated upstream information
  rec {
    baseName="eudev";
    version="2.1.1";
    name="${baseName}-${version}";
    url="http://dev.gentoo.org/~blueness/eudev/eudev-${version}.tar.gz";
    sha256="0shf5vqiz9fdxl95aa1a8vh0xjxwim3psc39wr2xr8lnahf11vva";
  };
  buildInputs = [
    glib pkgconfig gperf utillinux
  ];
in
stdenv.mkDerivation {
  inherit (s) name version;
  inherit buildInputs;
  src = fetchurl {
    inherit (s) url sha256;
  };
  meta = {
    inherit (s) version;
    description = ''An udev fork by Gentoo'';
    license = stdenv.lib.licenses.gpl2Plus ;
    maintainers = [stdenv.lib.maintainers.raskin];
    platforms = stdenv.lib.platforms.linux;
    homepage = ''http://www.gentoo.org/proj/en/eudev/'';
    downloadPage = ''http://dev.gentoo.org/~blueness/eudev/'';
    updateWalker = true;
  };
}


{stdenv, fetchurl, binutilsCross ? null, gccCross ? null, onlyHeaders ? false}:

let
  name = "mingw-w64-2.0.3";
in
stdenv.mkDerivation (rec {
  inherit name;

  src = fetchurl {
    url = "mirror://sourceforge/mingw-w64/mingw-w64-v2.0.3.tar.gz";
    sha256 = "043jk6z90f9pxs9kfn6ckh2vlnbgcv6yfbp5ybahrj3z58dcijp5";
  };

  # I don't know what's that $host directory about, I put the
  # files inside include as usual.
  postInstall = ''
    rmdir $out/include
    mv $out/x86_64-w64-mingw32/* $out
    rm -R $out/x86_64-w64-mingw32
  '';
} //
(if onlyHeaders then {
  name = name + "-headers";
  preConfingure = ''
    cd mingw-w64-headers
  '';
  configureFlags = "--without-crt --host=x86_64-w64-mingw32";
} else {
  buildInputs = [ gccCross binutilsCross ];

  crossConfig = gccCross.crossConfig;

  dontStrip = true;
})
)

Update to new upstream version 3.1.0.

{stdenv, fetchurl, binutilsCross ? null, gccCross ? null, onlyHeaders ? false}:

let
  name = "mingw-w64-3.1.0";
in
stdenv.mkDerivation (rec {
  inherit name;

  src = fetchurl {
    url = "mirror://sourceforge/mingw-w64/mingw-w64-v3.1.0.tar.bz2";
    sha256 = "1lhpw381gc59w8b1r9zzdwa9cdi2wx6qx7s6rvajapmbw7ksgrzc";
  };
} //
(if onlyHeaders then {
  name = name + "-headers";
  preConfingure = ''
    cd mingw-w64-headers
  '';
  configureFlags = "--without-crt --host=x86_64-w64-mingw32";
} else {
  buildInputs = [ gccCross binutilsCross ];

  crossConfig = gccCross.crossConfig;

  dontStrip = true;
})
)


{ stdenv, fetchurl, pythonPackages, mopidy }:

pythonPackages.buildPythonPackage rec {
  name = "mopidy-spotify-${version}";

  version = "1.1.3";

  src = fetchurl {
    url = "https://github.com/mopidy/mopidy-spotify/archive/v${version}.tar.gz";
    sha256 = "09s6841qb24nrmlc2izb8vxbgv185ddra6ndskrsw907hfli2kl6";
  };

  propagatedBuildInputs = [ mopidy pythonPackages.pyspotify ];

  doCheck = false;

  meta = with stdenv.lib; {
    homepage = http://www.mopidy.com/;
    description = "Mopidy extension for playing music from Spotify.";
    license = licenses.asl20;
    maintainers = [ maintainers.rickynils ];
    hydraPlatforms = [];
  };
}

Update from 1.1.3 to 1.2.0

{ stdenv, fetchurl, pythonPackages, mopidy }:

pythonPackages.buildPythonPackage rec {
  name = "mopidy-spotify-${version}";

  version = "1.2.0";

  src = fetchurl {
    url = "https://github.com/mopidy/mopidy-spotify/archive/v${version}.tar.gz";
    sha256 = "1fgxakylsx0nggis11v6bxfy8h3dl1n1v86liyfcj0xazb1mx69m";
  };

  propagatedBuildInputs = [ mopidy pythonPackages.pyspotify ];

  doCheck = false;

  meta = with stdenv.lib; {
    homepage = http://www.mopidy.com/;
    description = "Mopidy extension for playing music from Spotify.";
    license = licenses.asl20;
    maintainers = [ maintainers.rickynils ];
    hydraPlatforms = [];
  };
}


{ pkgs, lib, fetchFromGitHub, buildPythonPackage, isPy3k, regex }:

buildPythonPackage rec {
  pname = "SoMaJo";
  version = "2.1.2";
  disabled = !isPy3k;

  src = fetchFromGitHub {
    owner = "tsproisl";
    repo = pname;
    rev = "v${version}";
    sha256 = "1c4g8nhlcc348w0axdswv69q8k3qxwbnvim1yf7vagd0adv83gsj";
  };

  propagatedBuildInputs = [ regex ];

  meta = with lib; {
    description = "Tokenizer and sentence splitter for German and English web texts";
    homepage = "https://github.com/tsproisl/SoMaJo";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ danieldk ];
  };
}

Disable tests on darwin because they are stuck

{ lib, stdenv, fetchFromGitHub, buildPythonPackage, isPy3k, regex }:

buildPythonPackage rec {
  pname = "SoMaJo";
  version = "2.1.2";
  disabled = !isPy3k;

  src = fetchFromGitHub {
    owner = "tsproisl";
    repo = pname;
    rev = "v${version}";
    sha256 = "1c4g8nhlcc348w0axdswv69q8k3qxwbnvim1yf7vagd0adv83gsj";
  };

  propagatedBuildInputs = [ regex ];

  # loops forever
  doCheck = !stdenv.isDarwin;

  meta = with lib; {
    description = "Tokenizer and sentence splitter for German and English web texts";
    homepage = "https://github.com/tsproisl/SoMaJo";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ danieldk ];
  };
}


{ stdenv, fetchFromGitHub, rustPlatform, makeWrapper }:

rustPlatform.buildRustPackage rec {
  name = "racer-${version}";
  version = "2.0.12";

  src = fetchFromGitHub {
    owner = "racer-rust";
    repo = "racer";
    rev = version;
    sha256 = "0y1xlpjr8y8gsmmrjlykx4vwzf8akk42g35kg3kc419ry4fli945";
  };

  cargoSha256 = "1h3jv4hajdv6k309kjr6b6298kxmd0faw081i3788sl794k9mp0j";

  buildInputs = [ makeWrapper ];

  preCheck = ''
    export RUST_SRC_PATH="${rustPlatform.rustcSrc}"
  '';

  doCheck = true;

  postInstall = ''
    wrapProgram $out/bin/racer --set RUST_SRC_PATH "${rustPlatform.rustcSrc}"
  '';

  meta = with stdenv.lib; {
    description = "A utility intended to provide Rust code completion for editors and IDEs";
    homepage = https://github.com/racer-rust/racer;
    license = licenses.mit;
    maintainers = with maintainers; [ jagajaga globin ];
    platforms = platforms.all;
  };
}

Revert "rustracer: 2.0.9 -> 2.0.12"

{ stdenv, fetchFromGitHub, rustPlatform, makeWrapper }:

rustPlatform.buildRustPackage rec {
  name = "racer-${version}";
  version = "2.0.9";

  src = fetchFromGitHub {
    owner = "racer-rust";
    repo = "racer";
    rev = version;
    sha256 = "06k50f2vj2w08afh3nrlhs0amcvw2i45bhfwr70sgs395xicjswp";
  };

  cargoSha256 = "1w5imxyqlyv24dvzncq6dy01zn2x8p1aciyvzh8ac1x1wdjcacjc";

  buildInputs = [ makeWrapper ];

  preCheck = ''
    export RUST_SRC_PATH="${rustPlatform.rustcSrc}"
  '';

  doCheck = true;

  installPhase = ''
    mkdir -p $out/bin
    cp -p target/release/racer $out/bin/
    wrapProgram $out/bin/racer --set RUST_SRC_PATH "${rustPlatform.rustcSrc}"
  '';

  meta = with stdenv.lib; {
    description = "A utility intended to provide Rust code completion for editors and IDEs";
    homepage = https://github.com/racer-rust/racer;
    license = licenses.mit;
    maintainers = with maintainers; [ jagajaga globin ];
    platforms = platforms.all;
  };
}


{ stdenv, fetchurl, cpio, zlib, bzip2, file, elfutils, nspr, nss, popt, db4, xz, python }:

stdenv.mkDerivation rec {
  name = "rpm-4.7.2";

  src = fetchurl {
    url = "http://rpm.org/releases/rpm-4.7.x/${name}.tar.bz2";
    sha1 = "07b90f653775329ea726ce0005c4c82f56167ca0";
  };

  buildInputs = [ cpio zlib bzip2 file nspr nss popt db4 xz python ];

  # Note: we don't add elfutils to buildInputs, since it provides a
  # bad `ld' and other stuff.
  NIX_CFLAGS_COMPILE = "-I${nspr}/include/nspr -I${nss}/include/nss -I${elfutils}/include";

  NIX_CFLAGS_LINK = "-L${elfutils}/lib";

  configureFlags = "--with-external-db --without-lua --enable-python";

  meta = {
    homepage = http://www.rpm.org/;
    license = "GPLv2";
    description = "The RPM Package Manager";
    maintainers = stdenv.lib.maintainers.mornfall;
  };
}

Upgrade from 4.7.2 -> 4.11.2

{ stdenv, fetchurl, cpio, zlib, bzip2, file, elfutils, nspr, nss, popt, db, xz, python }:

stdenv.mkDerivation rec {
  name = "rpm-4.11.2";

  src = fetchurl {
    url = "http://rpm.org/releases/rpm-4.11.x/${name}.tar.bz2";
    sha256 = "1m2859js0dwg26sg2mnbkpzhvx303b12kx26az74cf5k6bk8sgs0";
  };

  buildInputs = [ cpio zlib bzip2 file nspr nss popt db xz python ];

  # Note: we don't add elfutils to buildInputs, since it provides a
  # bad `ld' and other stuff.
  NIX_CFLAGS_COMPILE = "-I${nspr}/include/nspr -I${nss}/include/nss -I${elfutils}/include";

  NIX_CFLAGS_LINK = "-L${elfutils}/lib";

  configureFlags = "--with-external-db --without-lua --enable-python";

  meta = with stdenv.lib; {
    homepage = http://www.rpm.org/;
    license = licenses.gpl2;
    description = "The RPM Package Manager";
    maintainers = with maintainers; [ mornfall ];
  };
}


{ applicationId
, activityAttributes
, version
, iconPath
, intentFilters
, services
, permissions
}:
''
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="${applicationId}"
      android:versionCode="${version.code}"
      android:versionName="${version.name}">
    <application android:label="@string/app_name"
                 android:icon="${iconPath}"
                 android:hardwareAccelerated="true">
        <activity android:name="systems.obsidian.HaskellActivity"
                  android:label="@string/app_name"
                  android:configChanges="orientation|screenSize"
                  android:windowSoftInputMode="adjustResize"
                  ${activityAttributes}
                  >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            ${intentFilters}
        </activity>
        ${services}
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    ${permissions}
</manifest>
''

Add allowBackup/fullBackupContent to android manifest

{ applicationId
, activityAttributes
, version
, iconPath
, intentFilters
, services
, permissions
, allowBackup ? false
, fullBackupContent ? allowBackup
}:
let
  boolStr = x: if x then "true" else "false";
in ''
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="${applicationId}"
      android:versionCode="${version.code}"
      android:versionName="${version.name}">
    <application android:label="@string/app_name"
                 android:icon="${iconPath}"
                 android:allowBackup="${boolStr allowBackup}"
                 android:fullBackupContent="${boolStr fullBackupContent}"
                 android:hardwareAccelerated="true">
        <activity android:name="systems.obsidian.HaskellActivity"
                  android:label="@string/app_name"
                  android:configChanges="orientation|screenSize"
                  android:windowSoftInputMode="adjustResize"
                  ${activityAttributes}
                  >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
            ${intentFilters}
        </activity>
        ${services}
    </application>
    <uses-permission android:name="android.permission.INTERNET" />
    ${permissions}
</manifest>
''


{ lib, stdenv, fetchurl, perl, nixosTests }:

stdenv.mkDerivation rec {
  pname = "libxcrypt";
  version = "4.4.30";

  src = fetchurl {
    url = "https://github.com/besser82/libxcrypt/releases/download/v${version}/libxcrypt-${version}.tar.xz";
    sha256 = "sha256-s2Z/C6hdqtavJGukCQ++UxY62TyLaioSV9IqeLt87ro=";
  };

  outputs = [
    "out"
    "man"
  ];

  configureFlags = [
    "--enable-hashes=all"
    "--enable-obsolete-api=glibc"
    "--disable-failure-tokens"
  ] ++ lib.optionals stdenv.hostPlatform.isMusl [
    "--disable-werror"
  ];

  nativeBuildInputs = [
    perl
  ];

  enableParallelBuilding = true;

  doCheck = true;

  passthru.tests = {
    inherit (nixosTests) login shadow;
  };

  meta = with lib; {
    description = "Extended crypt library for descrypt, md5crypt, bcrypt, and others";
    homepage = "https://github.com/besser82/libxcrypt/";
    platforms = platforms.all;
    maintainers = with maintainers; [ dottedmag hexa ];
    license = licenses.lgpl21Plus;
  };
}

Fix the build on Android by allowing warnings

{ lib, stdenv, fetchurl, perl, nixosTests }:

stdenv.mkDerivation rec {
  pname = "libxcrypt";
  version = "4.4.30";

  src = fetchurl {
    url = "https://github.com/besser82/libxcrypt/releases/download/v${version}/libxcrypt-${version}.tar.xz";
    sha256 = "sha256-s2Z/C6hdqtavJGukCQ++UxY62TyLaioSV9IqeLt87ro=";
  };

  outputs = [
    "out"
    "man"
  ];

  configureFlags = [
    "--enable-hashes=all"
    "--enable-obsolete-api=glibc"
    "--disable-failure-tokens"
  ] ++ lib.optionals (stdenv.hostPlatform.isMusl || stdenv.hostPlatform.libc == "bionic") [
    "--disable-werror"
  ];

  nativeBuildInputs = [
    perl
  ];

  enableParallelBuilding = true;

  doCheck = true;

  passthru.tests = {
    inherit (nixosTests) login shadow;
  };

  meta = with lib; {
    description = "Extended crypt library for descrypt, md5crypt, bcrypt, and others";
    homepage = "https://github.com/besser82/libxcrypt/";
    platforms = platforms.all;
    maintainers = with maintainers; [ dottedmag hexa ];
    license = licenses.lgpl21Plus;
  };
}


{stdenv, fetchurl, emacs}:

let version = "20150111";

in stdenv.mkDerivation {
  name = "emacs-d-${version}";

  src = fetchurl {
    url = "https://github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode/archive/53efec4d83c7cee8227597f010fe7fc400ff05f1.tar.gz";
    sha256 = "0vb0za51lc6qf1qgqisap4vzk36caa5k17zajjn034rhjsqfw0w7";
  };

  buildInputs = [ emacs ];

  buildPhase = ''
    emacs -L . --batch -f batch-byte-compile *.el
  '';

  installPhase = ''
    install -d $out/share/emacs/site-lisp
    install *.el *.elc $out/share/emacs/site-lisp
  '';
}

Add meta attributes to emacsPackages.d

{stdenv, fetchurl, emacs}:

# Note: Don't have a version, using date as fallback.
let version = "20150111";

in stdenv.mkDerivation {
  name = "emacs-d-${version}";

  src = fetchurl {
    url = "https://github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode/archive/53efec4d83c7cee8227597f010fe7fc400ff05f1.tar.gz";
    sha256 = "0vb0za51lc6qf1qgqisap4vzk36caa5k17zajjn034rhjsqfw0w7";
  };

  buildInputs = [ emacs ];

  buildPhase = ''
    emacs -L . --batch -f batch-byte-compile *.el
  '';

  installPhase = ''
    install -d $out/share/emacs/site-lisp
    install *.el *.elc $out/share/emacs/site-lisp
  '';

  meta = {
    description = "Major mode for editing D code";
    homepage = https://github.com/Emacs-D-Mode-Maintainers/Emacs-D-Mode;
    license = stdenv.lib.licenses.gpl2;
    platforms = stdenv.lib.platforms.all;
  };

}


{stdenv, fetchurl, sqlite, zlib, acl, ncurses, openssl, readline}:

stdenv.mkDerivation {
  name = "bacula-5.2.13";

  src = fetchurl {
    url = mirror://sourceforge/bacula/bacula-5.2.13.tar.gz;
    sha256 = "1n3sc0kd7r0afpyi708y3md0a24rbldnfcdz0syqj600pxcd9gm4";
  };

  buildInputs = [ sqlite zlib acl ncurses openssl readline ];

  configureFlags = [ "--with-sqlite3=${sqlite}" ];

  meta = {
    description = "Enterprise ready, Network Backup Tool";
    homepage = http://bacula.org/;
    license = "GPLv2";
  };
}

Remove some duplication to avoid errors when updating.

{stdenv, fetchurl, sqlite, zlib, acl, ncurses, openssl, readline}:

stdenv.mkDerivation rec {
  name = "bacula-5.2.13";

  src = fetchurl {
    url = "mirror://sourceforge/bacula/${name}.tar.gz";
    sha256 = "1n3sc0kd7r0afpyi708y3md0a24rbldnfcdz0syqj600pxcd9gm4";
  };

  buildInputs = [ sqlite zlib acl ncurses openssl readline ];

  configureFlags = [ "--with-sqlite3=${sqlite}" ];

  meta = {
    description = "Enterprise ready, Network Backup Tool";
    homepage = http://bacula.org/;
    license = "GPLv2";
  };
}


{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc7102" }:
nixpkgs.pkgs.haskell.packages.${compiler}.callPackage ./libjenkins-examples.nix {}

Use the local version of the library in examples.

{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc7102" }:
nixpkgs.pkgs.haskell.packages.${compiler}.callPackage ./libjenkins-examples.nix {
  libjenkins = import ../. { inherit nixpkgs compiler; };
}


rec {
   version="0.10.1";
   name="couchdb-0.10.1";
   hash="0sy644slqmklj3v6dndxw6mh4jn0bm8f90sacycy7l1pclhzfsic";
   url="mirror://apache/couchdb/0.10.1/apache-couchdb-${version}.tar.gz";
   advertisedUrl="http://www.apache.org/dist/couchdb/0.10.1/apache-couchdb-0.10.1.tar.gz";

}

Update CouchDB (patch and tested by Cillian Deroiste)

rec {
   version="0.11.0";
   name="couchdb-0.11.0";
   hash="0jdh9h6kzay02fpcjvhpwgvpwy9s8yl0hjc5j67lyw504wn2d441";
   url="mirror://apache/couchdb/0.11.0/apache-couchdb-${version}.tar.gz";
   advertisedUrl="http://www.apache.org/dist/couchdb/0.11.0/apache-couchdb-0.11.0.tar.gz";

}


{ stdenv, fetchurl, pythonPackages, python }:

pythonPackages.buildPythonPackage rec {
  version = "1.6.10";
  name = "ansible-${version}";
  namePrefix = "";

  src = fetchurl {
    url = "https://github.com/ansible/ansible/archive/v${version}.tar.gz";
    sha256 = "0j133353skzb6ydrqqgfkzbkkj1zaibl1x8sgl0arnfma8qky1g1";
  };

  prePatch = ''
    sed -i "s,\/usr\/share\/ansible\/,$out/share/ansible," lib/ansible/constants.py
  '';

  doCheck = false;
  dontStrip = true;
  dontPatchELF = true;
  dontPatchShebangs = true;

  propagatedBuildInputs = with pythonPackages; [
    paramiko jinja2 pyyaml httplib2 boto
  ];

  postFixup = ''
      wrapPythonProgramsIn $out/bin "$out $pythonPath"
  '';

  meta = with stdenv.lib; {
    homepage = "http://www.ansible.com";
    description = "A simple automation tool";
    license = licenses.gpl3;
    maintainers = [ maintainers.joamaki ];
    platforms = platforms.linux ++ [ "x86_64-darwin" ];
  };
}

Update to latest ansible version

{ stdenv, fetchurl, pythonPackages, python }:

pythonPackages.buildPythonPackage rec {
  version = "1.7.1";
  name = "ansible-${version}";
  namePrefix = "";

  src = fetchurl {
    url = "http://releases.ansible.com/ansible/ansible-${version}.tar.gz";
    sha1 = "4f4be4d45f28f52e4ab0c063efb66c7b9f482a51";
  };

  prePatch = ''
    sed -i "s,\/usr\/share\/ansible\/,$out/share/ansible," lib/ansible/constants.py
  '';

  doCheck = false;
  dontStrip = true;
  dontPatchELF = true;
  dontPatchShebangs = true;

  propagatedBuildInputs = with pythonPackages; [
    paramiko jinja2 pyyaml httplib2 boto
  ];

  postFixup = ''
      wrapPythonProgramsIn $out/bin "$out $pythonPath"
  '';

  meta = with stdenv.lib; {
    homepage = "http://www.ansible.com";
    description = "A simple automation tool";
    license = licenses.gpl3;
    maintainers = [ maintainers.joamaki ];
    platforms = platforms.linux ++ [ "x86_64-darwin" ];
  };
}


{stdenv, lib, fetchurl, pythonPackages
, gnutar, unzip, lhasa, rpm, binutils, cpio, gzip, cabextract, unrar, unshield
, bzip2, xz, lzip
# unsafe:
# ,p7zip
# unzip is no longer handled by p7zip, since it's unsafe
, unzipSupport ? true
, unrarSupport ? false }:

let
  # p7zip
  archivers = lib.makeBinPath ([ gnutar lhasa rpm binutils cpio gzip cabextract unshield ]
                               ++ lib.optional (unzipSupport) unzip
                               ++ lib.optional (unrarSupport) unrar
                               ++ [ bzip2 xz lzip ]);

in pythonPackages.buildPythonApplication rec {
  pname = "dtrx";
  version = "7.1";

  src = fetchurl {
    url = "https://brettcsmith.org/2007/dtrx/dtrx-${version}.tar.gz";
    sha256 = "15yf4n27zbhvv0byfv3i89wl5zn6jc2wbc69lk5a3m6rx54gx6hw";
  };

  postInstall = ''
    wrapProgram "$out/bin/dtrx" --prefix PATH : "${archivers}"
  '';

  meta = with stdenv.lib; {
    description = "Do The Right Extraction: A tool for taking the hassle out of extracting archives";
    homepage = "https://brettcsmith.org/2007/dtrx/";
    license = licenses.gpl3Plus;
    maintainers = [ maintainers.spwhitt ];
    platforms = platforms.all;
  };
}

Revert "dtrx: remove p7zip, since it's unsafe"

{stdenv, lib, fetchurl, pythonPackages
, gnutar, unzip, lhasa, rpm, binutils, cpio, gzip, p7zip, cabextract, unrar, unshield
, bzip2, xz, lzip
# unzip is handled by p7zip
, unzipSupport ? false
, unrarSupport ? false }:

let
  archivers = lib.makeBinPath ([ gnutar lhasa rpm binutils cpio gzip p7zip cabextract unshield ]
  ++ lib.optional (unzipSupport) unzip
  ++ lib.optional (unrarSupport) unrar
  ++ [ bzip2 xz lzip ]);

in pythonPackages.buildPythonApplication rec {
  pname = "dtrx";
  version = "7.1";

  src = fetchurl {
    url = "https://brettcsmith.org/2007/dtrx/dtrx-${version}.tar.gz";
    sha256 = "15yf4n27zbhvv0byfv3i89wl5zn6jc2wbc69lk5a3m6rx54gx6hw";
  };

  postInstall = ''
    wrapProgram "$out/bin/dtrx" --prefix PATH : "${archivers}"
  '';

  meta = with stdenv.lib; {
    description = "Do The Right Extraction: A tool for taking the hassle out of extracting archives";
    homepage = "https://brettcsmith.org/2007/dtrx/";
    license = licenses.gpl3Plus;
    maintainers = [ maintainers.spwhitt ];
    platforms = platforms.all;
  };
}


{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "valgrind-3.2.3";
  src = fetchurl {
    url = http://valgrind.org/downloads/valgrind-3.2.3.tar.bz2;
    sha256 = "0hf48y13mm1c1zg59bvkbr0lzcwng5mb33lgiv3d0gzl4w2r5jhv";
  };

  meta = {
    description = "Award-winning suite of tools for debugging and profiling Linux programs";
  };
}

Fix for building valgrind on x86_64-linux.

{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "valgrind-3.2.3";
  src = fetchurl {
    url = http://valgrind.org/downloads/valgrind-3.2.3.tar.bz2;
    sha256 = "0hf48y13mm1c1zg59bvkbr0lzcwng5mb33lgiv3d0gzl4w2r5jhv";
  };

  configureFlags =
    if stdenv.system == "x86_64-linux" then ["--enable-only64bit"] else [];

  meta = {
    description = "Award-winning suite of tools for debugging and profiling Linux programs";
  };
}


{ stdenv, callPackage, windows }:

stdenv.mkDerivation {
  inherit (callPackage ./common.nix {}) name src;
  buildInputs = [ windows.mingw_w64_headers ];
  dontStrip = true;
}

Disable stack hardening of the runtime

{ stdenv, callPackage, windows }:

stdenv.mkDerivation {
  inherit (callPackage ./common.nix {}) name src;
  buildInputs = [ windows.mingw_w64_headers ];
  dontStrip = true;
  hardeningDisable = [ "stackprotector" "fortify" ];
}


{ stdenv, fetchurl, which, pkgconfig, perl, guile, libxml2 }:

stdenv.mkDerivation rec {
  name = "autogen-${version}";
  version = "5.18.5";

  src = fetchurl {
    url = "mirror://gnu/autogen/rel${version}/autogen-${version}.tar.gz";
    sha256 = "1flnbnmkbqmbfgammkl8m36wrlk6rhpgnf9pdm6gdfhqalxvggbv";
  };

  nativeBuildInputs = [ which pkgconfig perl ];
  buildInputs = [ guile libxml2 ];

  postPatch = ''
    # Fix a broken sed expression used for detecting the minor
    # version of guile we are using
    sed -i "s,sed '.*-I.*',sed 's/\\\(^\\\| \\\)-I/\\\1/g',g" configure

    # Don't write temporary files outside the build directory
    sed -i "s,/tmp/mklibsrc-log.tx,$TMPDIR/mklibsrc-log.tx,g" pkg/libopts/mklibsrc.sh
  '';

  #doCheck = true; # 2 tests fail because of missing /dev/tty

  meta = with stdenv.lib; {
    description = "Automated text and program generation tool";
    license = with licenses; [ gpl3Plus lgpl3Plus ];
    homepage = http://www.gnu.org/software/autogen/;
    platforms = platforms.all;
    maintainers = [ ];
  };
}

Revert "autogen: don't write temp files outside build dir"

{ stdenv, fetchurl, which, pkgconfig, perl, guile, libxml2 }:

stdenv.mkDerivation rec {
  name = "autogen-${version}";
  version = "5.18.5";

  src = fetchurl {
    url = "mirror://gnu/autogen/rel${version}/autogen-${version}.tar.gz";
    sha256 = "1flnbnmkbqmbfgammkl8m36wrlk6rhpgnf9pdm6gdfhqalxvggbv";
  };

  nativeBuildInputs = [ which pkgconfig perl ];
  buildInputs = [ guile libxml2 ];

  postPatch = ''
    # Fix a broken sed expression used for detecting the minor
    # version of guile we are using
    sed -i "s,sed '.*-I.*',sed 's/\\\(^\\\| \\\)-I/\\\1/g',g" configure
  '';

  #doCheck = true; # 2 tests fail because of missing /dev/tty

  meta = with stdenv.lib; {
    description = "Automated text and program generation tool";
    license = with licenses; [ gpl3Plus lgpl3Plus ];
    homepage = http://www.gnu.org/software/autogen/;
    platforms = platforms.all;
    maintainers = [ ];
  };
}


{ stdenv, fetchurl, eventlog, pkgconfig, glib, python, systemd }:

stdenv.mkDerivation {
  name = "syslog-ng-3.5.4.1";

  src = fetchurl {
    url = "http://www.balabit.com/downloads/files?path=/syslog-ng/sources/3.5.4.1/source/syslog-ng_3.5.4.1.tar.gz";
    sha256 = "0rkgrmnyx1x6m3jw5n49k7r1dcg79lxh900g74rgvd3j86g9dilj";
  };

  buildInputs = [ eventlog pkgconfig glib python systemd ];

  configureFlags = [
    "--enable-dynamic-linking"
    "--enable-systemd"
    "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
  ];

  meta = {
    homepage = "http://www.balabit.com/network-security/syslog-ng/";
    description = "Next-generation syslogd with advanced networking and filtering capabilities";
    license = "GPLv2";
  };
}

Add perl to buildInputs so perl scripts in output are fixed correctly

{ stdenv, fetchurl, eventlog, pkgconfig, glib, python, systemd, perl }:

stdenv.mkDerivation {
  name = "syslog-ng-3.5.4.1";

  src = fetchurl {
    url = "http://www.balabit.com/downloads/files?path=/syslog-ng/sources/3.5.4.1/source/syslog-ng_3.5.4.1.tar.gz";
    sha256 = "0rkgrmnyx1x6m3jw5n49k7r1dcg79lxh900g74rgvd3j86g9dilj";
  };

  buildInputs = [ eventlog pkgconfig glib python systemd perl ];

  configureFlags = [
    "--enable-dynamic-linking"
    "--enable-systemd"
    "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
  ];

  meta = {
    homepage = "http://www.balabit.com/network-security/syslog-ng/";
    description = "Next-generation syslogd with advanced networking and filtering capabilities";
    license = "GPLv2";
  };
}


{ stdenv, fetchgit }:

stdenv.mkDerivation rec {
    name = "dd-agent-ab14fde6f9";

    src = fetchgit {
      url = git://github.com/DataDog/dd-agent.git;
      rev = "ab14fde6f9b9f6cb3544f643cece97ef18a0d770";
      sha256 = "2615a2f122ac97363eba8973dfc6c2ce81cb61a26eb61c2988faad2abd05efc5";
    };

    postUnpack = "export sourceRoot=$sourceRoot/packaging";

    makeFlags = [ "BUILD=$(out)" ];

    installTargets = [ "install_base" "install_full" ];
}

Move /usr stuff to directly

{ stdenv, fetchgit }:

stdenv.mkDerivation rec {
    name = "dd-agent-ab14fde6f9";

    src = fetchgit {
      url = git://github.com/DataDog/dd-agent.git;
      rev = "ab14fde6f9b9f6cb3544f643cece97ef18a0d770";
      sha256 = "2615a2f122ac97363eba8973dfc6c2ce81cb61a26eb61c2988faad2abd05efc5";
    };

    postUnpack = "export sourceRoot=$sourceRoot/packaging";

    makeFlags = [ "BUILD=$(out)" ];

    installTargets = [ "install_base" "install_full" ];

    postInstall = ''
      mv $out/usr/* $out
      rmdir $out/usr
    '';
}