{ stdenv, fetchFromGitHub, pkgconfig, glib, fuse3, autoreconfHook }:

stdenv.mkDerivation rec {
  version = "3.2.0";
  name = "sshfs-fuse-${version}";

  src = fetchFromGitHub {
    owner = "libfuse";
    repo = "sshfs";
    rev = "sshfs-${version}";
    sha256 = "09pqdibhcj1p7m6vxkqiprvbcxp9iq2lm1hb6w7p8iarmvp80rlv";
  };

  buildInputs = [ pkgconfig glib fuse3 autoreconfHook ];

  postInstall = ''
    mkdir -p $out/sbin
    ln -sf $out/bin/sshfs $out/sbin/mount.sshfs
  '';

  meta = with stdenv.lib; {
    inherit (src.meta) homepage;
    description = "FUSE-based filesystem that allows remote filesystems to be mounted over SSH";
    platforms = platforms.linux;
    maintainers = with maintainers; [ primeos ];
  };
}

Fix the build on i686-linux

{ stdenv, fetchFromGitHub, pkgconfig, glib, fuse3, autoreconfHook }:

stdenv.mkDerivation rec {
  version = "3.2.0";
  name = "sshfs-fuse-${version}";

  src = fetchFromGitHub {
    owner = "libfuse";
    repo = "sshfs";
    rev = "sshfs-${version}";
    sha256 = "09pqdibhcj1p7m6vxkqiprvbcxp9iq2lm1hb6w7p8iarmvp80rlv";
  };

  buildInputs = [ pkgconfig glib fuse3 autoreconfHook ];

  NIX_CFLAGS_COMPILE = stdenv.lib.optional
    (stdenv.system == "i686-linux")
    "-D_FILE_OFFSET_BITS=64";

  postInstall = ''
    mkdir -p $out/sbin
    ln -sf $out/bin/sshfs $out/sbin/mount.sshfs
  '';

  meta = with stdenv.lib; {
    inherit (src.meta) homepage;
    description = "FUSE-based filesystem that allows remote filesystems to be mounted over SSH";
    platforms = platforms.linux;
    maintainers = with maintainers; [ primeos ];
  };
}


# This file defines the source of Rust / cargo's crates registry
#
# buildRustPackage will automatically download dependencies from the registry
# version that we define here. If you're having problems downloading / finding
# a Rust library, try updating this to a newer commit.

{ fetchgit }:

fetchgit {
  url = git://github.com/rust-lang/crates.io-index.git;

  # 2015-04-20
  rev = "c7112fed5f973e438bb600946016c5083e66b1c9";
  sha256 = "0vyrz7d6zvh79hx5fg557g93r9qm40wx1g4hx7304lina4smk30h";

  # cargo needs the 'master' branch to exist
  leaveDotGit = true;
  branchName = "master";
}

Fix "Target OID..." cargo failure.

# This file defines the source of Rust / cargo's crates registry
#
# buildRustPackage will automatically download dependencies from the registry
# version that we define here. If you're having problems downloading / finding
# a Rust library, try updating this to a newer commit.

{ runCommand, fetchgit, git }:

let
  version = "2015-04-20";

  src = fetchgit {
      url = git://github.com/rust-lang/crates.io-index.git;

      rev = "c7112fed5f973e438bb600946016c5083e66b1c9";
      sha256 = "0vyrz7d6zvh79hx5fg557g93r9qm40wx1g4hx7304lina4smk30h";

      # cargo needs the 'master' branch to exist
      leaveDotGit = true;
      branchName = "master";
  };

in

runCommand "rustRegistry-${version}-${builtins.substring 0 7 src.rev}" {} ''
  # For some reason, cargo doesn't like fetchgit's git repositories, not even
  # if we clone them (tested with registry rev
  # 965b634156cc5c6f10c7a458392bfd6f27436e7e), failing with the message:
  #
  # "Target OID for the reference doesn't exist on the repository"
  #
  # So we'll just have to create a new git repository from scratch with the
  # contents downloaded with fetchgit...

  mkdir -p $out

  cp -r ${src}/* $out/

  cd $out

  git="${git}/bin/git"

  $git init
  $git config --local user.email "example@example.com"
  $git config --local user.name "example"
  $git add .
  $git commit -m 'Rust registry commit'
''


{
  buildPythonPackage,
  fetchPypi,
  lib,
  nose,
  six,
}:

buildPythonPackage rec {
  pname = "class-registry";
  version = "2.1.2";

  src = fetchPypi {
    inherit pname version;
    sha256 = "0zjf9nczl1ifzj07bgs6mwxsfd5xck9l0lchv2j0fv2n481xp2v7";
  };

  propagatedBuildInputs = [ six ];
  checkInputs = [ nose ];

  # Tests currently failing.
  doCheck = false;

  meta = {
    description = "Factory+Registry pattern for Python classes.";
    homepage = "https://class-registry.readthedocs.io/en/latest/";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ kevincox ];
  };
}

Add typing propagatedBuildInput when using python2

{
  buildPythonPackage,
  fetchPypi,
  lib,
  nose,
  six,
  typing,
  isPy27,
}:

buildPythonPackage rec {
  pname = "class-registry";
  version = "2.1.2";

  src = fetchPypi {
    inherit pname version;
    sha256 = "0zjf9nczl1ifzj07bgs6mwxsfd5xck9l0lchv2j0fv2n481xp2v7";
  };

  propagatedBuildInputs = [ six ] ++ lib.optional isPy27 typing;
  checkInputs = [ nose ];

  # Tests currently failing.
  doCheck = false;

  meta = {
    description = "Factory+Registry pattern for Python classes.";
    homepage = "https://class-registry.readthedocs.io/en/latest/";
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ kevincox ];
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  version = "1.4.2";
  name = "logstash-${version}";

  src = fetchurl {
    url = "https://download.elasticsearch.org/logstash/logstash/logstash-${version}.tar.gz";
    sha256 = "0sc0bwyf96fzs5h3d7ii65v9vvpfbm7w67vk1im9djnlz0d1ggnm";
  };

  dontBuild    = true;
  dontPatchELF = true;
  dontStrip    = true;

  installPhase = ''
    cp -a bin $out
  '';

  meta = {
    description = "Open Source, Distributed, RESTful Search Engine";
    homepage    = http://www.elasticsearch.org;
  };
}

Install all dirs for logstash

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  version = "1.4.2";
  name = "logstash-${version}";

  src = fetchurl {
    url = "https://download.elasticsearch.org/logstash/logstash/logstash-${version}.tar.gz";
    sha256 = "0sc0bwyf96fzs5h3d7ii65v9vvpfbm7w67vk1im9djnlz0d1ggnm";
  };

  dontBuild    = true;
  dontPatchELF = true;
  dontStrip    = true;
  dontPatchShebangs = true;

  installPhase = ''
    ensureDir $out/bin
    ensureDir $out/vendor
    ensureDir $out/lib
    ensureDir $out/locales
    ensureDir $out/patterns
    cp -a bin $out
    cp -a vendor $out
    cp -a lib $out
    cp -a locales $out
    cp -a patterns $out
    patchShebangs $out/bin
  '';

  meta = {
    description = "Open Source, Distributed, RESTful Search Engine";
    homepage    = http://www.elasticsearch.org;
  };
}


# Automatically generated by `update-patch-set.sh'; do not edit.

patch: [
(patch "001" "1qxl74f4n0hv4a807byrgbk4ixd8m50apj3922q2ss9pfi0nra1q")
(patch "002" "1m670g2xzib6r81315q9r24nh9brmxkpq07acch1fwxmih94jqqy")
(patch "003" "0x13c9wir4r44v2vdg96y0ahn8kl3wcmb5y0xn15yvid6pzk28fb")
(patch "004" "0xjlkxfssfsd6jwbqhfjs4hybcps0b9zgz8v86vbhnzag4j39g89")
]

Update readline for patch5 (needed for darwin13).

# Automatically generated by `update-patch-set.sh'; do not edit.

patch: [
(patch "001" "1qxl74f4n0hv4a807byrgbk4ixd8m50apj3922q2ss9pfi0nra1q")
(patch "002" "1m670g2xzib6r81315q9r24nh9brmxkpq07acch1fwxmih94jqqy")
(patch "003" "0x13c9wir4r44v2vdg96y0ahn8kl3wcmb5y0xn15yvid6pzk28fb")
(patch "004" "0xjlkxfssfsd6jwbqhfjs4hybcps0b9zgz8v86vbhnzag4j39g89")
(patch "005" "1x61bjl3wgs1gwla9b3y1hh12m1j5qlbis22258mljjl9mg900pg")
]


{ lib, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  pname = "oauth2_proxy";
  version = "5.1.0";

  goPackagePath = "github.com/pusher/${pname}";

  src = fetchFromGitHub {
    repo = pname;
    owner = "pusher";
    sha256 = "190k1v2c1f6vp9waqs01rlzm0jc3vrmsq1w1n0c2q2nfqx76y2wz";
    rev = "v${version}";
  };

  goDeps = ./deps.nix;

  doCheck = true;

  # Taken from https://github.com/oauth2-proxy/oauth2-proxy/blob/master/Makefile
  buildFlagsArray = ("-ldflags=-X main.VERSION=${version}");

  meta = with lib; {
    description = "A reverse proxy that provides authentication with Google, Github, or other providers";
    homepage = "https://github.com/pusher/oauth2_proxy/";
    license = licenses.mit;
    maintainers = [ maintainers.yorickvp ];
  };
}

Add knl as a maintainer

{ lib, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  pname = "oauth2_proxy";
  version = "5.1.0";

  goPackagePath = "github.com/pusher/${pname}";

  src = fetchFromGitHub {
    repo = pname;
    owner = "pusher";
    sha256 = "190k1v2c1f6vp9waqs01rlzm0jc3vrmsq1w1n0c2q2nfqx76y2wz";
    rev = "v${version}";
  };

  goDeps = ./deps.nix;

  doCheck = true;

  # Taken from https://github.com/oauth2-proxy/oauth2-proxy/blob/master/Makefile
  buildFlagsArray = ("-ldflags=-X main.VERSION=${version}");

  meta = with lib; {
    description = "A reverse proxy that provides authentication with Google, Github, or other providers";
    homepage = "https://github.com/pusher/oauth2_proxy/";
    license = licenses.mit;
    maintainers = with maintainers; [ yorickvp knl ];
  };
}


{ system ? builtins.currentSystem
, pkgs ? import <nixpkgs> { inherit system; }
}:
let
  dns = import ./dns.nix { inherit system pkgs; };
  rbac = import ./rbac.nix { inherit system pkgs; };
  # TODO kubernetes.e2e should eventually replace kubernetes.rbac when it works
  # e2e = import ./e2e.nix { inherit system pkgs; };
in
{
  dns-single-node = dns.singlenode.test;
  dns-multi-node = dns.multinode.test;
  # timed out: https://hydra.nixos.org/build/160710933
  #rbac-single-node = rbac.singlenode.test;
  # timed out: https://hydra.nixos.org/build/160711286
  #rbac-multi-node = rbac.multinode.test;
}

Revert "kubernetes: disable rbac tests"

{ system ? builtins.currentSystem
, pkgs ? import <nixpkgs> { inherit system; }
}:
let
  dns = import ./dns.nix { inherit system pkgs; };
  rbac = import ./rbac.nix { inherit system pkgs; };
  # TODO kubernetes.e2e should eventually replace kubernetes.rbac when it works
  # e2e = import ./e2e.nix { inherit system pkgs; };
in
{
  dns-single-node = dns.singlenode.test;
  dns-multi-node = dns.multinode.test;
  rbac-single-node = rbac.singlenode.test;
  rbac-multi-node = rbac.multinode.test;
}


{ stdenv, fetchurl, doxygen }:

stdenv.mkDerivation rec {
  version = "${passthru.majorVersion}.${passthru.minorVersion}";
  name = "libmpdclient-${version}";

  src = fetchurl {
    url = "http://www.musicpd.org/download/libmpdclient/2/${name}.tar.bz2";
    sha256 = "1qwjkb56rsbk0hwhg7fl15d6sf580a19gh778zcdg374j4yym3hh";
  };

  buildInputs = [ doxygen ];

  passthru = {
    majorVersion = "2";
    minorVersion = "8";
  };

  meta = {
    description = "Client library for MPD (music player daemon)";
    homepage = http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki;
    license = "GPLv2";
    platforms = with stdenv.lib.platforms; linux;
    maintainers = [ stdenv.lib.maintainers.mornfall ];
  };
}

Update to latest upstream (2.9).

{ stdenv, fetchurl, doxygen }:

stdenv.mkDerivation rec {
  version = "${passthru.majorVersion}.${passthru.minorVersion}";
  name = "libmpdclient-${version}";

  src = fetchurl {
    url = "http://www.musicpd.org/download/libmpdclient/2/${name}.tar.xz";
    sha256 = "1jlrfqxqq3gscwrppr2h0xqxd5abl1ypwpwpwnpxs6p9c2jppjbw";
  };

  buildInputs = [ doxygen ];

  passthru = {
    majorVersion = "2";
    minorVersion = "9";
  };

  meta = {
    description = "Client library for MPD (music player daemon)";
    homepage = http://mpd.wikia.com/wiki/Music_Player_Daemon_Wiki;
    license = "GPLv2";
    platforms = with stdenv.lib.platforms; linux;
    maintainers = [ stdenv.lib.maintainers.mornfall ];
  };
}


{ stdenv, fetchurl, pkgconfig, udev, dbus_libs, perl }:

stdenv.mkDerivation rec {
  name = "pcsclite-1.8.8";

  src = fetchurl {
    url = "http://alioth.debian.org/frs/download.php/3862/${name}.tar.bz2";
    sha256 = "1rw5530vr2jf02ziyf32jbd98n5q8zjcfwp5nkw3x3bkgr53arpy";
  };

  # The OS should care on preparing the drivers into this location
  configureFlags = [
    "--enable-usbdropdir=/var/lib/pcsc/drivers"
    "--with-systemdsystemunitdir=$out/lib/systemd/system" # probably
  ];

  preConfigure = ''
    configureFlags="$configureFlags --enable-confdir=$out/etc"
  '';

  buildInputs = [ udev dbus_libs perl ];

  nativeBuildInputs = [ pkgconfig ];

  meta = {
    description = "Middleware to access a smart card using SCard API (PC/SC)";
    homepage = http://pcsclite.alioth.debian.org/;
    license = "BSD";
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}

Upgrade from 1.8.8 -> 1.8.10

{ stdenv, fetchurl, pkgconfig, udev, dbus_libs, perl }:

stdenv.mkDerivation rec {
  version = "1.8.10";
  name = "pcsclite-${version}";

  src = fetchurl {
    url = "http://ftp.de.debian.org/debian/pool/main/p/pcsc-lite/pcsc-lite_${version}.orig.tar.bz2";
    sha256 = "04i63zi9ayg38z3cahp6gf3rgx23w17bmcpdccm2hvaj63blnz30";
  };

  # The OS should care on preparing the drivers into this location
  configureFlags = [
    "--enable-usbdropdir=/var/lib/pcsc/drivers"
    "--with-systemdsystemunitdir=$out/lib/systemd/system" # probably
  ];

  preConfigure = ''
    configureFlags="$configureFlags --enable-confdir=$out/etc"
  '';

  buildInputs = [ udev dbus_libs perl ];

  nativeBuildInputs = [ pkgconfig ];

  meta = {
    description = "Middleware to access a smart card using SCard API (PC/SC)";
    homepage = http://pcsclite.alioth.debian.org/;
    license = "BSD";
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}


with (import <nixpkgs> {});

let
  # MUST match resolver in stack.yaml
  resolver = haskell.packages.lts-9_0.ghc;

  native_libs = [
    libffi
    zlib
    ncurses
    gmp
    pkgconfig
  ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
    Cocoa
    CoreServices
  ]);

in stdenv.mkDerivation {

  name = "idrisBuildEnv";

  buildInputs = [ resolver ] ++ native_libs;

  STACK_IN_NIX_EXTRA_ARGS = builtins.foldl'
    (acc: lib:
      " --extra-lib-dirs=${lib}/lib --extra-include-dirs=${lib}/include" + acc)
    "" native_libs;

  # Needed if one wants to use ghci, due to https://ghc.haskell.org/trac/ghc/ticket/11042
  LD_LIBRARY_PATH = builtins.concatStringsSep ":" (map (lib: lib.out + "/lib") native_libs);
}

Update resolver to match current version of GHC

with (import <nixpkgs> {});

let
  # MUST match GHC of resolver in stack.yaml
  ghc = haskell.packages.ghc802.ghc;

  native_libs = [
    libffi
    zlib
    ncurses
    gmp
    pkgconfig
  ] ++ lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [
    Cocoa
    CoreServices
  ]);

in stdenv.mkDerivation {

  name = "idrisBuildEnv";

  buildInputs = [ ghc ] ++ native_libs;

  STACK_IN_NIX_EXTRA_ARGS = builtins.foldl'
    (acc: lib:
      " --extra-lib-dirs=${lib}/lib --extra-include-dirs=${lib}/include" + acc)
    "" native_libs;

  # Needed if one wants to use ghci, due to https://ghc.haskell.org/trac/ghc/ticket/11042
  LD_LIBRARY_PATH = builtins.concatStringsSep ":" (map (lib: lib.out + "/lib") native_libs);
}


lib: lib.composable-set (lib.import-subdirs ./. [
  "multiplex-activations"
  "socket"
])

Remove relic of multiplex-activations living in the activations dir

lib: lib.composable-set (lib.import-subdirs ./. [
  "socket"
])


{ stdenv, buildPythonPackage, fetchFromGitHub
, future, six, ecdsa, rsa
, pycrypto, pytest, pytestcov, pytestrunner, cryptography
}:

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

  src = fetchFromGitHub {
    owner = "mpdavis";
    repo = "python-jose";
    rev = version;
    sha256 = "1ahq4m86z504bnlk9z473r7r3dprg5m39900rld797hbczdhqa4f";
  };

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

  postPatch = ''
    # File says it's utf-8 so instead of relying on the environment, fix the decoding when reading.
    substituteInPlace setup.py --replace "open('README.md')" "open('README.md',encoding='utf-8')"
  '';

  propagatedBuildInputs = [ future six ecdsa rsa ];

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

Revert "pythonPackages.python-jose: fix build for python 3.6""

{ stdenv, buildPythonPackage, fetchFromGitHub
, future, six, ecdsa, rsa
, pycrypto, pytest, pytestcov, pytestrunner, cryptography
}:

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

  src = fetchFromGitHub {
    owner = "mpdavis";
    repo = "python-jose";
    rev = version;
    sha256 = "1ahq4m86z504bnlk9z473r7r3dprg5m39900rld797hbczdhqa4f";
  };

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

  propagatedBuildInputs = [ future six ecdsa rsa ];

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


{stdenv, fetchurl}:

stdenv.mkDerivation rec {
  name = "cpulimit-${version}";
  version = "2.2";

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

  buildFlags = with stdenv;
    if isDarwin then "osx"
    else if isFreeBSD then "freebsd"
    else "cpulimit";

  installFlags = "PREFIX=$(out)";

  meta = with stdenv.lib; {
    homepage = "http://limitcpu.sourceforge.net/";
    description = "A tool to throttle the CPU usage of programs";
    platforms = with platforms; [linux freebsd darwin];
    license = licenses.gpl2;
    maintainer = [maintainers.rycee];
  };
}

Fix platforms attribute for 'cpulimit' expression.

{stdenv, fetchurl}:

stdenv.mkDerivation rec {
  name = "cpulimit-${version}";
  version = "2.2";

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

  buildFlags = with stdenv;
    if isDarwin then "osx"
    else if isFreeBSD then "freebsd"
    else "cpulimit";

  installFlags = "PREFIX=$(out)";

  meta = with stdenv.lib; {
    homepage = "http://limitcpu.sourceforge.net/";
    description = "A tool to throttle the CPU usage of programs";
    platforms = with platforms; linux ++ freebsd ++ darwin;
    license = licenses.gpl2;
    maintainer = [maintainers.rycee];
  };
}


let
  defaultPkgs = import <nixpkgs> {};
  pinnedPkgs = import (defaultPkgs.fetchFromGitHub {
    owner = "NixOS";
    repo = "nixpkgs-channels";
    rev = "f0fac3b578086066b47360de17618448d066b30e"; # 17 April 2017
    sha256 = "1mpwdminwk1wzycwmgi2c2kwpbcfjwmxiakn7bmvvsaxb30gwyyb";
  }) {};

in

{ nixpkgs ? pinnedPkgs }:

let
  pkgs = if nixpkgs == null then defaultPkgs else pinnedPkgs;
  devEnv = with pkgs; buildEnv {
    name = "devEnv";
    paths = [
      maven3
      openjdk8
      travis
    ];
  };
in
  pkgs.runCommand "dummy" {
    buildInputs = [
      devEnv
    ];
  } ""

Upgrade nixpkgs-channels to latest version @2019-10-15

let
  defaultPkgs = import <nixpkgs> {};
  pinnedPkgs = import (defaultPkgs.fetchFromGitHub {
    owner = "NixOS";
    repo = "nixpkgs-channels";
    rev = "94500c93dc239761bd144128a1684abcd08df6b7"; # 15 Oct 2019
    sha256 = "0p6bd16mb1k5c3zihl1c3d62m419rii102xfb340pccgbd8j34bc";
  }) {};

in

{ nixpkgs ? pinnedPkgs }:

let
  pkgs = if nixpkgs == null then defaultPkgs else pinnedPkgs;
  devEnv = with pkgs; buildEnv {
    name = "devEnv";
    paths = [
      maven3
      openjdk8
      travis
    ];
  };
in
  pkgs.runCommand "dummy" {
    buildInputs = [
      devEnv
    ];
  } ""


args : with args;
let version = lib.attrByPath ["version"] "2.04" args; in
rec {
  src = fetchurl {
    urls = [
      "ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/ttf-arkpandora-${version}.tgz"
      "http://www.users.bigpond.net.au/gavindi/ttf-arkpandora-${version}.tgz"
      ];
    sha256 = "16mfxwlgn6vs3xn00hha5dnmz6bhjiflq138y4zcq3yhk0y9bz51";
  };

  buildInputs = [];
  configureFlags = [];

  /* doConfigure should be specified separately */
  phaseNames = ["doUnpack" "installFonts"];

  name = "arkpandora-" + version;
  meta = {
    description = "Font, metrically identical to Arial and Times New Roman";
  };
}

Add a working URL for arkpandora font

args : with args;
let version = lib.attrByPath ["version"] "2.04" args; in
rec {
  src = fetchurl {
    urls = [
      "ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/ttf-arkpandora-${version}.tgz"
      "http://distcache.FreeBSD.org/ports-distfiles/ttf-arkpandora-${version}.tgz"
      "http://www.users.bigpond.net.au/gavindi/ttf-arkpandora-${version}.tgz"
      ];
    sha256 = "16mfxwlgn6vs3xn00hha5dnmz6bhjiflq138y4zcq3yhk0y9bz51";
  };

  buildInputs = [];
  configureFlags = [];

  /* doConfigure should be specified separately */
  phaseNames = ["doUnpack" "installFonts"];

  name = "arkpandora-" + version;
  meta = {
    description = "Font, metrically identical to Arial and Times New Roman";
  };
}


{ nixpkgs ? import <nixpkgs> {}
, ghc ? nixpkgs.haskell.compiler.ghc7103   # Default needed for Docker build.
}:

with nixpkgs;

let
  spark = nixpkgs.spark.override { mesosSupport = false; };
  openjdk = openjdk7;
  jvmlibdir =
    if stdenv.isLinux
    then "${openjdk}/lib/openjdk/jre/lib/amd64/server"
    else "${openjdk}/jre/lib/server";
in
haskell.lib.buildStackProject {
  name = "sparkle";
  buildInputs =
    [ gradle
      ncurses5 # For intero
      openjdk
      spark
      which
      zlib
      zip
    ];
  inherit ghc;
  extraArgs = ["--extra-lib-dirs=${jvmlibdir}"];
  # XXX Workaround https://ghc.haskell.org/trac/ghc/ticket/11042.
  LD_LIBRARY_PATH = [jvmlibdir];
  # XXX By default recent Nixpkgs passes hardening flags to the
  # linker. The bindnow hardening flag is problematic, because it
  # makes objects fail to load in GHCi, with strange errors about
  # undefined symbols. See
  # https://ghc.haskell.org/trac/ghc/ticket/12684. As a workaround,
  # disable bindnow for now.
  hardeningDisable = [ "bindnow" ];
}

Move sparkle to OpenJDK 8.

{ nixpkgs ? import <nixpkgs> {}
, ghc ? nixpkgs.haskell.compiler.ghc7103   # Default needed for Docker build.
}:

with nixpkgs;

let
  spark = nixpkgs.spark.override { mesosSupport = false; };
  openjdk = openjdk8;
  jvmlibdir =
    if stdenv.isLinux
    then "${openjdk}/lib/openjdk/jre/lib/amd64/server"
    else "${openjdk}/jre/lib/server";
in
haskell.lib.buildStackProject {
  name = "sparkle";
  buildInputs =
    [ gradle
      ncurses5 # For intero
      openjdk
      spark
      which
      zlib
      zip
    ];
  inherit ghc;
  extraArgs = ["--extra-lib-dirs=${jvmlibdir}"];
  # XXX Workaround https://ghc.haskell.org/trac/ghc/ticket/11042.
  LD_LIBRARY_PATH = [jvmlibdir];
  # XXX By default recent Nixpkgs passes hardening flags to the
  # linker. The bindnow hardening flag is problematic, because it
  # makes objects fail to load in GHCi, with strange errors about
  # undefined symbols. See
  # https://ghc.haskell.org/trac/ghc/ticket/12684. As a workaround,
  # disable bindnow for now.
  hardeningDisable = [ "bindnow" ];
}


{ stdenv, fetchurl, buildPythonPackage, blivet
# Propagated to blivet
, useNixUdev ? null, udevSoMajor ? null
}:

let
  blivetOverrides = stdenv.lib.filterAttrs (k: v: v != null) {
    inherit useNixUdev udevSoMajor;
  };
in buildPythonPackage rec {
  name = "nixpart-${version}";
  version = "0.4.0";

  src = fetchurl {
    url = "https://github.com/aszlig/nixpart/archive/v${version}.tar.gz";
    sha256 = "1kgiyqh7gndr0zs3qgi6r0dpy5p71d32c2k9kbd8pjf2xyyb6fk6";
  };

  propagatedBuildInputs = [ (blivet.override blivetOverrides) ];

  doCheck = false;

  meta = {
    description = "NixOS storage manager/partitioner";
    license = stdenv.lib.licenses.gpl2Plus;
    maintainers = [ stdenv.lib.maintainers.aszlig ];
  };
}

Update to bugfix version 0.4.1.

{ stdenv, fetchurl, buildPythonPackage, blivet
# Propagated to blivet
, useNixUdev ? null, udevSoMajor ? null
}:

let
  blivetOverrides = stdenv.lib.filterAttrs (k: v: v != null) {
    inherit useNixUdev udevSoMajor;
  };
in buildPythonPackage rec {
  name = "nixpart-${version}";
  version = "0.4.1";

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

  propagatedBuildInputs = [ (blivet.override blivetOverrides) ];

  doCheck = false;

  meta = {
    description = "NixOS storage manager/partitioner";
    license = stdenv.lib.licenses.gpl2Plus;
    maintainers = [ stdenv.lib.maintainers.aszlig ];
  };
}


{ lib
, aiohttp
, aresponses
, buildPythonPackage
, fetchFromGitHub
, inflection
, pyjwt
, pytest-asyncio
, pytestCheckHook
, python-dateutil
, pythonOlder
}:

let
  # https://github.com/mdz/python-smarttub/issues/10
  pyjwt' = pyjwt.overridePythonAttrs (oldAttrs: rec {
    version = "1.7.1";
    src = oldAttrs.src.override {
      inherit version;
      sha256 = "8d59a976fb773f3e6a39c85636357c4f0e242707394cadadd9814f5cbaa20e96";
    };
  });
in

buildPythonPackage rec {
  pname = "python-smarttub";
  version = "0.0.19";
  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "mdz";
    repo = pname;
    rev = "v${version}";
    sha256 = "01i4pvgvpl7inwhy53c6b34pi5zvfiv2scn507j8jdg5cjs04g80";
  };

  propagatedBuildInputs = [
    aiohttp
    inflection
    pyjwt'
    python-dateutil
  ];

  checkInputs = [
    aresponses
    pytest-asyncio
    pytestCheckHook
  ];

  pythonImportsCheck = [ "smarttub" ];

  meta = with lib; {
    description = "Python API for SmartTub enabled hot tubs";
    homepage = "https://github.com/mdz/python-smarttub";
    license = with licenses; [ mit ];
    maintainers = with maintainers; [ fab ];
  };
}

Revert "python3Packages.python-smarttub: pin pyjwt at 1.7.1"

{ lib
, aiohttp
, aresponses
, buildPythonPackage
, fetchFromGitHub
, inflection
, pyjwt
, pytest-asyncio
, pytestCheckHook
, python-dateutil
, pythonOlder
}:

buildPythonPackage rec {
  pname = "python-smarttub";
  version = "0.0.19";
  disabled = pythonOlder "3.8";

  src = fetchFromGitHub {
    owner = "mdz";
    repo = pname;
    rev = "v${version}";
    sha256 = "01i4pvgvpl7inwhy53c6b34pi5zvfiv2scn507j8jdg5cjs04g80";
  };

  propagatedBuildInputs = [
    aiohttp
    inflection
    pyjwt
    python-dateutil
  ];

  checkInputs = [
    aresponses
    pytest-asyncio
    pytestCheckHook
  ];

  pythonImportsCheck = [ "smarttub" ];

  meta = with lib; {
    description = "Python API for SmartTub enabled hot tubs";
    homepage = "https://github.com/mdz/python-smarttub";
    license = with licenses; [ mit ];
    maintainers = with maintainers; [ fab ];
    broken = pyjwt.version != "1.7.1";
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "thttpd-${version}";
  version = "2.26";

  src = fetchurl {
    url = "http://acme.com/software/thttpd/${name}.tar.gz";
    sha256 = "1dybhpyfrly0m285cdn9jah397bqzylrwzi26gin2h451z3gdcqm";
  };

  prePatch = ''
    sed -i -e 's/getline/getlineX/' extras/htpasswd.c
  '';

  preInstall = ''
    mkdir -p "$out/man/man1"
    sed -i -e 's/-o bin -g bin *//' Makefile
    sed -i -e '/chgrp/d' extras/Makefile
  '';

  meta = {
    description = "Tiny/turbo/throttling HTTP server";
    homepage = "http://www.acme.com/software/thttpd/";
    license = stdenv.lib.licenses.bsd2;
  };
}

Fix SHA256 of the upstream tarball.

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "thttpd-${version}";
  version = "2.26";

  src = fetchurl {
    url = "http://acme.com/software/thttpd/${name}.tar.gz";
    sha256 = "1idlpnwrd5fpmnfh477h1lzanavx8jxir2d8adax46zy472dg4s6";
  };

  prePatch = ''
    sed -i -e 's/getline/getlineX/' extras/htpasswd.c
  '';

  preInstall = ''
    mkdir -p "$out/man/man1"
    sed -i -e 's/-o bin -g bin *//' Makefile
    sed -i -e '/chgrp/d' extras/Makefile
  '';

  meta = {
    description = "Tiny/turbo/throttling HTTP server";
    homepage = "http://www.acme.com/software/thttpd/";
    license = stdenv.lib.licenses.bsd2;
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "libraw1394-2.1.0";

  src = fetchurl {
    url = "mirror://kernel/linux/libs/ieee1394/${name}.tar.gz";
    sha256 = "0w5sw06p51wfq2ahgql93ljkkp3hqprifzcxq8dq71c8zcbgyg58";
  };

  meta = {
    description = "Library providing direct access to the IEEE 1394 bus through the Linux 1394 subsystem's raw1394 user space interface";
    homepage = "https://ieee1394.wiki.kernel.org/index.php/Libraries#libraw1394";
    license = ["GPL" "LGPL"];
  };
}

Set platforms and update license

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "libraw1394-2.1.0";

  src = fetchurl {
    url = "mirror://kernel/linux/libs/ieee1394/${name}.tar.gz";
    sha256 = "0w5sw06p51wfq2ahgql93ljkkp3hqprifzcxq8dq71c8zcbgyg58";
  };

  meta = {
    description = "Library providing direct access to the IEEE 1394 bus through the Linux 1394 subsystem's raw1394 user space interface";
    homepage = "https://ieee1394.wiki.kernel.org/index.php/Libraries#libraw1394";
    license = stdenv.lib.licenses.lgpl21Plus;
    platforms = stdenv.lib.platforms.linux;
  };
}


{ stdenv, fetchFromGitHub, cmake }:

stdenv.mkDerivation rec {
  name = "Vc-${version}";
  version = "1.3.2";

  src = fetchFromGitHub {
    owner = "VcDevel";
    repo = "Vc";
    rev = version;
    sha256 = "119sm0kldr5j163ff04fra35420cvpj040hs7n0mnfbcgyx4nxq9";
  };

  nativeBuildInputs = [ cmake ];

  enableParallelBuilding = true;

  postPatch = ''
    sed -i '/OptimizeForArchitecture()/d' cmake/VcMacros.cmake
    sed -i '/AutodetectHostArchitecture()/d' print_target_architecture.cmake
  '';

  meta = with stdenv.lib; {
    description = "Library for multiprecision complex arithmetic with exact rounding";
    homepage = https://github.com/VcDevel/Vc;
    license = licenses.bsd3;
    platforms = [ "x86_64-linux" "x86_64-darwin" ];
    maintainers = with maintainers; [ abbradar ];
  };
}

Revert "vc: Broken on i686"

{ stdenv, fetchFromGitHub, cmake }:

stdenv.mkDerivation rec {
  name = "Vc-${version}";
  version = "1.3.2";

  src = fetchFromGitHub {
    owner = "VcDevel";
    repo = "Vc";
    rev = version;
    sha256 = "119sm0kldr5j163ff04fra35420cvpj040hs7n0mnfbcgyx4nxq9";
  };

  nativeBuildInputs = [ cmake ];

  enableParallelBuilding = true;

  postPatch = ''
    sed -i '/OptimizeForArchitecture()/d' cmake/VcMacros.cmake
    sed -i '/AutodetectHostArchitecture()/d' print_target_architecture.cmake
  '';

  meta = with stdenv.lib; {
    description = "Library for multiprecision complex arithmetic with exact rounding";
    homepage = https://github.com/VcDevel/Vc;
    license = licenses.bsd3;
    platforms = platforms.all;
    maintainers = with maintainers; [ abbradar ];
  };
}


{stdenv, fetchurl}:

stdenv.mkDerivation rec {
  name = "keyutils-1.2";

  src = fetchurl {
    url = http://people.redhat.com/dhowells/keyutils/keyutils-1.2.tar.bz2;
    sha256 = "0gcv47crbaw6crgn02j1w75mknhnwgkhmfcmwq2qi9iwiwprnv9h";
  };

  patchPhase = ''
    sed -i -e "s, /etc, $out/etc," \
        -e "s, /bin, $out/bin," \
        -e "s, /sbin, $out/sbin," \
        -e "s, /lib, $out/lib," \
        -e "s,/usr,$out," \
        Makefile
  '';

  meta = {
    homepage = http://people.redhat.com/dhowells/keyutils/;
    description = "Tools used to control the Linux kernel key management system";
    license = "GPLv2+";
  };
}

Upgrade keyutils from 1.2 -> 1.5.8

{ stdenv, fetchurl, gnumake, file }:

stdenv.mkDerivation rec {
  name = "keyutils-1.5.8";

  src = fetchurl {
    url = "http://people.redhat.com/dhowells/keyutils/${name}.tar.bz2";
    sha256 = "17419fr7mph8wlhxpqb1bdrghz0db15bmjdgxg1anfgbf9ra6zbc";
  };

  buildInputs = [ file ];

  patchPhase = ''
    sed -i -e "s,/usr/bin/make,${gnumake}/bin/make," \
        -e "s, /etc, $out/etc," \
        -e "s, /bin, $out/bin," \
        -e "s, /sbin, $out/sbin," \
        -e "s, /lib, $out/lib," \
        -e "s, /lib64, $out/lib64," \
        -e "s,/usr,$out," \
        Makefile
  '';

  meta = {
    homepage = http://people.redhat.com/dhowells/keyutils/;
    description = "Tools used to control the Linux kernel key management system";
    license = "GPLv2+";
  };
}


{ stdenv, fetchgit, runCommand, git, cacert, gnupg }:

stdenv.mkDerivation rec {
  name = "firmware-linux-nonfree-${version}";
  version = "2018-03-20";

  src = fetchgit {
    url = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git";
    sha256 = "1gh5a2km33jj151j3q7mgkjzzhaaxlqxbb53n4ff46q658gv0wma";
  };

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

  installFlags = [ "DESTDIR=$(out)" ];

  # Firmware blobs do not need fixing and should not be modified
  dontFixup = true;

  meta = with stdenv.lib; {
    description = "Binary firmware collection packaged by kernel.org";
    homepage = http://packages.debian.org/sid/firmware-linux-nonfree;
    license = licenses.unfreeRedistributableFirmware;
    platforms = platforms.linux;
    maintainers = with maintainers; [ fpletz ];
    priority = 6; # give precedence to kernel firmware
  };

  passthru = { inherit version; };
}

Update SHA and add rev to prevent breakage on future commits.

{ stdenv, fetchgit, runCommand, git, cacert, gnupg }:

stdenv.mkDerivation rec {
  name = "firmware-linux-nonfree-${version}";
  version = "2018-03-20";

  src = fetchgit {
    url = "https://git.kernel.org/pub/scm/linux/kernel/git/firmware/linux-firmware.git";
    rev = "8c1e439c967a50f0698d61aafdba3841aff10db0";
    sha256 = "110vxgahyx5dvylqrxsm5cmx4a32cl2zchvm6cgc270jz75fg7wd";
  };

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

  installFlags = [ "DESTDIR=$(out)" ];

  # Firmware blobs do not need fixing and should not be modified
  dontFixup = true;

  meta = with stdenv.lib; {
    description = "Binary firmware collection packaged by kernel.org";
    homepage = http://packages.debian.org/sid/firmware-linux-nonfree;
    license = licenses.unfreeRedistributableFirmware;
    platforms = platforms.linux;
    maintainers = with maintainers; [ fpletz ];
    priority = 6; # give precedence to kernel firmware
  };

  passthru = { inherit version; };
}


{ capstone
, fetchFromGitHub
, jansson
, lib
, stdenv
, wxGTK30
}:

stdenv.mkDerivation rec {
  pname = "rehex";
  version = "0.3.1";

  src = fetchFromGitHub {
    owner = "solemnwarning";
    repo = pname;
    rev = version;
    sha256 = "1yj9a63j7534mmz8cl1ifg2wmgkxmk6z75jd8lkmc2sfrjbick32";
  };

  buildInputs = [
    capstone
    jansson
    wxGTK30
  ];

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

  meta = with lib; {
    description = "Reverse Engineers' Hex Editor";
    longDescription = ''
      A cross-platform (Windows, Linux, Mac) hex editor for reverse
      engineering, and everything else.
    '';
    homepage = "https://github.com/solemnwarning/rehex";
    license = licenses.gpl2;
    maintainers = with maintainers; [ markus1189 ];
    platforms = platforms.all;
  };
}

Add darwin support from @SuperSandro2000

{ stdenv
, fetchFromGitHub
, capstone
, jansson
, wxGTK30
, darwin
, libicns
, wxmac
}:

stdenv.mkDerivation rec {
  pname = "rehex";
  version = "0.3.1";

  src = fetchFromGitHub {
    owner = "solemnwarning";
    repo = pname;
    rev = version;
    sha256 = "1yj9a63j7534mmz8cl1ifg2wmgkxmk6z75jd8lkmc2sfrjbick32";
  };

  patchPhase = ''
    substituteInPlace Makefile.osx --replace 'iconutil -c icns -o $@ $(ICONSET)' \
      'png2icns $@ $(ICONSET)/icon_16x16.png $(ICONSET)/icon_32x32.png $(ICONSET)/icon_128x128.png $(ICONSET)/icon_256x256.png $(ICONSET)/icon_512x512.png'
  '';

  nativeBuildInputs = stdenv.lib.optionals (stdenv.isDarwin) [ libicns ];

  buildInputs = [ capstone jansson ]
    ++ (stdenv.lib.optionals (!stdenv.isDarwin) [ wxGTK30 ])
    ++ (stdenv.lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ Carbon Cocoa IOKit wxmac ]));

  makeFlags = [ "prefix=$(out)" ] ++ (stdenv.lib.optionals stdenv.isDarwin [ "-f Makefile.osx" ]);

  meta = with stdenv.lib; {
    description = "Reverse Engineers' Hex Editor";
    longDescription = ''
      A cross-platform (Windows, Linux, Mac) hex editor for reverse
      engineering, and everything else.
    '';
    homepage = "https://github.com/solemnwarning/rehex";
    license = licenses.gpl2;
    maintainers = with maintainers; [ markus1189 SuperSandro2000 ];
    platforms = platforms.all;
  };
}


{ lib
, stdenv
, fetchFromGitHub
, cmake
}:

stdenv.mkDerivation rec {
  pname = "cglm";
  version = "0.8.5";

  src = fetchFromGitHub {
    owner = "recp";
    repo = "cglm";
    rev = "v${version}";
    sha256 = "sha256-PJHDZXc0DD/d+K/4uouv5F8gAf1sE5e3jLkGILPMpnI=";
  };

  nativeBuildInputs = [ cmake ];

  cmakeFlags = [
    "-DCMAKE_INSTALL_INCLUDEDIR=include"
    "-DCMAKE_INSTALL_LIBDIR=lib"
  ];

  meta = with lib; {
    homepage = "https://github.com/recp/cglm";
    description = "Highly Optimized Graphics Math (glm) for C";
    license = licenses.mit;
    maintainers = [ maintainers.ivar ];
    platforms = platforms.unix;
  };
}

Revert "cglm: install correct include/lib dir in pkg-config"

{ lib
, stdenv
, fetchFromGitHub
, cmake
}:

stdenv.mkDerivation rec {
  pname = "cglm";
  version = "0.8.5";

  src = fetchFromGitHub {
    owner = "recp";
    repo = "cglm";
    rev = "v${version}";
    sha256 = "sha256-PJHDZXc0DD/d+K/4uouv5F8gAf1sE5e3jLkGILPMpnI=";
  };

  nativeBuildInputs = [ cmake ];

  meta = with lib; {
    homepage = "https://github.com/recp/cglm";
    description = "Highly Optimized Graphics Math (glm) for C";
    license = licenses.mit;
    maintainers = [ maintainers.ivar ];
    platforms = platforms.unix;
  };
}


{ pkgs, ... }:

{
  # List of other files to include:
  imports = [
    ./base.nix
    ./development.nix
  ];

  # Packages for a full user experience on a laptop or workstation.
  packages = with pkgs; [
    # Security:
    pwsafe

    # Terminals and core software:
    wmctrl gnome.gnome_keyring

    # Internet Utilities:
    uzbl chromium conkeror ssvnc pypyPackages.googlecl

    # Media Players/Viewers:
    mpd mpc_cli ncmpcpp vlc mpg123 moc feh zathura

    # Media Ripping:
    handbrake /* FIXME: makemkv (404) */

    # Media Editors:
    audacity gimp inkscape darktable

    # Writing and Designing:
    aspell aspellDicts.en dict
    ghostscript texLiveFull
    gcolor2 impressive libreoffice
    graphviz mscgen xournal

    # Games:
    mednafen

    # Misc.
    tty-clock notify-osd libnotify
  ];
}

Make sure imagemagick is installed

{ pkgs, ... }:

{
  # List of other files to include:
  imports = [
    ./base.nix
    ./development.nix
  ];

  # Packages for a full user experience on a laptop or workstation.
  packages = with pkgs; [
    # Security:
    pwsafe

    # Terminals and core software:
    wmctrl gnome.gnome_keyring

    # Internet Utilities:
    uzbl chromium conkeror ssvnc pypyPackages.googlecl

    # Media Players/Viewers:
    mpd mpc_cli ncmpcpp vlc mpg123 moc feh zathura

    # Media Ripping:
    handbrake /* FIXME: makemkv (404) */

    # Media Editors:
    audacity gimp inkscape darktable imagemagick

    # Writing and Designing:
    aspell aspellDicts.en dict
    ghostscript texLiveFull
    gcolor2 impressive libreoffice
    graphviz mscgen xournal

    # Games:
    mednafen

    # Misc.
    tty-clock notify-osd libnotify
  ];
}


{ fetchurl, stdenv, sqlite, pkgconfig, xapian, glib, gmime, texinfo, emacs, guile }:

stdenv.mkDerivation rec {
  version = "0.9.9.5";
  name = "mu-${version}";

  src = fetchurl {
    url = "https://mu0.googlecode.com/files/mu-${version}.tar.gz";
    sha256 = "1hwkliyb8fjrz5sw9fcisssig0jkdxzhccw0ld0l9a10q1l9mqhp";
  };

  buildInputs = [ sqlite pkgconfig xapian glib gmime texinfo emacs guile ];

  meta = {
    description = "A collection of utilties for indexing and searching Maildirs";
    license = "GPLv3+";
    homepage = "http://www.djcbsoftware.nl/code/mu/";
    platforms = stdenv.lib.platforms.all;
    maintainers = with stdenv.lib.maintainers; [ antono the-kenny ];
  };
}

Install msg2pdf (render html mail to pdf) and mug (gtk gui)

{ fetchurl, stdenv, sqlite, pkgconfig, xapian, glib, gmime, texinfo, emacs, guile
, gtk3, webkit, libsoup, icu }:

stdenv.mkDerivation rec {
  version = "0.9.9.5";
  name = "mu-${version}";

  src = fetchurl {
    url = "https://mu0.googlecode.com/files/mu-${version}.tar.gz";
    sha256 = "1hwkliyb8fjrz5sw9fcisssig0jkdxzhccw0ld0l9a10q1l9mqhp";
  };

  buildInputs = [ sqlite pkgconfig xapian glib gmime texinfo emacs guile
                  gtk3 webkit libsoup icu ];

  preBuild = ''
    # Fix mu4e-builddir (set it to $out)
    substituteInPlace mu4e/mu4e-meta.el.in \
      --replace "@abs_top_builddir@" "$out"

    # We install msg2pdf to bin/msg2pdf, fix its location in elisp
    substituteInPlace mu4e/mu4e-actions.el \
      --replace "/toys/msg2pdf/msg2pdf" "/bin/msg2pdf"
  '';

  # Install mug and msg2pdf
  postInstall = ''
    cp -v toys/msg2pdf/msg2pdf $out/bin/
    cp -v toys/mug/mug $out/bin/
  '';

  meta = {
    description = "A collection of utilties for indexing and searching Maildirs";
    license = "GPLv3+";
    homepage = "http://www.djcbsoftware.nl/code/mu/";
    platforms = stdenv.lib.platforms.all;
    maintainers = with stdenv.lib.maintainers; [ antono the-kenny ];
  };
}


{ lib, stdenv, fetchurl, pkg-config, libdaemon, bison, flex, check }:

stdenv.mkDerivation rec {
  pname = "radvd";
  version = "2.19";

  src = fetchurl {
    url = "http://www.litech.org/radvd/dist/${pname}-${version}.tar.xz";
    sha256 = "0h722f17h7cra1sjgrxhrrvx54mm47fs039909yhbabigxch8kjn";
  };

  nativeBuildInputs = [ pkg-config bison flex check ];
  buildInputs = [ libdaemon ];

  meta = with lib; {
    homepage = "http://www.litech.org/radvd/";
    description = "IPv6 Router Advertisement Daemon";
    platforms = platforms.linux;
    license = licenses.bsdOriginal;
    maintainers = with maintainers; [ fpletz ];
  };
}

Add AR to makeFlags for cross-compiling

{ lib, stdenv, fetchurl, pkg-config, libdaemon, bison, flex, check }:

stdenv.mkDerivation rec {
  pname = "radvd";
  version = "2.19";

  src = fetchurl {
    url = "http://www.litech.org/radvd/dist/${pname}-${version}.tar.xz";
    sha256 = "0h722f17h7cra1sjgrxhrrvx54mm47fs039909yhbabigxch8kjn";
  };

  nativeBuildInputs = [ pkg-config bison flex check ];
  buildInputs = [ libdaemon ];

  # Needed for cross-compilation
  makeFlags = [
    "AR=${stdenv.cc.targetPrefix}ar"
  ];

  meta = with lib; {
    homepage = "http://www.litech.org/radvd/";
    description = "IPv6 Router Advertisement Daemon";
    platforms = platforms.linux;
    license = licenses.bsdOriginal;
    maintainers = with maintainers; [ fpletz ];
  };
}


{ cabal, fetchurl }:

cabal.mkDerivation (self: {
  pname = "Agda-stdlib";
  version = "0.7";

  src = fetchurl {
    url = "http://www.cse.chalmers.se/~nad/software/lib-0.7.tar.gz";
    sha256 = "1ynjgqk8hhnm6rbngy8fjsrd6i4phj2hlan9bk435bbywbl366k3";
  };

  preConfigure = "cd ffi";

  postInstall = ''
      mkdir -p $out/share
      cp -pR ../src $out/share/agda
  '';

  meta = {
    homepage = "http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Libraries.StandardLibrary";
    description = "A standard library for use with the Agda compiler.";
    license = "unknown";
    platforms = self.ghc.meta.platforms;
    maintainers = [ self.stdenv.lib.maintainers.jwiegley ];
  };
})

Build AgdaStdlib before installing it

{ cabal, fetchurl, filemanip, Agda }:

cabal.mkDerivation (self: {
  pname = "Agda-stdlib";
  version = "0.7";

  src = fetchurl {
    url = "http://www.cse.chalmers.se/~nad/software/lib-0.7.tar.gz";
    sha256 = "1ynjgqk8hhnm6rbngy8fjsrd6i4phj2hlan9bk435bbywbl366k3";
  };

  buildDepends = [ filemanip Agda ];

  preConfigure = "cd ffi";

  postInstall = ''
      mkdir -p $out/share
      cd ..
      runhaskell GenerateEverything
      agda -i . -i src Everything.agda
      cp -pR src $out/share/agda
  '';

  meta = {
    homepage = "http://wiki.portal.chalmers.se/agda/pmwiki.php?n=Libraries.StandardLibrary";
    description = "A standard library for use with the Agda compiler.";
    license = "unknown";
    platforms = self.ghc.meta.platforms;
    maintainers = [ self.stdenv.lib.maintainers.jwiegley ];
  };
})


{ stdenv, fetchurl, perl, ghcWithPackages }:

let ghc = ghcWithPackages (hpkgs: with hpkgs; [
            binary zlib utf8-string readline fgl regex-compat HsSyck random
          ]);
in

stdenv.mkDerivation rec {
  name = "jhc-${version}";
  version = "0.8.2";

  src = fetchurl {
    url    = "http://repetae.net/dist/${name}.tar.gz";
    sha256 = "0lrgg698mx6xlrqcylba9z4g1f053chrzc92ri881dmb1knf83bz";
  };

  buildInputs = [ perl ghc ];

  meta = {
    description = "Whole-program, globally optimizing Haskell compiler";
    homepage = "http://repetae.net/computer/jhc/";
    license = stdenv.lib.licenses.bsd3;
    platforms = ["x86_64-linux"]; # 32 bit builds are broken
    maintainers = with stdenv.lib.maintainers; [ aforemny thoughtpolice ];
  };
}

Use the cc that's in scope when building

{ stdenv, fetchurl, perl, ghcWithPackages }:

let ghc = ghcWithPackages (hpkgs: with hpkgs; [
            binary zlib utf8-string readline fgl regex-compat HsSyck random
          ]);
in

stdenv.mkDerivation rec {
  name = "jhc-${version}";
  version = "0.8.2";

  src = fetchurl {
    url    = "http://repetae.net/dist/${name}.tar.gz";
    sha256 = "0lrgg698mx6xlrqcylba9z4g1f053chrzc92ri881dmb1knf83bz";
  };

  buildInputs = [ perl ghc ];

  preConfigure = ''
    configureFlagsArray+=("CC=cc")
    configureFlagsArray+=("--with-hsc2hs=${ghc}/bin/hsc2hs --cc=cc")
  '';

  meta = {
    description = "Whole-program, globally optimizing Haskell compiler";
    homepage = "http://repetae.net/computer/jhc/";
    license = stdenv.lib.licenses.bsd3;
    platforms = ["x86_64-linux"]; # 32 bit builds are broken
    maintainers = with stdenv.lib.maintainers; [ aforemny thoughtpolice ];
  };
}


{stdenv, fetchurl, guile}:

stdenv.mkDerivation rec {
  name = "guile-lint-14";
  src = fetchurl {
    url = "http://www.geocities.com/user42_kevin/guile-lint/"
            + name + ".tar.bz2.bin";
    sha256 = "5bfcf7a623338b2ef81ac097e3e136eaf32856dd0730b7eeaff3161067b5d0be";
  };

  buildInputs = [ guile ];

  unpackPhase = ''tar xjvf "$src" && sourceRoot="$PWD/${name}"'';
  patchPhase = ''
    cat guile-lint.in |						\
    sed 's|^exec guile|exec $\{GUILE:-${guile}/bin/guile}|g' > ,,tmp &&	\
    mv ,,tmp guile-lint.in
  '';

  doCheck = true;

  meta = {
    description = "Guile-Lint checks syntax and semantics in a Guile program or module";
    homepage = http://www.geocities.com/user42_kevin/guile-lint/index.html;
    license = "GPL";
  };
}

Fix url for guile-lint (geocities is dead now)

{stdenv, fetchurl, guile}:

stdenv.mkDerivation rec {
  name = "guile-lint-14";
  src = fetchurl {
    url = "http://download.tuxfamily.org/user42/" + name + ".tar.bz2";
    sha256 = "5bfcf7a623338b2ef81ac097e3e136eaf32856dd0730b7eeaff3161067b5d0be";
  };

  buildInputs = [ guile ];

  unpackPhase = ''tar xjvf "$src" && sourceRoot="$PWD/${name}"'';
  patchPhase = ''
    cat guile-lint.in |						\
    sed 's|^exec guile|exec $\{GUILE:-${guile}/bin/guile}|g' > ,,tmp &&	\
    mv ,,tmp guile-lint.in
  '';

  doCheck = true;

  meta = {
    description = "Guile-Lint checks syntax and semantics in a Guile program or module";
    homepage = http://user42.tuxfamily.org/guile-lint/index.html;
    license = "GPL";
  };
}


{ mkDerivation, fetchFromGitHub
, aeson, aeson-pretty, attoparsec, base, bytestring, conduit, conduit-extra
, containers, exceptions, mtl, optparse-simple, parsec, scientific, stdenv
, text, unordered-containers, vector
}:
mkDerivation rec {
  pname = "jl";
  version = "0.0.5";
  src = fetchFromGitHub {
    owner = "chrisdone";
    repo = "jl";
    rev = "v${version}";
    sha256 = "1hlnwsl4cj0l4x8dxwda2fcnk789cwlphl9gv9cfrivl43mgkgar";
  };
  isLibrary = true;
  isExecutable = true;
  libraryHaskellDepends = [
    aeson attoparsec base bytestring containers exceptions mtl parsec
    scientific text unordered-containers vector
  ];
  executableHaskellDepends = [
    aeson aeson-pretty base bytestring conduit conduit-extra containers
    mtl optparse-simple text vector
  ];
  license = stdenv.lib.licenses.bsd3;
  description = "Functional sed for JSON";
  maintainers = with stdenv.lib.maintainers; [ fgaz ];
  homepage = https://github.com/chrisdone/jl;
}

Patch to work with MonadFail GHC 8.6 change

{ mkDerivation, fetchFromGitHub, fetchpatch
, aeson, aeson-pretty, attoparsec, base, bytestring, conduit, conduit-extra
, containers, exceptions, mtl, optparse-simple, parsec, scientific, stdenv
, text, unordered-containers, vector
}:
mkDerivation rec {
  pname = "jl";
  version = "0.0.5";
  src = fetchFromGitHub {
    owner = "chrisdone";
    repo = "jl";
    rev = "v${version}";
    sha256 = "1hlnwsl4cj0l4x8dxwda2fcnk789cwlphl9gv9cfrivl43mgkgar";
  };
  patches = [
    # MonadFail compatibility patch. Should be removed with the next release
    (fetchpatch {
      url = https://github.com/chrisdone/jl/commit/6d40308811cbc22a96b47ebe69ec308b4e9fd356.patch;
      sha256 = "1pg92ffkg8kim5r8rz8js6fjqyjisg1266sf7p9jyxjgsskwpa4g";
    })
  ];

  isLibrary = true;
  isExecutable = true;
  libraryHaskellDepends = [
    aeson attoparsec base bytestring containers exceptions mtl parsec
    scientific text unordered-containers vector
  ];
  executableHaskellDepends = [
    aeson aeson-pretty base bytestring conduit conduit-extra containers
    mtl optparse-simple text vector
  ];
  license = stdenv.lib.licenses.bsd3;
  description = "Functional sed for JSON";
  maintainers = with stdenv.lib.maintainers; [ fgaz ];
  homepage = https://github.com/chrisdone/jl;
}


{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, vala, gtk3, libgee, fetchpatch
, poppler, libpthreadstubs, gstreamer, gst-plugins-base, gst-plugins-good, gst-libav, librsvg, pcre, gobject-introspection, wrapGAppsHook
, webkitgtk, discount, json-glib }:

stdenv.mkDerivation rec {
  name = "${product}-${version}";
  product = "pdfpc";
  version = "4.5.0";

  src = fetchFromGitHub {
    repo = product;
    owner = product;
    rev = "v${version}";
    sha256 = "0bmy51w6ypz927hxwp5g7wapqvzqmsi3w32rch6i3f94kg1152ck";
  };

  nativeBuildInputs = [
    cmake pkg-config vala
    # For setup hook
    gobject-introspection
    wrapGAppsHook
  ];

  buildInputs = [
    gtk3 libgee poppler
    libpthreadstubs librsvg pcre
    gstreamer
    gst-plugins-base
    (gst-plugins-good.override { gtkSupport = true; })
    gst-libav
    webkitgtk
    discount
    json-glib
  ];

  cmakeFlags = lib.optional stdenv.isDarwin "-DMOVIES=OFF";

  meta = with lib; {
    description = "A presenter console with multi-monitor support for PDF files";
    homepage = "https://pdfpc.github.io/";
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ pSub ];
    platforms = platforms.unix;
  };

}

Update license to match upstream

{ lib, stdenv, fetchFromGitHub, cmake, pkg-config, vala, gtk3, libgee, fetchpatch
, poppler, libpthreadstubs, gstreamer, gst-plugins-base, gst-plugins-good, gst-libav, librsvg, pcre, gobject-introspection, wrapGAppsHook
, webkitgtk, discount, json-glib }:

stdenv.mkDerivation rec {
  name = "${product}-${version}";
  product = "pdfpc";
  version = "4.5.0";

  src = fetchFromGitHub {
    repo = product;
    owner = product;
    rev = "v${version}";
    sha256 = "0bmy51w6ypz927hxwp5g7wapqvzqmsi3w32rch6i3f94kg1152ck";
  };

  nativeBuildInputs = [
    cmake pkg-config vala
    # For setup hook
    gobject-introspection
    wrapGAppsHook
  ];

  buildInputs = [
    gtk3 libgee poppler
    libpthreadstubs librsvg pcre
    gstreamer
    gst-plugins-base
    (gst-plugins-good.override { gtkSupport = true; })
    gst-libav
    webkitgtk
    discount
    json-glib
  ];

  cmakeFlags = lib.optional stdenv.isDarwin "-DMOVIES=OFF";

  meta = with lib; {
    description = "A presenter console with multi-monitor support for PDF files";
    homepage = "https://pdfpc.github.io/";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ pSub ];
    platforms = platforms.unix;
  };

}


{ stdenv, lib, buildPythonPackage, fetchPypi, isPyPy, libgit2, six, cffi }:

buildPythonPackage rec {
  pname = "pygit2";
  version = "0.27.1";

  src = fetchPypi {
    inherit pname version;
    sha256 = "1aa5ba1d59370bda158950ba4849bb6e59f13ac7e6fca5e392bfd873bd2c1cf9";
  };

  preConfigure = lib.optionalString stdenv.isDarwin ''
    export DYLD_LIBRARY_PATH="${libgit2}/lib"
  '';

  propagatedBuildInputs = [ libgit2 six ] ++ lib.optional (!isPyPy) cffi;

  preCheck = ''
    # disable tests that require networking
    rm test/test_repository.py
    rm test/test_credentials.py
    rm test/test_submodule.py
  '';

  meta = with lib; {
    description = "A set of Python bindings to the libgit2 shared library";
    homepage = https://pypi.python.org/pypi/pygit2;
    license = licenses.gpl2;
  };
}

Revert "python: pygit2: 0.26.4 -> 0.27.1"

{ stdenv, lib, buildPythonPackage, fetchPypi, isPyPy, libgit2, six, cffi }:

buildPythonPackage rec {
  pname = "pygit2";
  version = "0.26.4";

  src = fetchPypi {
    inherit pname version;
    sha256 = "a8a0ecce4aadac2675afa5bcda0f698bfe39ec61ac1e15b9264704d1b41bb390";
  };

  preConfigure = lib.optionalString stdenv.isDarwin ''
    export DYLD_LIBRARY_PATH="${libgit2}/lib"
  '';

  propagatedBuildInputs = [ libgit2 six ] ++ lib.optional (!isPyPy) cffi;

  preCheck = ''
    # disable tests that require networking
    rm test/test_repository.py
    rm test/test_credentials.py
    rm test/test_submodule.py
  '';

  meta = with lib; {
    description = "A set of Python bindings to the libgit2 shared library";
    homepage = https://pypi.python.org/pypi/pygit2;
    license = licenses.gpl2;
  };
}


{ stdenv, fetchurl, pkgconfig, glib, gssdp, libsoup, libxml2, libuuid }:

stdenv.mkDerivation rec {
  name = "gupnp-${version}";
  majorVersion = "0.20";
  version = "${majorVersion}.14";

  src = fetchurl {
    url = "mirror://gnome/sources/gupnp/${majorVersion}/gupnp-${version}.tar.xz";
    sha256 = "77ffb940ba77c4a6426d09d41004c75d92652dcbde86c84ac1c847dbd9ad59bd";
  };

  nativeBuildInputs = [ pkgconfig ];
  propagatedBuildInputs = [ glib gssdp libsoup libxml2 libuuid ];

  postInstall = ''
    ln -sv ${libsoup}/include/*/libsoup $out/include
    ln -sv ${libxml2.dev}/include/*/libxml $out/include
    ln -sv ${gssdp}/include/*/libgssdp $out/include
  '';

  meta = {
    homepage = http://www.gupnp.org/;
    description = "An implementation of the UPnP specification";
    license = stdenv.lib.licenses.gpl2;
    platforms = stdenv.lib.platforms.linux;
  };
}

Make explicit that 'dev' output of libsoup is used

{ stdenv, fetchurl, pkgconfig, glib, gssdp, libsoup, libxml2, libuuid }:

stdenv.mkDerivation rec {
  name = "gupnp-${version}";
  majorVersion = "0.20";
  version = "${majorVersion}.14";

  src = fetchurl {
    url = "mirror://gnome/sources/gupnp/${majorVersion}/gupnp-${version}.tar.xz";
    sha256 = "77ffb940ba77c4a6426d09d41004c75d92652dcbde86c84ac1c847dbd9ad59bd";
  };

  nativeBuildInputs = [ pkgconfig ];
  propagatedBuildInputs = [ glib gssdp libsoup libxml2 libuuid ];

  postInstall = ''
    ln -sv ${libsoup.dev}/include/*/libsoup $out/include
    ln -sv ${libxml2.dev}/include/*/libxml $out/include
    ln -sv ${gssdp}/include/*/libgssdp $out/include
  '';

  meta = {
    homepage = http://www.gupnp.org/;
    description = "An implementation of the UPnP specification";
    license = stdenv.lib.licenses.gpl2;
    platforms = stdenv.lib.platforms.linux;
  };
}


{ buildPythonPackage, fetchPypi, lib, cython, jq }:

buildPythonPackage rec {
  pname = "jq";
  version = "1.0.2";

  src = fetchPypi {
    inherit pname version;
    sha256 = "9fe6ce07bc8d209c385d8ba132a2971c69aef015103c46bea87a73a16c5ec147";
  };
  patches = [ ./jq-py-setup.patch ];

  nativeBuildInputs = [ cython ];

  preBuild = ''
    cython jq.pyx
  '';

  buildInputs = [ jq ];

  meta = {
    description = "Python bindings for jq, the flexible JSON processor";
    homepage = "https://github.com/mwilliamson/jq.py";
    license = lib.licenses.bsd2;
    maintainers = with lib.maintainers; [ benley ];
  };
}

Revert "python: jq: 0.1.6 -> 1.0.2"

{ buildPythonPackage, fetchPypi, lib, cython, jq }:

buildPythonPackage rec {
  pname = "jq";
  version = "0.1.6";

  src = fetchPypi {
    inherit pname version;
    sha256 = "34bdf9f9e49e522e1790afc03f3584c6b57329215ea0567fb2157867d6d6f602";
  };
  patches = [ ./jq-py-setup.patch ];

  nativeBuildInputs = [ cython ];

  preBuild = ''
    cython jq.pyx
  '';

  buildInputs = [ jq ];

  meta = {
    description = "Python bindings for jq, the flexible JSON processor";
    homepage = "https://github.com/mwilliamson/jq.py";
    license = lib.licenses.bsd2;
    maintainers = with lib.maintainers; [ benley ];
  };
}


{ lib, fetchFromGitHub, buildPythonPackage
, pythonOlder
, poetry-core
, nose
, typing-extensions
}:

buildPythonPackage rec {
  pname = "rx";
  version = "4.0.4";
  disabled = pythonOlder "3.6";
  format = "pyproject";

  # There are no tests on the pypi source
  src = fetchFromGitHub {
    owner = "ReactiveX";
    repo = "rxpy";
    rev = "refs/tags/v${version}";
    sha256 = "sha256-W1qYNbYV6Roz1GJtP/vpoPD6KigWaaQOWe1R5DZHlUw=";
  };

  nativeBuildInputs = [
    poetry-core
  ];

  propagatedBuildInputs = [
    typing-extensions
  ];

  checkInputs = [ nose ];

  # Some tests are nondeterministic. (`grep sleep -r tests`)
  # test_timeout_schedule_action_cancel: https://hydra.nixos.org/build/74954646
  # test_new_thread_scheduler_timeout: https://hydra.nixos.org/build/74949851
  doCheck = false;

  meta = {
    homepage = "https://github.com/ReactiveX/RxPY";
    description = "Reactive Extensions for Python";
    maintainers = with lib.maintainers; [ thanegill ];
    license = lib.licenses.asl20;
  };
}

Revert "python3Packages.rx: 3.2.0 -> 4.0.4"

{ lib, fetchFromGitHub, buildPythonPackage, pythonOlder, nose }:

buildPythonPackage rec {
  pname = "rx";
  version = "3.2.0";
  disabled = pythonOlder "3.6";

  # There are no tests on the pypi source
  src = fetchFromGitHub {
    owner = "ReactiveX";
    repo = "rxpy";
    rev = "v${version}";
    sha256 = "159ln0c721rrdz0mqyl3zvv6qsry7ql7ddlpwpnxs9q15ik15mnj";
  };

  checkInputs = [ nose ];

  # Some tests are nondeterministic. (`grep sleep -r tests`)
  # test_timeout_schedule_action_cancel: https://hydra.nixos.org/build/74954646
  # test_new_thread_scheduler_timeout: https://hydra.nixos.org/build/74949851
  doCheck = false;

  meta = {
    homepage = "https://github.com/ReactiveX/RxPY";
    description = "Reactive Extensions for Python";
    maintainers = with lib.maintainers; [ thanegill ];
    license = lib.licenses.asl20;
  };
}


{ stdenv, fetchFromGitHub, cmake, cmocka }:

stdenv.mkDerivation rec {
  pname = "libcbor";
  version = "unstable-2019-07-25";

  src = fetchFromGitHub {
    owner = "PJK";
    repo = pname;
    rev = "82512d851205fbc7f65d96a0b4a8e1bad2e4f3c6";
    sha256 = "01hy7n21gxz4gp3gdwm2ywz822p415bj2k9ccxgwz3plvncs4xa1";
  };

  nativeBuildInputs = [ cmake ];
  checkInputs = [ cmocka ];

  doCheck = false; # needs "-DWITH_TESTS=ON", but fails w/compilation error

  NIX_CFLAGS_COMPILE = "-fno-lto";

  meta = with stdenv.lib; {
    description = "CBOR protocol implementation for C and others";
    homepage = "https://github.com/PJK/libcbor";
    license = licenses.mit;
    maintainers = with maintainers; [ dtzWill ];
  };
}

Fix pkgconfig being placed correctly

{ stdenv, fetchFromGitHub, cmake, cmocka }:

stdenv.mkDerivation rec {
  pname = "libcbor";
  version = "unstable-2019-07-25";

  src = fetchFromGitHub {
    owner = "PJK";
    repo = pname;
    rev = "82512d851205fbc7f65d96a0b4a8e1bad2e4f3c6";
    sha256 = "01hy7n21gxz4gp3gdwm2ywz822p415bj2k9ccxgwz3plvncs4xa1";
  };

  nativeBuildInputs = [ cmake ];
  checkInputs = [ cmocka ];

  doCheck = false; # needs "-DWITH_TESTS=ON", but fails w/compilation error

  cmakeFlags = [ "-DCMAKE_INSTALL_LIBDIR=lib" ];

  NIX_CFLAGS_COMPILE = "-fno-lto";

  meta = with stdenv.lib; {
    description = "CBOR protocol implementation for C and others";
    homepage = "https://github.com/PJK/libcbor";
    license = licenses.mit;
    maintainers = with maintainers; [ dtzWill ];
  };
}


{ stdenv, fetchurl, pkgconfig, glib, zlib, libpng, gnumake3, cmake }:

stdenv.mkDerivation rec {
  version = "0.3.2";
  name = "lensfun-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/lensfun/${version}/${name}.tar.gz";
    sha256 = "0cfk8jjhs9nbfjfdy98plrj9ayi59aph0nx6ppslgjhlcvacm2xf";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ glib zlib libpng cmake gnumake3 ];

  configureFlags = "-v";

  meta = with stdenv.lib; {
    platforms = platforms.linux;
    maintainers = [ ];
    license = stdenv.lib.licenses.lgpl3;
    description = "An opensource database of photographic lenses and their characteristics";
    homepage = http://lensfun.sourceforge.net/;
  };
}

Add macOS as a supported platform

{ stdenv, fetchurl, pkgconfig, glib, zlib, libpng, gnumake3, cmake }:

stdenv.mkDerivation rec {
  version = "0.3.2";
  name = "lensfun-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/lensfun/${version}/${name}.tar.gz";
    sha256 = "0cfk8jjhs9nbfjfdy98plrj9ayi59aph0nx6ppslgjhlcvacm2xf";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ glib zlib libpng cmake gnumake3 ];

  configureFlags = "-v";

  meta = with stdenv.lib; {
    platforms = platforms.linux ++ platforms.darwin;
    maintainers = with maintainers; [ enzime ];
    license = stdenv.lib.licenses.lgpl3;
    description = "An opensource database of photographic lenses and their characteristics";
    homepage = http://lensfun.sourceforge.net/;
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "ebtables-2.0.9-2";

  src = fetchurl {
    url = mirror://sourceforge/ebtables/ebtables-v2.0.9-2.tar.gz;
    sha256 = "18yni9zzhfi1ygkgifzj8qpn95cwwiw7j6b3wsl1bij39mj5z1cq";
  };

  makeFlags =
    "LIBDIR=$(out)/lib BINDIR=$(out)/sbin MANDIR=$(out)/share/man " +
    "ETCDIR=$(out)/etc INITDIR=$(TMPDIR) SYSCONFIGDIR=$(out)/etc/sysconfig";

  preBuild =
    ''
      substituteInPlace Makefile --replace '-o root -g root' ""
    '';

  preInstall = "mkdir -p $out/etc/sysconfig";

  meta = {
    description = "A filtering tool for Linux-based bridging firewalls";
    homepage = http://ebtables.sourceforge.net/;
    platforms = stdenv.lib.platforms.linux;
  };
}

Update to 2.0.10-4 and fix build

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "ebtables-${version}";
  version = "2.0.10-4";

  src = fetchurl {
    url = "mirror://sourceforge/ebtables/ebtables-v${version}.tar.gz";
    sha256 = "0pa5ljlk970yfyhpf3iqwfpbc30j8mgn90fapw9cfz909x47nvyw";
  };

  makeFlags =
    [ "LIBDIR=$(out)/lib" "BINDIR=$(out)/sbin" "MANDIR=$(out)/share/man"
      "ETCDIR=$(out)/etc" "INITDIR=$(TMPDIR)" "SYSCONFIGDIR=$(out)/etc/sysconfig"
      "LOCALSTATEDIR=/var"
    ];

  preBuild =
    ''
      substituteInPlace Makefile --replace '-o root -g root' ""
    '';

  NIX_CFLAGS_COMPILE = "-Wno-error";

  preInstall = "mkdir -p $out/etc/sysconfig";

  meta = {
    description = "A filtering tool for Linux-based bridging firewalls";
    homepage = http://ebtables.sourceforge.net/;
    platforms = stdenv.lib.platforms.linux;
  };
}


{stdenv, fetchurl, pciutils, python}:

stdenv.mkDerivation rec {
  version = "1.30";
  name = "x86info-${version}";

  src = fetchurl {
    url = "http://codemonkey.org.uk/projects/x86info/${name}.tgz";
    sha256 = "0a4lzka46nabpsrg3n7akwr46q38f96zfszd73xcback1s2hjc7y";
  };

  buildInputs = [ pciutils python ];

  installPhase = ''
    ensureDir $out/bin
    cp x86info lsmsr $out/bin
  '';

  meta = {
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [jcumming];
    description = "x86info, a CPU identification utility.";
  };
}

Update x86info description. Add Homepage.

{stdenv, fetchurl, pciutils, python}:

stdenv.mkDerivation rec {
  version = "1.30";
  name = "x86info-${version}";

  src = fetchurl {
    url = "http://codemonkey.org.uk/projects/x86info/${name}.tgz";
    sha256 = "0a4lzka46nabpsrg3n7akwr46q38f96zfszd73xcback1s2hjc7y";
  };

  buildInputs = [ pciutils python ];

  installPhase = ''
    ensureDir $out/bin
    cp x86info lsmsr $out/bin
  '';

  meta = {
    description = "An identification utility for the x86 series of processors.";
    longDescription =
    ''
      x86info will identify all Intel/AMD/Centaur/Cyrix/VIA CPUs. It leverages
      the cpuid kernel module where possible.  it supports parsing model specific
      registers (MSRs) via the msr kernel module.  it will approximate processor
      frequency, and identify the cache sizes and layout.
    '';
    platforms = stdenv.lib.platforms.linux;
    license = stdenv.lib.licenses.gpl2;
    homepage = http://codemonkey.org.uk/projects/x86info/;
    maintainers = with stdenv.lib.maintainers; [jcumming];
  };
}


{ stdenv, fetchurl, perl }:

let
  opensslCrossSystem = stdenv.lib.attrByPath [ "openssl" "system" ]
    (throw "openssl needs its platform name cross building" null)
    stdenv.cross;
in

stdenv.mkDerivation (rec {
  name = "openssl-1.0.0";

  src = fetchurl {
    url = "http://www.openssl.org/source/${name}.tar.gz";
    sha1 = "3f800ea9fa3da1c0f576d689be7dca3d55a4cb62";
  };

  buildNativeInputs = [ perl ];

  configureScript = "./config";

  configureFlags="--libdir=lib shared";

  crossAttrs = {
    preConfigure=''
      export cross=$crossSystem-
    '';
    configureFlags="--libdir=lib ${opensslCrossSystem} shared";
    buildPhase = ''
      make CC=$crossConfig-gcc \
        AR="$crossConfig-ar r" \
        RANLIB=$crossConfig-ranlib
    '';
  };

  meta = {
    homepage = http://www.openssl.org/;
    description = "A cryptographic library that implements the SSL and TLS protocols";
  };
}
//
(if stdenv.isDarwin then {
  patches = ./darwin-arch.patch;
}
else { })
)

Revert "Install libraries to $out/lib instead of $out/lib64"

{ stdenv, fetchurl, perl }:

let
  opensslCrossSystem = stdenv.lib.attrByPath [ "openssl" "system" ]
    (throw "openssl needs its platform name cross building" null)
    stdenv.cross;
in

stdenv.mkDerivation (rec {
  name = "openssl-1.0.0";

  src = fetchurl {
    url = "http://www.openssl.org/source/${name}.tar.gz";
    sha1 = "3f800ea9fa3da1c0f576d689be7dca3d55a4cb62";
  };

  buildNativeInputs = [ perl ];

  configureScript = "./config";

  configureFlags = "shared";

  crossAttrs = {
    configurePhase = ''
      export cross=$crossSystem-
      ./Configure --prefix=$out ${opensslCrossSystem} shared
    '';
    buildPhase = ''
      make CC=$crossConfig-gcc \
        AR="$crossConfig-ar r" \
        RANLIB=$crossConfig-ranlib
    '';
  };

  meta = {
    homepage = http://www.openssl.org/;
    description = "A cryptographic library that implements the SSL and TLS protocols";
  };
}
//
(if stdenv.isDarwin then {
  patches = ./darwin-arch.patch;
}
else { })
)


{ stdenv, buildPythonPackage, fetchPypi, click }:

buildPythonPackage rec {
  pname = "click-log";
  version = "0.3.2";

  src = fetchPypi {
    inherit pname version;
    sha256 = "16fd1ca3fc6b16c98cea63acf1ab474ea8e676849dc669d86afafb0ed7003124";
  };

  propagatedBuildInputs = [ click ];

  meta = with stdenv.lib; {
    homepage = https://github.com/click-contrib/click-log/;
    description = "Logging integration for Click";
    license = licenses.mit;
    maintainers = with maintainers; [ ];
  };
}

Revert "python: click-log: 0.2.1 -> 0.3.2"

{ stdenv, buildPythonPackage, fetchPypi, click }:

buildPythonPackage rec {
  pname = "click-log";
  version = "0.2.1";

  src = fetchPypi {
    inherit pname version;
    sha256 = "1r1x85023cslb2pwldd089jjk573mk3w78cnashs77wrx7yz8fj9";
  };

  propagatedBuildInputs = [ click ];

  meta = with stdenv.lib; {
    homepage = https://github.com/click-contrib/click-log/;
    description = "Logging integration for Click";
    license = licenses.mit;
    maintainers = with maintainers; [ ];
  };
}


{ 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 = [ ];
  };
}

Fix build outside of chroot

{ 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

    substituteInPlace pkg/libopts/mklibsrc.sh --replace /tmp $TMPDIR
  '';

  #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 }:

stdenv.mkDerivation rec {
  name = "dnsmasq-2.71";

  src = fetchurl {
    url = "http://www.thekelleys.org.uk/dnsmasq/${name}.tar.gz";
    sha256 = "1i1l2s2bcs6yx05wh1p2rf4bl0jfdgmg77b33gh44r1rdbv6933x";
  };

  makeFlags = "DESTDIR= BINDIR=$(out)/bin MANDIR=$(out)/man LOCALEDIR=$(out)/share/locale";

  meta = {
    description = "An integrated DNS, DHCP and TFTP server for small networks";
    homepage = http://www.thekelleys.org.uk/dnsmasq/doc.html;
    license = "GPL";
    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
    maintainers = [ stdenv.lib.maintainers.eelco ];
  };
}

Use .tar.xz instead of .tar.gz for dnsmasq

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "dnsmasq-2.71";

  src = fetchurl {
    url = "http://www.thekelleys.org.uk/dnsmasq/${name}.tar.xz";
    sha256 = "1fpzpzja7qr8b4kfdhh4i4sijp62c634yf0xvq2n4p7d5xbzn6a9";
  };

  makeFlags = "DESTDIR= BINDIR=$(out)/bin MANDIR=$(out)/man LOCALEDIR=$(out)/share/locale";

  meta = {
    description = "An integrated DNS, DHCP and TFTP server for small networks";
    homepage = http://www.thekelleys.org.uk/dnsmasq/doc.html;
    license = "GPL";
    platforms = stdenv.lib.platforms.linux ++ stdenv.lib.platforms.darwin;
    maintainers = [ stdenv.lib.maintainers.eelco ];
  };
}


runCommand: git: repository: branch:
  import (runCommand "head-revision"
    { buildInputs = [ git ];
      dummy = builtins.currentTime;
    }
    ''
      rev=$(git ls-remote ${repository} | grep "refs/${branch}$" | awk '{ print $1 }')
      echo "[ \"$rev\" ]" > $out
      echo Latest revision in ${branch} is $rev
    '');

Remove semicolon causing evaluation error.


{ pkgs, config, ... }:

{
  programs.bash = {
    enable = true;
    historyControl = [ "ignorespace" ];

    initExtra = ''
      # Shell prompt
      function git_slug {
          if $(test -d .git); then
              if $([ -z "$(git status --porcelain)" ]); then
                  echo "$(git rev-parse --abbrev-ref HEAD)  "
              else
                  echo "$(git rev-parse --abbrev-ref HEAD)* "
              fi
          fi
      }
      export PS1='\[\033[1;33m\]\w\[\033[0m\] $(git_slug)$ '
    '';

    shellAliases = {
      l = "LC_COLLATE=C ls --group-directories-first --color -FHAlh -w 80";
      ll = "LC_COLLATE=C ls --group-directories-first --color -FHA -w 80";
      ls = "LC_COLLATE=C ls --group-directories-first --color -FH -w 80";
      vi = "${config.home.sessionVariables.EDITOR}";
      vim = "${config.home.sessionVariables.EDITOR}";
      space = "find -maxdepth 1 -exec du -sh '{}' \\; | sort -h";
      suspace = "sudo find -maxdepth 1 -exec du -sh '{}' --exclude='proc' \\; | sort -h";
    };

    shellOptions = [
      "cmdhist"
      "histappend"
      "checkwinsize"
      "extglob"
      "globstar"
      "checkjobs"
    ];
  };
}

Use git prompt in repo subdirs

{ pkgs, config, ... }:

{
  programs.bash = {
    enable = true;
    historyControl = [ "ignorespace" ];

    initExtra = ''
      # Shell prompt
      function git_slug {
          if git status --porcelain &>/dev/null; then
              if [ -z "$(git status --porcelain)" ]; then
                  echo "$(git rev-parse --abbrev-ref HEAD)  "
              else
                  echo "$(git rev-parse --abbrev-ref HEAD)* "
              fi
          fi
      }
      export PS1='\[\033[1;33m\]\w\[\033[0m\] $(git_slug)$ '
    '';

    shellAliases = {
      l = "LC_COLLATE=C ls --group-directories-first --color -FHAlh -w 80";
      ll = "LC_COLLATE=C ls --group-directories-first --color -FHA -w 80";
      ls = "LC_COLLATE=C ls --group-directories-first --color -FH -w 80";
      vi = "${config.home.sessionVariables.EDITOR}";
      vim = "${config.home.sessionVariables.EDITOR}";
      space = "find -maxdepth 1 -exec du -sh '{}' \\; | sort -h";
      suspace = "sudo find -maxdepth 1 -exec du -sh '{}' --exclude='proc' \\; | sort -h";
    };

    shellOptions = [
      "cmdhist"
      "histappend"
      "checkwinsize"
      "extglob"
      "globstar"
      "checkjobs"
    ];
  };
}


{ lib
, bash
, stdenv
, lz4
, ffmpeg-full
, fetchFromGitHub
, openssh
, makeWrapper
}:

stdenv.mkDerivation rec {
  pname = "restream";
  version = "1.2.0";

  src = fetchFromGitHub {
    owner = "rien";
    repo = pname;
    rev = version;
    sha256 = "0vyj0kng8c9inv2rbw1qdr43ic15s5x8fvk9mbw0vpc6g723x99g";
  };

  nativeBuildInputs = [ makeWrapper ];

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstall

    install -D ${src}/restream.arm.static $out/libexec/restream.arm.static
    install -D ${src}/reStream.sh $out/bin/restream

    runHook postInstall
  '';

  postInstall = ''
    # `ffmpeg-full` is used here to bring in `ffplay`, which is used to display
    # the reMarkable framebuffer
    wrapProgram "$out/bin/restream" --suffix PATH ":" "${lib.makeBinPath [ ffmpeg-full lz4 openssh ]}"
  '';

  meta = with lib; {
    description = "reMarkable screen sharing over SSH";
    homepage = "https://github.com/rien/reStream";
    license = licenses.mit;
    maintainers = [ maintainers.cpcloud ];
  };
}

Add nc command to wrapper

{ lib
, bash
, stdenv
, lz4
, ffmpeg-full
, fetchFromGitHub
, openssh
, netcat
, makeWrapper
}:

stdenv.mkDerivation rec {
  pname = "restream";
  version = "1.2.0";

  src = fetchFromGitHub {
    owner = "rien";
    repo = pname;
    rev = version;
    sha256 = "0vyj0kng8c9inv2rbw1qdr43ic15s5x8fvk9mbw0vpc6g723x99g";
  };

  nativeBuildInputs = [ makeWrapper ];

  dontConfigure = true;
  dontBuild = true;

  installPhase = ''
    runHook preInstall

    install -D ${src}/restream.arm.static $out/libexec/restream.arm.static
    install -D ${src}/reStream.sh $out/bin/restream

    runHook postInstall
  '';

  postInstall = ''
    # `ffmpeg-full` is used here to bring in `ffplay`, which is used to display
    # the reMarkable framebuffer
    wrapProgram "$out/bin/restream" --suffix PATH ":" "${lib.makeBinPath [ ffmpeg-full lz4 openssh netcat ]}"
  '';

  meta = with lib; {
    description = "reMarkable screen sharing over SSH";
    homepage = "https://github.com/rien/reStream";
    license = licenses.mit;
    maintainers = [ maintainers.cpcloud ];
  };
}


{stdenv, fetchurl, mesa, freeglut, glew, libXmu, libXext, libX11
  }:

stdenv.mkDerivation rec {
  version = "1.4.0";
  name = "opencsg-${version}";
  src = fetchurl {
    url = "http://www.opencsg.org/OpenCSG-${version}.tar.gz";
    sha256 = "13c73jxadm27h7spdh3qj1v6rnn81v4xwqlv5a6k72pv9kjnpd7c";
  };

  buildInputs = [mesa freeglut glew libXmu libXext libX11];

  doCheck = false;

  installPhase = ''
    mkdir -pv "$out/"{bin,share/doc/opencsg}

    cp example/opencsgexample "$out/bin"
    cp -r include lib "$out"

    cp license.txt "$out/share/doc/opencsg"
  '';

  meta = {
    description = "Constructive Solid Geometry library";
    homepage = "http://www.opencsg.org/";
    platforms = with stdenv.lib.platforms;
      linux;
    maintainers = with stdenv.lib.maintainers;
      [raskin];
  };
}

Fix build related to missing libX11 linking the example.

{stdenv, fetchurl, mesa, freeglut, glew, libXmu, libXext, libX11
  }:

stdenv.mkDerivation rec {
  version = "1.4.0";
  name = "opencsg-${version}";
  src = fetchurl {
    url = "http://www.opencsg.org/OpenCSG-${version}.tar.gz";
    sha256 = "13c73jxadm27h7spdh3qj1v6rnn81v4xwqlv5a6k72pv9kjnpd7c";
  };

  buildInputs = [mesa freeglut glew libXmu libXext libX11];

  doCheck = false;

  preConfigure = ''
    sed -i 's/^\(LIBS *=.*\)$/\1 -lX11/' example/Makefile
  '';

  installPhase = ''
    mkdir -pv "$out/"{bin,share/doc/opencsg}

    cp example/opencsgexample "$out/bin"
    cp -r include lib "$out"

    cp license.txt "$out/share/doc/opencsg"
  '';

  meta = {
    description = "Constructive Solid Geometry library";
    homepage = "http://www.opencsg.org/";
    platforms = with stdenv.lib.platforms;
      linux;
    maintainers = with stdenv.lib.maintainers;
      [raskin];
  };
}


{ stdenv, fetchurl, udev, polkit, dbus_glib, ppp, intltool, pkgconfig, libmbim, libqmi }:

stdenv.mkDerivation rec {
  name = "ModemManager-0.7.991";

  src = fetchurl {
    url = "mirror://gnome/sources/ModemManager/0.7/${name}.tar.xz";
    sha256 = "0p8shqsbgnsazim7s52ylxjk064cbx2n1vm1jgywr7i58hsd6n4y";
  };

  nativeBuildInputs = [ intltool pkgconfig ];

  buildInputs = [ udev polkit dbus_glib ppp libmbim libqmi ];

  configureFlags = [
    "--with-polkit"
    "--with-udev-base-dir=$(out)/lib/udev"
    "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
  ];

  meta = {
    description = "WWAN modem manager, part of NetworkManager";
    maintainers = [ stdenv.lib.maintainers.urkud ];
    platforms = stdenv.lib.platforms.linux;
  };
}

Update from 0.7.991 to 1.2.0

{ stdenv, fetchurl, udev, polkit, dbus_glib, ppp, intltool, pkgconfig, libmbim, libqmi }:

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

  src = fetchurl {
    url = "http://www.freedesktop.org/software/ModemManager/${name}.tar.xz";
    sha256 = "1g08ciyhys9bi5m45z30kln17zni4r07i5byjaglmwq6np1xincb";
  };

  nativeBuildInputs = [ intltool pkgconfig ];

  buildInputs = [ udev polkit dbus_glib ppp libmbim libqmi ];

  configureFlags = [
    "--with-polkit"
    "--with-udev-base-dir=$(out)/lib/udev"
    "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
  ];

  postInstall = ''
    # systemd in NixOS doesn't use `systemctl enable`, so we need to establish
    # aliases ourselves.
    ln -s $out/etc/systemd/system/ModemManager.service \
      $out/etc/systemd/system/dbus-org.freedesktop.ModemManager1.service
  '';

  meta = {
    description = "WWAN modem manager, part of NetworkManager";
    maintainers = [ stdenv.lib.maintainers.urkud ];
    platforms = stdenv.lib.platforms.linux;
  };
}


{ config, pkgs, ... }:

{
  services.xserver = {
    enable = true;
    layout = "us";

    displayManager.slim = {
      enable = true;
      autoLogin = true;
      defaultUser = "kiba";
    };

    desktopManager = {
      # Disable the defaults.  Don't use a desktop manager or xterm.
      default = "none";
      xterm.enable = false;
    };

    windowManager = {
      default = "spectrwm";
      spectrwm.enable = true;
    };
  };

  # Fonts to include
  fonts.fonts = [
    pkgs.corefonts # Microsoft free fonts
    pkgs.source-code-pro
    pkgs.source-sans-pro
    pkgs.source-serif-pro
  ];

  # Default fonts
  fonts.fontconfig.defaultFonts = {
    monospace = [ "Source Code Pro" ];
    sansSerif = [ "Source Sans Pro" ];
    serif = [ "Source Serif Pro" ];
  };

  environment.systemPackages = [
    # Browsers
    pkgs.chromium
    pkgs.firefox

    # Terminal
    pkgs.st

    # Tools
    pkgs.dmenu
  ];
}

Add xsel and i3lock to graphical workstations

{ config, pkgs, ... }:

{
  services.xserver = {
    enable = true;
    layout = "us";

    displayManager.slim = {
      enable = true;
      autoLogin = true;
      defaultUser = "kiba";
    };

    desktopManager = {
      # Disable the defaults.  Don't use a desktop manager or xterm.
      default = "none";
      xterm.enable = false;
    };

    windowManager = {
      default = "spectrwm";
      spectrwm.enable = true;
    };
  };

  # Fonts to include
  fonts.fonts = [
    pkgs.corefonts # Microsoft free fonts
    pkgs.source-code-pro
    pkgs.source-sans-pro
    pkgs.source-serif-pro
  ];

  # Default fonts
  fonts.fontconfig.defaultFonts = {
    monospace = [ "Source Code Pro" ];
    sansSerif = [ "Source Sans Pro" ];
    serif = [ "Source Serif Pro" ];
  };

  environment.systemPackages = [
    # Browsers
    pkgs.chromium
    pkgs.firefox

    # Terminal
    pkgs.st

    # Menu
    pkgs.dmenu

    # Clipboard
    pkgs.xsel

    # Graphical lock
    pkgs.i3lock
  ];
}


{ mkDerivation, base, bytestring, jsaddle-webkit2gtk, jsaddle-wkwebview, jsaddle-warp, reflex
, reflex-dom-core, stdenv, text, ghc, hostPlatform, jsaddle-clib, android-activity ? null
}:
let isAndroid = hostPlatform.libc == "bionic";
in mkDerivation {
  pname = "reflex-dom";
  version = "0.4";
  src = builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [ ".git" "dist" ])) ./.;
  libraryHaskellDepends = [
    base bytestring reflex reflex-dom-core text
  ] ++ (if ghc.isGhcjs or false then [
  ] else if hostPlatform.isDarwin then [
    jsaddle-wkwebview
    jsaddle-warp
  ] else if isAndroid then [
    jsaddle-clib
    android-activity
  ] else [
    jsaddle-webkit2gtk
    jsaddle-warp
  ]);
  configureFlags = if isAndroid then [ "-fandroid" ] else [];
  description = "Functional Reactive Web Apps with Reflex";
  license = stdenv.lib.licenses.bsd3;
}

Allow specification of ghc backend package

{ mkDerivation, base, bytestring, jsaddle-webkit2gtk, jsaddle-wkwebview, jsaddle-warp, reflex
, reflex-dom-core, stdenv, text, ghc, hostPlatform, jsaddle-clib, android-activity ? null
, ghcBackend ? "webkit2gtk"
}:
assert (builtins.elem ghcBackend [ "warp" "webkit2gtk" ]);
let isAndroid = hostPlatform.libc == "bionic";
    ghcBackendPackage = {
      webkit2gtk = jsaddle-webkit2gtk;
      warp = jsaddle-warp;
    }.${ghcBackend};
in mkDerivation {
  pname = "reflex-dom";
  version = "0.4";
  src = builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [ ".git" "dist" ])) ./.;
  libraryHaskellDepends = [
    base bytestring reflex reflex-dom-core text
  ] ++ (if ghc.isGhcjs or false then [
  ] else if hostPlatform.isDarwin then [
    jsaddle-wkwebview
    jsaddle-warp
  ] else if isAndroid then [
    jsaddle-clib
    android-activity
  ] else [
    ghcBackendPackage
  ]);
  configureFlags = if isAndroid then [
    "-fandroid"
  ] else if ghcBackend == "warp" then [
    "-fuse-warp"
  ] else [
  ];
  description = "Functional Reactive Web Apps with Reflex";
  license = stdenv.lib.licenses.bsd3;
}


{ stdenv, fetchurl, autoconf, automake, libtool, libxml2, cppunit, boost
, apr, aprutil, db45, expat
}:

stdenv.mkDerivation {
  name = "log4cxx-0.10.0";

  src = fetchurl {
    url = http://apache.mirrors.hoobly.com/logging/log4cxx/0.10.0/apache-log4cxx-0.10.0.tar.gz;
    sha256 = "130cjafck1jlqv92mxbn47yhxd2ccwwnprk605c6lmm941i3kq0d";
  };

  buildInputs = [autoconf automake libtool libxml2 cppunit boost apr aprutil db45 expat];

  meta = {
    homepage = http://logging.apache.org/log4cxx/index.html;
    description = "A logging framework for C++ patterned after Apache log4j";
  };
}

Fix build by adding missing includes.

{ stdenv, fetchurl, autoconf, automake, libtool, libxml2, cppunit, boost
, apr, aprutil, db45, expat
}:

stdenv.mkDerivation {
  name = "log4cxx-0.10.0";

  src = fetchurl {
    url = http://apache.mirrors.hoobly.com/logging/log4cxx/0.10.0/apache-log4cxx-0.10.0.tar.gz;
    sha256 = "130cjafck1jlqv92mxbn47yhxd2ccwwnprk605c6lmm941i3kq0d";
  };

  postPatch = ''
    sed -i -e '1,/^#include/ {
      /^#include/i \
        #include <cstdio> \
        #include <cstdlib> \
        #include <cstring>
    }' src/examples/cpp/console.cpp \
       src/main/cpp/inputstreamreader.cpp \
       src/main/cpp/socketoutputstream.cpp
  '';

  buildInputs = [autoconf automake libtool libxml2 cppunit boost apr aprutil db45 expat];

  meta = {
    homepage = http://logging.apache.org/log4cxx/index.html;
    description = "A logging framework for C++ patterned after Apache log4j";
  };
}


{ stdenv, fetchurl, zlib, xz }:

assert zlib != null;

stdenv.mkDerivation rec {
  name = "libpng-1.2.46";

  src = fetchurl {
    url = "mirror://sourceforge/libpng/${name}.tar.xz";
    sha256 = "0rcx4v4khdkrvz7b02fmx7lab2pk1lal4dhx9widv36b7g2xvwzn";
  };

  propagatedBuildInputs = [ zlib ];

  buildNativeInputs = [ xz ];

  passthru = { inherit zlib; };

  meta = {
    description = "The official reference implementation for the PNG file format";
    homepage = http://www.libpng.org/pub/png/libpng.html;
    license = "free-non-copyleft"; # http://www.libpng.org/pub/png/src/libpng-LICENSE.txt
  };
}

Add a notice about libpng branch

{ stdenv, fetchurl, zlib, xz }:

assert zlib != null;

# If you want to upgrade libpng, look at libpng15 branch
stdenv.mkDerivation rec {
  name = "libpng-1.2.46";

  src = fetchurl {
    url = "mirror://sourceforge/libpng/${name}.tar.xz";
    sha256 = "0rcx4v4khdkrvz7b02fmx7lab2pk1lal4dhx9widv36b7g2xvwzn";
  };

  propagatedBuildInputs = [ zlib ];

  buildNativeInputs = [ xz ];

  passthru = { inherit zlib; };

  meta = {
    description = "The official reference implementation for the PNG file format";
    homepage = http://www.libpng.org/pub/png/libpng.html;
    license = "free-non-copyleft"; # http://www.libpng.org/pub/png/src/libpng-LICENSE.txt
  };
}


{ stdenv, fetchurl, cpio, zlib, bzip2, file, elfutils, nspr, nss, popt, db, 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 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 = {
    homepage = http://www.rpm.org/;
    license = "GPLv2";
    description = "The RPM Package Manager";
    maintainers = stdenv.lib.maintainers.mornfall;
  };
}

Revert to using db4, fails to build with db5.

{ 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;
  };
}


{ lib, stdenv, fetchurl
, enableAlsa ? true, alsaLib ? null
, enableLibao ? true, libao ? null
, enableLame ? false, lame ? null
, enableLibmad ? true, libmad ? null
, enableLibogg ? true, libogg ? null, libvorbis ? null
}:

with stdenv.lib;

stdenv.mkDerivation rec {
  name = "sox-14.4.1";

  src = fetchurl {
    url = "mirror://sourceforge/sox/${name}.tar.gz";
    sha256 = "16x8gykfjdhxg0kdxwzcwgwpm5caa08y2mx18siqsq0ywmpjr34s";
  };

  buildInputs =
    optional (enableAlsa && stdenv.isLinux) alsaLib ++
    optional enableLibao libao ++
    optional enableLame lame ++
    optional enableLibmad libmad ++
    optionals enableLibogg [ libogg libvorbis ];

  meta = {
    description = "Sample Rate Converter for audio";
    homepage = http://www.mega-nerd.com/SRC/index.html;
    maintainers = [ lib.maintainers.marcweber lib.maintainers.shlevy ];
    license = lib.licenses.gpl2Plus;
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
  };
}

Enable support for FLAC and PNG.

{ lib, stdenv, fetchurl
, enableAlsa ? true, alsaLib ? null
, enableLibao ? true, libao ? null
, enableLame ? false, lame ? null
, enableLibmad ? true, libmad ? null
, enableLibogg ? true, libogg ? null, libvorbis ? null
, enableFLAC ? true, flac ? null
, enablePNG ? true, libpng ? null
}:

with stdenv.lib;

stdenv.mkDerivation rec {
  name = "sox-14.4.1";

  src = fetchurl {
    url = "mirror://sourceforge/sox/${name}.tar.gz";
    sha256 = "16x8gykfjdhxg0kdxwzcwgwpm5caa08y2mx18siqsq0ywmpjr34s";
  };

  buildInputs =
    optional (enableAlsa && stdenv.isLinux) alsaLib ++
    optional enableLibao libao ++
    optional enableLame lame ++
    optional enableLibmad libmad ++
    optionals enableLibogg [ libogg libvorbis ] ++
    optional enableFLAC flac ++
    optional enablePNG libpng;

  meta = {
    description = "Sample Rate Converter for audio";
    homepage = http://www.mega-nerd.com/SRC/index.html;
    maintainers = [ lib.maintainers.marcweber lib.maintainers.shlevy ];
    license = lib.licenses.gpl2Plus;
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
  };
}


{ stdenv, fetchurl, cmake, qt4, perl, bzip2, libxml2, exiv2
, clucene_core, fam, zlib, dbus_tools, pkgconfig
}:

stdenv.mkDerivation rec {
  name = "strigi-${version}";
  version = "0.7.8";

  src = fetchurl {
    url = "http://www.vandenoever.info/software/strigi/${name}.tar.bz2";
    sha256 = "12grxzqwnvbyqw7q1gnz42lypadxmq89vk2qpxczmpmc4nk63r23";
  };

  includeAllQtDirs = true;

  CLUCENE_HOME = clucene_core;

  buildInputs =
    [ zlib bzip2 stdenv.cc.libc libxml2 qt4 exiv2 clucene_core fam dbus_tools ];

  nativeBuildInputs = [ cmake pkgconfig perl ];

  patches = [ ./export_bufferedstream.patch ];

  enableParallelBuilding = true;

  meta = {
    homepage = http://strigi.sourceforge.net;
    description = "A very fast and efficient crawler to index data on your harddrive";
    license = "LGPL";
    maintainers = with stdenv.lib.maintainers; [ sander urkud ];
    inherit (qt4.meta) platforms;
  };
}

Fix libraries being installed in $out/$out/lib

{ stdenv, fetchurl, cmake, qt4, perl, bzip2, libxml2, exiv2
, clucene_core, fam, zlib, dbus_tools, pkgconfig
}:

stdenv.mkDerivation rec {
  name = "strigi-${version}";
  version = "0.7.8";

  src = fetchurl {
    url = "http://www.vandenoever.info/software/strigi/${name}.tar.bz2";
    sha256 = "12grxzqwnvbyqw7q1gnz42lypadxmq89vk2qpxczmpmc4nk63r23";
  };

  includeAllQtDirs = true;

  CLUCENE_HOME = clucene_core;

  buildInputs =
    [ zlib bzip2 stdenv.cc.libc libxml2 qt4 exiv2 clucene_core fam dbus_tools ];

  nativeBuildInputs = [ cmake pkgconfig perl ];

  patches = [ ./export_bufferedstream.patch ];

  enableParallelBuilding = true;

  # Strigi installs some libraries in an incorrect place
  # ($out/$out/lib instead of $out/lib), so move them to the right
  # place.
  postInstall =
    ''
      mv $out/$out/lib/* $out/lib
      rm -rf $out/nix
    '';

  meta = {
    homepage = http://strigi.sourceforge.net;
    description = "A very fast and efficient crawler to index data on your harddrive";
    license = "LGPL";
    maintainers = with stdenv.lib.maintainers; [ sander urkud ];
    inherit (qt4.meta) platforms;
  };
}


{ lib
, buildPythonPackage
, fetchPypi
, cryptography
, ecdsa
, pytest-cov
, pytestCheckHook
, pythonOlder
}:

buildPythonPackage rec {
  pname = "pyjwt";
  version = "2.1.0";
  disabled = pythonOlder "3.6";

  src = fetchPypi {
    pname = "PyJWT";
    inherit version;
    sha256 = "sha256-+6ROeJi7yhYKKytQH0koJPyDgkhdOm8Rul0MGTfOYTA=";
  };

  propagatedBuildInputs = [
    cryptography
    ecdsa
  ];

  checkInputs = [
    pytest-cov
    pytestCheckHook
  ];

  disabledTests = lib.optionals (lib.versionOlder version "2.0") [
    # ecdsa changed internal behavior, required if one does 1.7.1 overriding
    "ec_verify_should_return_false_if_signature_invalid"
  ];

  pythonImportsCheck = [ "jwt" ];

  meta = with lib; {
    description = "JSON Web Token implementation in Python";
    homepage = "https://github.com/jpadilla/pyjwt";
    license = licenses.mit;
    maintainers = with maintainers; [ prikhi ];
  };
}

Revert "python3Packages.pyjwt: disable failing test for 1.7.1"

{ lib
, buildPythonPackage
, fetchPypi
, cryptography
, ecdsa
, pytest-cov
, pytestCheckHook
, pythonOlder
}:

buildPythonPackage rec {
  pname = "pyjwt";
  version = "2.1.0";
  disabled = pythonOlder "3.6";

  src = fetchPypi {
    pname = "PyJWT";
    inherit version;
    sha256 = "sha256-+6ROeJi7yhYKKytQH0koJPyDgkhdOm8Rul0MGTfOYTA=";
  };

  propagatedBuildInputs = [
    cryptography
    ecdsa
  ];

  checkInputs = [
    pytest-cov
    pytestCheckHook
  ];

  pythonImportsCheck = [ "jwt" ];

  meta = with lib; {
    description = "JSON Web Token implementation in Python";
    homepage = "https://github.com/jpadilla/pyjwt";
    license = licenses.mit;
    maintainers = with maintainers; [ prikhi ];
  };
}


{ stdenv, lib, fetchFromGitHub, wrapPython }:

with lib;

stdenv.mkDerivation rec {
  name = "droopy-${version}";
  version = "20160830";

  src = fetchFromGitHub {
    owner = "stackp";
    repo = "Droopy";
    rev = "7a9c7bc46c4ff8b743755be86a9b29bd1a8ba1d9";
    sha256 = "03i1arwyj9qpfyyvccl21lbpz3rnnp1hsadvc0b23nh1z2ng9sff";
  };

  nativeBuildInputs = [ wrapPython ];

  installPhase = ''
    install -vD droopy $out/bin/droopy
    install -vD -m 644 man/droopy.1 $out/share/man/man1/droopy.1
    wrapPythonPrograms
  '';

  meta = {
    description = "Mini Web server that let others upload files to your computer";
    homepage = http://stackp.online.fr/droopy;
    license = licenses.bsd3;
    maintainers = maintainers.profpatsch;
  };

}

Fix schema, maintainers are usually an array

{ stdenv, lib, fetchFromGitHub, wrapPython }:

with lib;

stdenv.mkDerivation rec {
  name = "droopy-${version}";
  version = "20160830";

  src = fetchFromGitHub {
    owner = "stackp";
    repo = "Droopy";
    rev = "7a9c7bc46c4ff8b743755be86a9b29bd1a8ba1d9";
    sha256 = "03i1arwyj9qpfyyvccl21lbpz3rnnp1hsadvc0b23nh1z2ng9sff";
  };

  nativeBuildInputs = [ wrapPython ];

  installPhase = ''
    install -vD droopy $out/bin/droopy
    install -vD -m 644 man/droopy.1 $out/share/man/man1/droopy.1
    wrapPythonPrograms
  '';

  meta = {
    description = "Mini Web server that let others upload files to your computer";
    homepage = http://stackp.online.fr/droopy;
    license = licenses.bsd3;
    maintainers = [ maintainers.profpatsch ];
  };

}


{ stdenv, fetchurl, autoreconfHook, pkgconfig
, openssl
, odbcSupport ? false, unixODBC ? null }:

assert odbcSupport -> unixODBC != null;

stdenv.mkDerivation rec {
  name = "freetds-${version}";
  version = "1.00.62";

  src = fetchurl {
    url    = "http://www.freetds.org/files/stable/${name}.tar.bz2";
    sha256 = "10d1rjflp3gkmgk5zlv2ck23p0fgpxrgf1jhfv9pvy3q02h9ldis";
  };

  configureFlags = [
    "--with-tdsver=7.0"
  ];

  buildInputs = [
    openssl
  ] ++ stdenv.lib.optional odbcSupport unixODBC;

  nativeBuildInputs = [ autoreconfHook pkgconfig ];

  enableParallelBuilding = true;

  meta = with stdenv.lib; {
    description = "Libraries to natively talk to Microsoft SQL Server and Sybase databases";
    homepage    = http://www.freetds.org;
    license     = licenses.lgpl2;
    maintainers = with maintainers; [ peterhoeg ];
    platforms   = platforms.all;
  };
}

Revert "freetds: 0.91 -> 1.00.62"

{ stdenv, fetchurl
, odbcSupport ? false, unixODBC ? null }:

assert odbcSupport -> unixODBC != null;

stdenv.mkDerivation rec {
  name = "freetds-0.91";

  src = fetchurl {
    url = "http://mirrors.ibiblio.org/freetds/stable/${name}.tar.gz";
    sha256 = "0r946axzxs0czsmr7283w7vmk5jx3jnxxc32d2ncxsrsh2yli0ba";
  };

  hardeningDisable = [ "format" ];

  buildInputs = stdenv.lib.optional odbcSupport [ unixODBC ];

  configureFlags = stdenv.lib.optionalString odbcSupport "--with-odbc=${unixODBC}";

  doDist = true;

  distPhase = ''
    touch $out/include/tds.h
    touch $out/lib/libtds.a
  '';

  meta = {
    description =
      "Libraries to natively talk to Microsoft SQL Server and Sybase databases";
    homepage = http://www.freetds.org;
    license = "lgpl";
    platforms = stdenv.lib.platforms.all;
  };
}


{ stdenv, kernel, perl, libmpc }:

let
  baseBuildFlags = [ "INSTALL_HDR_PATH=$(out)" "headers_install" ];
in stdenv.mkDerivation {
  name = "linux-headers-${kernel.version}";

  inherit (kernel) src patches;

  nativeBuildInputs = [ perl libmpc ];

  buildFlags = [ "ARCH=${stdenv.platform.kernelArch}" ] ++ baseBuildFlags;

  crossAttrs = {
    inherit (kernel.crossDrv) src patches;
    buildFlags = [ "ARCH=${stdenv.cross.platform.kernelArch}" ] ++ baseBuildFlags;
  };

  installPhase = ''
    find $out \( -name ..install.cmd -o -name .install \) -print0 | xargs -0 rm
  '';

  # Headers shouldn't reference anything else
  allowedReferences = [];

  meta.platforms = stdenv.lib.platforms.linux;
}

Revert "kernelHeaders: fix build with libmpc"

{ stdenv, kernel, perl }:

let
  baseBuildFlags = [ "INSTALL_HDR_PATH=$(out)" "headers_install" ];
in stdenv.mkDerivation {
  name = "linux-headers-${kernel.version}";

  inherit (kernel) src patches;

  nativeBuildInputs = [ perl ];

  buildFlags = [ "ARCH=${stdenv.platform.kernelArch}" ] ++ baseBuildFlags;

  crossAttrs = {
    inherit (kernel.crossDrv) src patches;
    buildFlags = [ "ARCH=${stdenv.cross.platform.kernelArch}" ] ++ baseBuildFlags;
  };

  installPhase = ''
    find $out \( -name ..install.cmd -o -name .install \) -print0 | xargs -0 rm
  '';

  # Headers shouldn't reference anything else
  allowedReferences = [];

  meta.platforms = stdenv.lib.platforms.linux;
}