{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "picocom-1.7";

  src = fetchurl {
    url = "http://picocom.googlecode.com/files/${name}.tar.gz";
    sha256 = "17hjq713naq02xar711aw24qqd52p591mj1h5n97cni1ga7irwyh";
  };

  installPhase = ''
    ensureDir $out/bin $out/share/man/man8
    cp picocom $out/bin
    cp picocom.8 $out/share/man/man8
  '';

  meta = {
    description = "Minimal dumb-terminal emulation program";
    homepage = http://code.google.com/p/picocom/;
    license = "GPLv2+";
    platforms = stdenv.lib.platforms.gnu;  # arbitrary choice
  };
}

Add dependency on lrzsz so that we can transfer files

{ stdenv, fetchurl, makeWrapper, lrzsz }:

stdenv.mkDerivation rec {
  name = "picocom-1.7";

  src = fetchurl {
    url = "http://picocom.googlecode.com/files/${name}.tar.gz";
    sha256 = "17hjq713naq02xar711aw24qqd52p591mj1h5n97cni1ga7irwyh";
  };

  buildInputs = [ makeWrapper ];

  installPhase = ''
    ensureDir $out/bin $out/share/man/man8
    cp picocom $out/bin
    cp picocom.8 $out/share/man/man8

    wrapProgram $out/bin/picocom \
      --prefix PATH ":" "${lrzsz}/bin"
  '';

  meta = {
    description = "Minimal dumb-terminal emulation program";
    homepage = http://code.google.com/p/picocom/;
    license = "GPLv2+";
    platforms = stdenv.lib.platforms.gnu;  # arbitrary choice
  };
}


{ fetchurl, stdenv, guile, which, ed }:

stdenv.mkDerivation rec {
  name = "mcron-1.0.6";

  src = fetchurl {
    url = "mirror://gnu/mcron/${name}.tar.gz";
    sha256 = "0yvrfzzdy2m7fbqkr61fw01wd9r2jpnbyabxhcsfivgxywknl0fy";
  };

  patches = [ ./install-vixie-programs.patch ];

  buildInputs = [ guile which ed ];

  doCheck = true;

  meta = {
    description = "Flexible implementation of `cron' in Guile";

    longDescription = ''
      The GNU package mcron (Mellor's cron) is a 100% compatible
      replacement for Vixie cron.  It is written in pure Guile, and
      allows configuration files to be written in scheme (as well as
      Vixie's original format) for infinite flexibility in specifying
      when jobs should be run.  Mcron was written by Dale Mellor.
    '';

    homepage = http://www.gnu.org/software/mcron/;

    license = stdenv.lib.licenses.gpl3Plus;
    platforms = stdenv.lib.platforms.unix;
  };
}

Fix attempt to set +s during install

{ fetchurl, stdenv, guile, which, ed }:

stdenv.mkDerivation rec {
  name = "mcron-1.0.6";

  src = fetchurl {
    url = "mirror://gnu/mcron/${name}.tar.gz";
    sha256 = "0yvrfzzdy2m7fbqkr61fw01wd9r2jpnbyabxhcsfivgxywknl0fy";
  };

  patches = [ ./install-vixie-programs.patch ];

  # don't attempt to chmod +s files in the nix store
  postPatch = ''
    substituteInPlace makefile.in --replace "rwxs" "rwx"
  '';

  buildInputs = [ guile which ed ];

  doCheck = true;

  meta = {
    description = "Flexible implementation of `cron' in Guile";

    longDescription = ''
      The GNU package mcron (Mellor's cron) is a 100% compatible
      replacement for Vixie cron.  It is written in pure Guile, and
      allows configuration files to be written in scheme (as well as
      Vixie's original format) for infinite flexibility in specifying
      when jobs should be run.  Mcron was written by Dale Mellor.
    '';

    homepage = http://www.gnu.org/software/mcron/;

    license = stdenv.lib.licenses.gpl3Plus;
    platforms = stdenv.lib.platforms.unix;
  };
}


{ stdenv, fetchurl, unzip }:

stdenv.mkDerivation {
  name = "mp3gain-1.5.2";
  src = fetchurl {
    url = "http://downloads.sourceforge.net/mp3gain/mp3gain-1_5_2-src.zip";
    sha256 = "1jkgry59m8cnnfq05b9y1h4x4wpy3iq8j68slb9qffwa3ajcgbfv";
  };

  buildInputs = [ unzip ];

  sourceRoot = ".";

  buildFlags = [ "OSTYPE=linux" ];

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

  meta = {
    description = "Lossless mp3 normalizer with statistical analysis";
    homepage = http://mp3gain.sourceforge.net/;
    license = stdenv.lib.licenses.lgpl21;
    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.devhell ];
  };
}

Fix output path bin directory.

{ stdenv, fetchurl, unzip }:

stdenv.mkDerivation {
  name = "mp3gain-1.5.2";
  src = fetchurl {
    url = "http://downloads.sourceforge.net/mp3gain/mp3gain-1_5_2-src.zip";
    sha256 = "1jkgry59m8cnnfq05b9y1h4x4wpy3iq8j68slb9qffwa3ajcgbfv";
  };

  buildInputs = [ unzip ];

  sourceRoot = ".";

  buildFlags = [ "OSTYPE=linux" ];

  installPhase = ''
    install -vD mp3gain "$out/bin/mp3gain"
  '';

  meta = {
    description = "Lossless mp3 normalizer with statistical analysis";
    homepage = http://mp3gain.sourceforge.net/;
    license = stdenv.lib.licenses.lgpl21;
    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.devhell ];
  };
}


{stdenv, fetchurl, libtool, gettext}:

stdenv.mkDerivation {
  name = "attr-2.4.43";

  src = fetchurl {
    # The SGI site throws away old versions, so don't use it.
    url = mirror://gentoo/distfiles/attr_2.4.43-1.tar.gz;
    sha256 = "1gy5zspj8ynxv6q29r24d18cfvq06zirg1pxcdg27bg2ncrv4n6k";
  };

  buildNativeInputs = [gettext];
  buildInputs = [libtool];

  configureFlags = "MAKE=make LIBTOOL=libtool MSGFMT=msgfmt MSGMERGE=msgmerge XGETTEXT=xgettext ECHO=echo SED=sed AWK=gawk";

  installTargets = "install install-lib install-dev";

  meta = {
    homepage = ftp://oss.sgi.com/projects/xfs/cmd_tars/;
    description = "Library and tools for manipulating extended attributes";
  };
}

Upgrade attr, moved to savannah

{stdenv, fetchurl, libtool, gettext}:

stdenv.mkDerivation rec {
  name = "attr-2.4.44";

  src = fetchurl {
    url = "mirror://savannah/attr/${name}.src.tar.gz";
    sha256 = "16244r2vrd57i5fnf7dz3yi2mcckc47jr9y539jvljrzwnw18qlz";
  };

  buildNativeInputs = [gettext];
  buildInputs = [libtool];

  configureFlags = "MAKE=make LIBTOOL=libtool MSGFMT=msgfmt MSGMERGE=msgmerge XGETTEXT=xgettext ECHO=echo SED=sed AWK=gawk";

  installTargets = "install install-lib install-dev";

  meta = {
    homepage = http://savannah.nongnu.org/projects/attr/;
    description = "Library and tools for manipulating extended attributes";
  };
}


{ ... }:

{
  imports = [
    ../user
  ];

  programs.git.userEmail = "John.Ericson@Obsidian.Systems";

  xresources.properties = {
    "*.dpi" = 120;
  };

  # TODO get alacritty to respect the above, and remove this.
  programs.alacritty.settings.font.size = 4.5;
}

Add zoom and telegram to work computer

{ pkgs, ... }:

{
  imports = [
    ../user
  ];

  programs.git.userEmail = "John.Ericson@Obsidian.Systems";

  xresources.properties = {
    "*.dpi" = 120;
  };

  home.packages = with pkgs; [
    zoom-us
    tdesktop
  ];

  # TODO get alacritty to respect the above, and remove this.
  programs.alacritty.settings.font.size = 4.5;
}


{ stdenv, fetchFromGitHub, cmake, perl
, file, glib, gmime, libevent, luajit, openssl, pcre, pkgconfig, sqlite, ragel, icu, libfann }:

let libmagic = file;  # libmagic provided by file package ATM
in

stdenv.mkDerivation rec {
  name = "rspamd-${version}";
  version = "1.7.4";

  src = fetchFromGitHub {
    owner = "vstakhov";
    repo = "rspamd";
    rev = version;
    sha256 = "1iba6mpha1ikybn9qnvgxzh6pjw5yj5aipamd586rfb0j9lbwsd5";
  };

  nativeBuildInputs = [ cmake pkgconfig perl ];
  buildInputs = [ glib gmime libevent libmagic luajit openssl pcre sqlite ragel icu libfann ];

  cmakeFlags = [
    "-DDEBIAN_BUILD=ON"
    "-DRUNDIR=/var/run/rspamd"
    "-DDBDIR=/var/lib/rspamd"
    "-DLOGDIR=/var/log/rspamd"
    "-DLOCAL_CONFDIR=/etc/rspamd"
  ];

  meta = with stdenv.lib; {
    homepage = https://github.com/vstakhov/rspamd;
    license = licenses.asl20;
    description = "Advanced spam filtering system";
    maintainers = with maintainers; [ avnik fpletz ];
    platforms = with platforms; linux;
  };
}

Revert "rspamd: 1.7.3 -> 1.7.4"

{ stdenv, fetchFromGitHub, cmake, perl
, file, glib, gmime, libevent, luajit, openssl, pcre, pkgconfig, sqlite, ragel, icu, libfann }:

let libmagic = file;  # libmagic provided by file package ATM
in

stdenv.mkDerivation rec {
  name = "rspamd-${version}";
  version = "1.7.3";

  src = fetchFromGitHub {
    owner = "vstakhov";
    repo = "rspamd";
    rev = version;
    sha256 = "1gb4zg8i1nj337f65s434h299ad19c0d7jyawb2glvv3n4cshm97";
  };

  nativeBuildInputs = [ cmake pkgconfig perl ];
  buildInputs = [ glib gmime libevent libmagic luajit openssl pcre sqlite ragel icu libfann ];

  cmakeFlags = [
    "-DDEBIAN_BUILD=ON"
    "-DRUNDIR=/var/run/rspamd"
    "-DDBDIR=/var/lib/rspamd"
    "-DLOGDIR=/var/log/rspamd"
    "-DLOCAL_CONFDIR=/etc/rspamd"
  ];

  meta = with stdenv.lib; {
    homepage = https://github.com/vstakhov/rspamd;
    license = licenses.asl20;
    description = "Advanced spam filtering system";
    maintainers = with maintainers; [ avnik fpletz ];
    platforms = with platforms; linux;
  };
}


{ pkgs, config, ... }:

{
  # "Attribute set of files to link into the user home."
  home.file = {
    scripts = {
      recursive = true;
      source = "${config.home.homeDirectory}/dotfiles/scripts";
      target = "${config.home.homeDirectory}/.local/bin/scripts";
    };

    bak = {
      executable = true;
      target = "${config.home.homeDirectory}/.local/bin/bak";
      text = ''
        #!/usr/bin/env bash
        sudo rsync -PAXa --delete-excluded \
            --exclude="${config.xdg.cacheHome}/*" \
            --exclude="${config.xdg.dataHome}/Trash/*" \
            "/home" "/run/media/${config.home.username}/ca3036f2-022d-4b6e-bb03-ed762403fd3b"
      '';
    };

    inputrc = {
      target = "${config.home.homeDirectory}/.inputrc";
      text = ''
        set editing-mode vi
        set show-all-if-ambiguous on
        set show-all-if-unmodified on
        set menu-complete-display-prefix on
        $if mode=vi
          set keymap vi-command
          Control-l: clear-screen
          "k": history-search-backward
          "j": history-search-forward
          set keymap vi-insert
          Control-l: clear-screen
          "jk": vi-movement-mode
          "\t": menu-complete
          "\e[Z": menu-complete-backward
        $endif
      '';
    };
  };
}

Set no-inc-recursive and progress2 for bak

{ pkgs, config, ... }:

{
  # "Attribute set of files to link into the user home."
  home.file = {
    scripts = {
      recursive = true;
      source = "${config.home.homeDirectory}/dotfiles/scripts";
      target = "${config.home.homeDirectory}/.local/bin/scripts";
    };

    bak = {
      executable = true;
      target = "${config.home.homeDirectory}/.local/bin/bak";
      text = ''
        #!/usr/bin/env bash
        sudo rsync -AXa --delete-excluded --no-inc-recursive --info=progress2 \
            --exclude="${config.xdg.cacheHome}/*" \
            --exclude="${config.xdg.dataHome}/Trash/*" \
            "/home" "/run/media/${config.home.username}/ca3036f2-022d-4b6e-bb03-ed762403fd3b"
      '';
    };

    inputrc = {
      target = "${config.home.homeDirectory}/.inputrc";
      text = ''
        set editing-mode vi
        set show-all-if-ambiguous on
        set show-all-if-unmodified on
        set menu-complete-display-prefix on
        $if mode=vi
          set keymap vi-command
          Control-l: clear-screen
          "k": history-search-backward
          "j": history-search-forward
          set keymap vi-insert
          Control-l: clear-screen
          "jk": vi-movement-mode
          "\t": menu-complete
          "\e[Z": menu-complete-backward
        $endif
      '';
    };
  };
}


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

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="--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 { })
)


{ config, lib, pkgs, ... }:

with lib;

{

  config = {

    environment.etc =
      [ { source = "${pkgs.cacert}/etc/ca-bundle.crt";
          target = "ssl/certs/ca-bundle.crt";
        }
      ];

    environment.sessionVariables =
      { SSL_CERT_FILE          = "/etc/ssl/certs/ca-bundle.crt";
        # FIXME: unneeded - remove eventually.
        OPENSSL_X509_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt";
        GIT_SSL_CAINFO         = "/etc/ssl/certs/ca-bundle.crt";
      };

  };

}

Remove unnecessary $GIT_SSL_CAINFO from sys env

{ config, lib, pkgs, ... }:

with lib;

{

  config = {

    environment.etc =
      [ { source = "${pkgs.cacert}/etc/ca-bundle.crt";
          target = "ssl/certs/ca-bundle.crt";
        }
      ];

    environment.sessionVariables =
      { SSL_CERT_FILE          = "/etc/ssl/certs/ca-bundle.crt";
        # FIXME: unneeded - remove eventually.
        OPENSSL_X509_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt";
      };

  };

}


{ stdenv, fetchurl, pkgconfig, gtk, libglade, libgnomecanvas, fribidi
, libpng, popt, libgsf, enchant, wv, librsvg, bzip2, libjpeg
}:

stdenv.mkDerivation {
  name = "abiword-2.8.6";

  src = fetchurl {
    url = http://www.abisource.org/downloads/abiword/2.8.6/source/abiword-2.8.6.tar.gz;
    sha256 = "059sd2apxdmcacc4pll880i7vm18h0kyjsq299m1mz3c7ak8k46r";
  };

  buildInputs =
    [ pkgconfig gtk libglade librsvg bzip2 libgnomecanvas fribidi libpng popt
      libgsf enchant wv libjpeg
    ];
}

Fix glib/gdx_pixbuf related build errors.

{ stdenv, fetchurl, pkgconfig, gtk, libglade, libgnomecanvas, fribidi
, libpng, popt, libgsf, enchant, wv, librsvg, bzip2, libjpeg
}:

stdenv.mkDerivation {
  name = "abiword-2.8.6";

  src = fetchurl {
    url = http://www.abisource.org/downloads/abiword/2.8.6/source/abiword-2.8.6.tar.gz;
    sha256 = "059sd2apxdmcacc4pll880i7vm18h0kyjsq299m1mz3c7ak8k46r";
  };

  prePatch = ''
    sed -i -e '/#include <glib\/gerror.h>/d' src/af/util/xp/ut_go_file.h
    sed -i -e 's|#include <glib/gmacros.h>|#include <glib.h>|' \
      goffice-bits/goffice/app/goffice-app.h
    sed -i -e 's/ptr->jmpbuf/jmpbuf(png_ptr)/' src/af/util/xp/ut_png.cpp
    sed -i -e 's/\(m_pPNG\)->\(jmpbuf\)/png_\2(\1)/' \
      src/wp/impexp/gtk/ie_impGraphic_GdkPixbuf.cpp
    sed -i -e 's/--no-undefined //' src/Makefile*
  '';

  buildInputs =
    [ pkgconfig gtk libglade librsvg bzip2 libgnomecanvas fribidi libpng popt
      libgsf enchant wv libjpeg
    ];
}


{ stdenv, fetchFromGitHub, autoconf, automake, libtool, zlib, gtest }:

stdenv.mkDerivation rec {
  name = "protobuf-${version}";
  version = "2.6.1";

  src = fetchFromGitHub {
    owner = "google";
    repo = "protobuf";
    rev = version;
    sha256 = "03df8zvx2sry3jz2x4pi3l32qyfqa7w8kj8jdbz30nzy0h7aa070";
  };

  postPatch = ''
    sed -i -e '/gtest/d' Makefile.am
    sed -i \
      -e 's!\$(top_\(build\|src\)dir)/gtest!${gtest}!g' \
      -e 's/\(libgtest[^.]*\.\)la/\1a/g' \
      src/Makefile.am
  '';

  buildInputs = [ zlib autoconf automake libtool gtest ];

  preConfigure = "autoreconf -vfi";

  doCheck = true;

  meta = {
    description = "Protocol Buffers - Google's data interchange format";

    longDescription = ''
      Protocol Buffers are a way of encoding structured data in an
      efficient yet extensible format. Google uses Protocol Buffers for
      almost all of its internal RPC protocols and file formats.
    '';

    license = stdenv.lib.licenses.bsd3;

    homepage = "https://developers.google.com/protocol-buffers/";
  };
}

Revert "protobuf: Clean up and update to version 2.6.1."

{ fetchurl, stdenv, zlib }:

stdenv.mkDerivation rec {
  name = "protobuf-2.5.0";

  src = fetchurl {
    url = "http://protobuf.googlecode.com/files/${name}.tar.bz2";
    sha256 = "0xxn9gxhvsgzz2sgmihzf6pf75clr05mqj6218camwrwajpcbgqk";
  };

  buildInputs = [ zlib ];

  doCheck = true;

  meta = {
    description = "Protocol Buffers - Google's data interchange format";

    longDescription =
      '' Protocol Buffers are a way of encoding structured data in an
         efficient yet extensible format.  Google uses Protocol Buffers for
         almost all of its internal RPC protocols and file formats.
      '';

    license = "mBSD";

    homepage = http://code.google.com/p/protobuf/;
  };
}


{ pkgs, ... }:

{
  programs.fish.enable = true;
  programs.fish.package = pkgs.fish.overrideAttrs (old: {
    patches = old.patches or [] ++ [
      # https://github.com/fish-shell/fish-shell/pull/5637 is merged but not
      # yet released. Need this for sane behavior on macOS.
      (pkgs.fetchpatch {
        url = "https://patch-diff.githubusercontent.com/raw/fish-shell/fish-shell/pull/5637.diff";
        sha256 = "020f18pglsdh3ah28qyvni0986spv2gbha67gbcirzr2xspsfc45";
        excludes = [ "CHANGELOG.md" ];
      })
    ];
  });
  programs.fish.promptInit = builtins.readFile ./fish_prompt.fish;
  xdg.configFile."fish/functions".source = ./functions;
}

Remove no longer needed fish patch

{ pkgs, ... }:

{
  programs.fish.enable = true;
  programs.fish.promptInit = builtins.readFile ./fish_prompt.fish;
  xdg.configFile."fish/functions".source = ./functions;
}


{ pkgs ? import <nixpkgs> { }, ruby ? 2.7 }:

with pkgs;
let
  mri =
    if ruby == 2.5
    then ruby_2_5
    else if ruby == 2.6
    then ruby_2_6
    else if ruby == 2.7
    then ruby_2_7
    else abort "Unsupported Ruby version";
  gems = bundlerEnv {
    pname = "twterm";
    gemdir = ./.;
    ruby = mri;
  };
in
mkShell rec {
  buildInputs = [
    bundix
    bundler
    gems
    libidn
    mri
    ncurses
    readline
  ];
  shellHook = ''
    alias twterm='bundle exec bin/twterm'

    bundle install -j=4 --path=vendor/bundle

    ruby --version
    bundle --version
  '';
}

Add libffi to build inputs

{ pkgs ? import <nixpkgs> { }, ruby ? 2.7 }:

with pkgs;
let
  mri =
    if ruby == 2.5
    then ruby_2_5
    else if ruby == 2.6
    then ruby_2_6
    else if ruby == 2.7
    then ruby_2_7
    else abort "Unsupported Ruby version";
  gems = bundlerEnv {
    pname = "twterm";
    gemdir = ./.;
    ruby = mri;
  };
in
mkShell rec {
  buildInputs = [
    bundix
    bundler
    gems
    libffi
    libidn
    mri
    ncurses
    readline
  ];
  shellHook = ''
    alias twterm='bundle exec bin/twterm'

    bundle install -j=4 --path=vendor/bundle

    ruby --version
    bundle --version
  '';
}


{ stdenv, fetchsvn, autoconf, automake, libsndfile, libtool, pkgconfig }:

stdenv.mkDerivation rec {
  name = "libgig-svn-${version}";
  version = "2334";

  src = fetchsvn {
    url = "https://svn.linuxsampler.org/svn/libgig/trunk";
    rev = "${version}";
    sha256 = "0i7sj3zm6banl5avjdxblx0mlbxxzbsbr4x5hsl2fhrdsv5dnxhc";
  };

  buildInputs = [ autoconf automake libsndfile libtool pkgconfig ];

  preConfigure = "make -f Makefile.cvs";

  meta = with stdenv.lib; {
    homepage = http://www.linuxsampler.org;
    description = "Gigasampler file access library";
    license = licenses.gpl2;
    maintainers = [ maintainers.goibhniu ];
    platforms = platforms.linux;
  };
}

Configure script warns about missing libuuid

{ stdenv, fetchsvn, autoconf, automake, libsndfile, libtool, pkgconfig, libuuid }:

stdenv.mkDerivation rec {
  name = "libgig-svn-${version}";
  version = "2334";

  src = fetchsvn {
    url = "https://svn.linuxsampler.org/svn/libgig/trunk";
    rev = "${version}";
    sha256 = "0i7sj3zm6banl5avjdxblx0mlbxxzbsbr4x5hsl2fhrdsv5dnxhc";
  };

  buildInputs = [ autoconf automake libsndfile libtool pkgconfig libuuid ];

  preConfigure = "make -f Makefile.cvs";

  meta = with stdenv.lib; {
    homepage = http://www.linuxsampler.org;
    description = "Gigasampler file access library";
    license = licenses.gpl2;
    maintainers = [ maintainers.goibhniu ];
    platforms = platforms.linux;
  };
}


{ stdenv, fetchurl, xorg, pkgconfig
, gtkSupport ? true, gtk
, qtSupport ? true, qt4
}:

stdenv.mkDerivation rec {
  version = "0.31";
  name = "xautoclick-${version}";
  src = fetchurl {
    url = "http://downloads.sourceforge.net/project/xautoclick/xautoclick/xautoclick-0.31/xautoclick-0.31.tar.gz";
    sha256 = "0h522f12a7v2b89411xm51iwixmjp2mp90rnizjgiakx9ajnmqnm";
  };
  buildInputs = [ xorg.libX11 xorg.libXtst xorg.xinput xorg.libXi xorg.libXext pkgconfig ]
    ++ stdenv.lib.optionals gtkSupport [ gtk ]
    ++ stdenv.lib.optionals qtSupport [ qt4 ];
  patchPhase = ''
    substituteInPlace configure --replace /usr/X11R6 ${xorg.libX11}
  '';
  preConfigure = stdenv.lib.optional qtSupport ''
    mkdir .bin
    ln -s ${qt4}/bin/moc .bin/moc-qt4
    addToSearchPath PATH .bin
  '';
}

Make explicit that 'dev' output of xorg.libX11 is used

{ stdenv, fetchurl, xorg, pkgconfig
, gtkSupport ? true, gtk
, qtSupport ? true, qt4
}:

stdenv.mkDerivation rec {
  version = "0.31";
  name = "xautoclick-${version}";
  src = fetchurl {
    url = "http://downloads.sourceforge.net/project/xautoclick/xautoclick/xautoclick-0.31/xautoclick-0.31.tar.gz";
    sha256 = "0h522f12a7v2b89411xm51iwixmjp2mp90rnizjgiakx9ajnmqnm";
  };
  buildInputs = [ xorg.libX11 xorg.libXtst xorg.xinput xorg.libXi xorg.libXext pkgconfig ]
    ++ stdenv.lib.optionals gtkSupport [ gtk ]
    ++ stdenv.lib.optionals qtSupport [ qt4 ];
  patchPhase = ''
    substituteInPlace configure --replace /usr/X11R6 ${xorg.libX11.dev}
  '';
  preConfigure = stdenv.lib.optional qtSupport ''
    mkdir .bin
    ln -s ${qt4}/bin/moc .bin/moc-qt4
    addToSearchPath PATH .bin
  '';
}


{ stdenv, fetchurl, cmake, mesa, libXrandr, libXi, libXxf86vm, libXfixes, x11 }:

stdenv.mkDerivation rec {
  name = "glfw-3.0.4";

  src = fetchurl {
    url = "mirror://sourceforge/glfw/${name}.tar.bz2";
    sha256 = "1h7g16ncgkl38w19x4dvnn17k9j0kqfvbb9whw9qc71lkq5xf2ag";
  };

  enableParallelBuilding = true;

  buildInputs = [ cmake mesa libXrandr libXi libXxf86vm libXfixes x11 ];

  meta = with stdenv.lib; {
    description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time";
    homepage = "http://glfw.sourceforge.net/";
    license = licenses.zlib;
    maintainers = with maintainers; [ marcweber ];
    platforms = platforms.linux;
  };
}

Update to 3.1.1 and build shared library.

{ stdenv, fetchurl, cmake, mesa, libXrandr, libXi, libXxf86vm, libXfixes, x11
, libXinerama, libXcursor
}:

stdenv.mkDerivation rec {
  name = "glfw-3.1.1";

  src = fetchurl {
    url = "mirror://sourceforge/glfw/${name}.tar.bz2";
    sha256 = "0q9dhbj2az7jwwi556zai0qr8zmg6d2lyxcqngppkw0x7hi1d1aa";
  };

  enableParallelBuilding = true;

  buildInputs = [
    cmake mesa libXrandr libXi libXxf86vm libXfixes x11
    libXinerama libXcursor
  ];

  cmakeFlags = "-DBUILD_SHARED_LIBS=ON";

  meta = with stdenv.lib; {
    description = "Multi-platform library for creating OpenGL contexts and managing input, including keyboard, mouse, joystick and time";
    homepage = "http://glfw.sourceforge.net/";
    license = licenses.zlib;
    maintainers = with maintainers; [ marcweber ];
    platforms = platforms.linux;
  };
}


{ stdenv, fetchurl
, checksumType ? "built-in"
, libmhash ? null
, openssl ? null
}:

assert checksumType == "mhash" -> libmhash != null;
assert checksumType == "openssl" -> openssl != null;

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

  configureFlags = [
    "--with-checksum=${checksumType}"
  ];

  buildInputs = stdenv.lib.optional (checksumType == "mhash") libmhash
             ++ stdenv.lib.optional (checksumType == "openssl") openssl;

  src = fetchurl {
    urls = [
      "http://mamuti.net/files/netrw/netrw-${version}.tar.bz2"
      "http://www.sourcefiles.org/Networking/FTP/Other/netrw-${version}.tar.bz2"
    ];
    sha256 = "1gnl80i5zkyj2lpnb4g0q0r5npba1x6cnafl2jb3i3pzlfz1bndr";
  };

  meta = {
    description = "A simple tool for transporting data over the network.";
    homepage = "http://mamuti.net/netrw/index.en.html";
  };
}

Add missing license to meta attributes.

{ stdenv, fetchurl
, checksumType ? "built-in"
, libmhash ? null
, openssl ? null
}:

assert checksumType == "mhash" -> libmhash != null;
assert checksumType == "openssl" -> openssl != null;

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

  configureFlags = [
    "--with-checksum=${checksumType}"
  ];

  buildInputs = stdenv.lib.optional (checksumType == "mhash") libmhash
             ++ stdenv.lib.optional (checksumType == "openssl") openssl;

  src = fetchurl {
    urls = [
      "http://mamuti.net/files/netrw/netrw-${version}.tar.bz2"
      "http://www.sourcefiles.org/Networking/FTP/Other/netrw-${version}.tar.bz2"
    ];
    sha256 = "1gnl80i5zkyj2lpnb4g0q0r5npba1x6cnafl2jb3i3pzlfz1bndr";
  };

  meta = {
    description = "A simple tool for transporting data over the network.";
    license = stdenv.lib.licenses.gpl2;
    homepage = "http://mamuti.net/netrw/index.en.html";
  };
}


{ stdenv, fetchurl, pkgconfig, udev }:

stdenv.mkDerivation rec {
  name = "libusb-1.0.16";

  src = fetchurl {
    url = "mirror://sourceforge/libusbx/libusbx-1.0.16.tar.bz2";
    sha256 = "105m9jvjr3vrriyg0mwmyf7qla4l71iwwnymrsk3sy9dazwmqcsv";
  };

  buildInputs = [ pkgconfig ];
  propagatedBuildInputs = stdenv.lib.optional (stdenv.isLinux) udev;

  meta = {
    homepage = http://www.libusb.org;
    description = "User-space USB library";
    platforms = stdenv.lib.platforms.unix;
    maintainers = [ stdenv.lib.maintainers.urkud ];
  };
}

Fix "libgcc_s.so.1 must be installed for pthread_cancel to work" error

{ stdenv, fetchurl, pkgconfig, udev }:

stdenv.mkDerivation rec {
  name = "libusb-1.0.16";

  src = fetchurl {
    url = "mirror://sourceforge/libusbx/libusbx-1.0.16.tar.bz2";
    sha256 = "105m9jvjr3vrriyg0mwmyf7qla4l71iwwnymrsk3sy9dazwmqcsv";
  };

  buildInputs = [ pkgconfig ];
  propagatedBuildInputs = stdenv.lib.optional (stdenv.isLinux) udev;

  NIX_LDFLAGS = "-lgcc_s";

  meta = {
    homepage = http://www.libusb.org;
    description = "User-space USB library";
    platforms = stdenv.lib.platforms.unix;
    maintainers = [ stdenv.lib.maintainers.urkud ];
  };
}


{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, udev, libusb1
, darwin
, gnum4
}:

stdenv.mkDerivation rec {
  pname = "hidapi";
  version = "0.10.1";

  src = fetchFromGitHub {
    owner = "libusb";
    repo = "hidapi";
    rev = "${pname}-${version}";
    sha256 = "1nr4z4b10vpbh3ss525r7spz4i43zim2ba5qzfl15dgdxshxxivb";
  };

  nativeBuildInputs = [
    autoreconfHook
    pkgconfig
  ] ++ stdenv.lib.optionals (stdenv.hostPlatform != stdenv.buildPlatform) [
    # Could be added always, but added conditionally here to avoid large rebuild
    gnum4
  ];

  buildInputs = [ ]
    ++ stdenv.lib.optionals stdenv.isLinux [ libusb1 udev ];

  enableParallelBuilding = true;

  propagatedBuildInputs = stdenv.lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ IOKit Cocoa ]);

  meta = with stdenv.lib; {
    description = "Library for communicating with USB and Bluetooth HID devices";
    homepage = "https://github.com/libusb/hidapi";
    maintainers = with maintainers; [ prusnak ];
    # Actually, you can chose between GPLv3, BSD or HIDAPI license (more liberal)
    license = licenses.bsd3;
    platforms = platforms.unix;
  };
}

Revert "hidapi: fix cross build"

{ stdenv, fetchFromGitHub, autoreconfHook, pkgconfig, udev, libusb1
, darwin }:

stdenv.mkDerivation rec {
  pname = "hidapi";
  version = "0.10.1";

  src = fetchFromGitHub {
    owner = "libusb";
    repo = "hidapi";
    rev = "${pname}-${version}";
    sha256 = "1nr4z4b10vpbh3ss525r7spz4i43zim2ba5qzfl15dgdxshxxivb";
  };

  nativeBuildInputs = [ autoreconfHook pkgconfig ];

  buildInputs = [ ]
    ++ stdenv.lib.optionals stdenv.isLinux [ libusb1 udev ];

  enableParallelBuilding = true;

  propagatedBuildInputs = stdenv.lib.optionals stdenv.isDarwin (with darwin.apple_sdk.frameworks; [ IOKit Cocoa ]);

  meta = with stdenv.lib; {
    description = "Library for communicating with USB and Bluetooth HID devices";
    homepage = "https://github.com/libusb/hidapi";
    maintainers = with maintainers; [ prusnak ];
    # Actually, you can chose between GPLv3, BSD or HIDAPI license (more liberal)
    license = licenses.bsd3;
    platforms = platforms.unix;
  };
}


{ pkgs ? import ../nix/nixpkgs.nix, compiler ? null
, forShell ? pkgs.lib.inNixShell, hoogle ? forShell }:

let
  haskellPackages = let
    hp = if compiler == null then
      pkgs.haskellPackages
    else
      pkgs.haskell.packages.${compiler};
  in hp.override {
    overrides = import ../nix/haskell-packages.nix { inherit pkgs hoogle; };
  };

in if forShell then
  haskellPackages.shellFor {
    packages = p: [ p.vulkan-examples ];
    buildInputs = with pkgs; [ vulkan-validation-layers ];
    withHoogle = hoogle;
  }
else
  haskellPackages.vulkan-examples

Add swiftshader option to examples shell

{ pkgs ? import ../nix/nixpkgs.nix, compiler ? null
, forShell ? pkgs.lib.inNixShell, hoogle ? forShell, withSwiftshader ? false }:

let
  haskellPackages = let
    hp = if compiler == null then
      pkgs.haskellPackages
    else
      pkgs.haskell.packages.${compiler};
  in hp.override {
    overrides = import ../nix/haskell-packages.nix { inherit pkgs hoogle; };
  };

in if forShell then
  haskellPackages.shellFor ({
    packages = p: [ p.vulkan-examples ];
    buildInputs = with pkgs; [ vulkan-validation-layers ];
    withHoogle = hoogle;
  } // pkgs.lib.optionalAttrs withSwiftshader {
    VK_ICD_FILENAMES =
      "${pkgs.swiftshader}/share/vulkan/icd.d/vk_swiftshader_icd.json";
  })
else
  haskellPackages.vulkan-examples


{stdenv, fetchurl, libevent, openssl, zlib}:

stdenv.mkDerivation {
  name = "tor-0.2.1.26";

  src = fetchurl {
    url = "http://www.torproject.org/dist/tor-0.2.1.26.tar.gz";
    sha256 = "18kz1hs6lvckkddy4y36gi7ly03ar2il2xzkrf8bfgif1gnn1p3c";
  };

  patchPhase =
    # DNS lookups fail in chroots.
    '' sed -i "src/or/test.c" -es/localhost/127.0.0.1/g
    '';

  buildInputs = [libevent openssl zlib];

  doCheck = true;

  meta = {
    homepage = http://www.torproject.org/;
    description = "Tor is an onion router enabling Internet anonymity by thwarting network traffic analysis";
    longDescription=''
     Tor protects you by bouncing your communications around a distributed
     network of relays run by volunteers all around the world: it prevents
     somebody watching your Internet connection from learning what sites you
     visit, and it prevents the sites you visit from learning your physical
     location. Tor works with many of your existing applications, including
     web browsers, instant messaging clients, remote login, and other
     applications based on the TCP protocol.
    '';
    license="bsd";
  };

}

Add self as co-maintainer; add to Hydra; improve formatting.

{ stdenv, fetchurl, libevent, openssl, zlib }:

stdenv.mkDerivation rec {
  name = "tor-0.2.1.26";

  src = fetchurl {
    url = "http://www.torproject.org/dist/${name}.tar.gz";
    sha256 = "18kz1hs6lvckkddy4y36gi7ly03ar2il2xzkrf8bfgif1gnn1p3c";
  };

  patchPhase =
    # DNS lookups fail in chroots.
    '' sed -i "src/or/test.c" -es/localhost/127.0.0.1/g
    '';

  buildInputs = [ libevent openssl zlib ];

  doCheck = true;

  meta = {
    homepage = http://www.torproject.org/;
    description = "Tor, an anonymous network router to improve privacy on the Internet";

    longDescription=''
      Tor protects you by bouncing your communications around a distributed
      network of relays run by volunteers all around the world: it prevents
      somebody watching your Internet connection from learning what sites you
      visit, and it prevents the sites you visit from learning your physical
      location. Tor works with many of your existing applications, including
      web browsers, instant messaging clients, remote login, and other
      applications based on the TCP protocol.
    '';

    license="mBSD";

    maintainers =
      [ # Russell O’Connor <roconnor@theorem.ca> ?
	stdenv.lib.maintainers.ludo
      ];
    platforms = stdenv.lib.platforms.gnu;  # arbitrary choice
  };
}


{ stdenv, fetchFromGitHub, go }:

stdenv.mkDerivation rec {
  name = "cni-${version}";
  version = "0.6.0";

  src = fetchFromGitHub {
    owner = "containernetworking";
    repo = "cni";
    rev = "v${version}";
    sha256 = "00ajs2r5r2z3l0vqwxrcwhjfc9px12qbcv5vnvs2mdipvvls1y2y";
  };

  buildInputs = [ go ];

  buildPhase = ''
    patchShebangs build.sh
    ./build.sh
  '';

  installPhase = ''
    mkdir -p $out/bin
    mv bin/cnitool $out/bin
  '';

  meta = with stdenv.lib; {
    description = "Container Network Interface - networking for Linux containers";
    license = licenses.asl20;
    homepage = https://github.com/containernetworking/cni;
    maintainers = with maintainers; [offline];
    platforms = [ "x86_64-linux" ];
  };
}

Remove go from runtime closure

{ stdenv, fetchFromGitHub, go, removeReferencesTo }:

stdenv.mkDerivation rec {
  name = "cni-${version}";
  version = "0.6.0";

  src = fetchFromGitHub {
    owner = "containernetworking";
    repo = "cni";
    rev = "v${version}";
    sha256 = "00ajs2r5r2z3l0vqwxrcwhjfc9px12qbcv5vnvs2mdipvvls1y2y";
  };

  buildInputs = [ removeReferencesTo go ];

  GOCACHE = "off";

  buildPhase = ''
    patchShebangs build.sh
    ./build.sh
  '';

  installPhase = ''
    mkdir -p $out/bin
    mv bin/cnitool $out/bin
  '';

  preFixup = ''
    find $out/bin -type f -exec remove-references-to -t ${go} '{}' +
  '';

  meta = with stdenv.lib; {
    description = "Container Network Interface - networking for Linux containers";
    license = licenses.asl20;
    homepage = https://github.com/containernetworking/cni;
    maintainers = with maintainers; [offline];
    platforms = [ "x86_64-linux" ];
  };
}


{ config, pkgs, ... }:

with pkgs.lib;

{
  options = {
    gnu = mkOption {
      default = false;
      description =
        '' When enable, GNU software is chosent by default whenever a there is
           a choice between GNU and non-GNU software (e.g., GNU lsh
           vs. OpenSSH).
        '';
    };
  };

  config = mkIf config.gnu {

    environment.systemPackages = with pkgs;
      # TODO: Adjust `requiredPackages' from `system-path.nix'.
      # TODO: Add Inetutils once it has the new `ifconfig'.
      [ grub2 parted fdisk
        nano zile
        texinfo # for the stand-alone Info reader
      ];

    # GNU GRUB.
    boot.loader.grub.enable = true;
    boot.loader.grub.version = 2;

    # GNU lsh.
    services.openssh.enable = false;
    services.lshd.enable = true;
    services.xserver.startOpenSSHAgent = false;
    services.xserver.startGnuPGAgent = true;

    # TODO: GNU dico.
    # TODO: GNU Inetutils' inetd.
    # TODO: GNU Pies.
  };
}

Disable GRUB by default on ARM.

{ config, pkgs, ... }:

with pkgs.lib;

{
  options = {
    gnu = mkOption {
      default = false;
      description =
        '' When enable, GNU software is chosent by default whenever a there is
           a choice between GNU and non-GNU software (e.g., GNU lsh
           vs. OpenSSH).
        '';
    };
  };

  config = mkIf config.gnu {

    environment.systemPackages = with pkgs;
      # TODO: Adjust `requiredPackages' from `system-path.nix'.
      # TODO: Add Inetutils once it has the new `ifconfig'.
      [ parted fdisk
        nano zile
        texinfo # for the stand-alone Info reader
      ]
      ++ stdenv.lib.optional !stdenv.isArm grub2;

    # GNU GRUB, where available.
    boot.loader.grub.enable = !stdenv.isArm;
    boot.loader.grub.version = 2;

    # GNU lsh.
    services.openssh.enable = false;
    services.lshd.enable = true;
    services.xserver.startOpenSSHAgent = false;
    services.xserver.startGnuPGAgent = true;

    # TODO: GNU dico.
    # TODO: GNU Inetutils' inetd.
    # TODO: GNU Pies.
  };
}


{stdenv, fetchurl, readline}:
stdenv.mkDerivation {
  name = "lftp-3.5.14";

  src = fetchurl {
    url = ftp://ftp.cs.tu-berlin.de/pub/net/ftp/lftp/lftp-3.5.14.tar.bz2;
    sha256 = "0hzrbhpgvndpd4wd08whfv1iqzbcijs1nxz40rhn651xabhiasrv";
  };

  buildInputs = [readline];
}

Advance lftp to current release version 4.1.3

{stdenv, fetchurl, gnutls, libtasn1, pkgconfig, readline, zlib}:
stdenv.mkDerivation {
  name = "lftp-4.1.3";

  src = fetchurl {
    url = ftp://ftp.cs.tu-berlin.de/pub/net/ftp/lftp/lftp-4.1.3.tar.bz2;
    sha256 = "1nbgbql8kkhdvai0glwgkq8l9ik09l5lb8znpjrv26hfzl15dvv1";
  };

  buildInputs = [gnutls libtasn1 pkgconfig readline zlib];
}


{ lib
, buildGoModule
, fetchFromGitHub
, pkgconfig
, gobject-introspection
, pango
, cairo
, gtk2
}:

buildGoModule rec {
  pname = "hasmail";
  version = "2019-08-24";
  name = "${pname}-${version}-unstable";

  src = fetchFromGitHub {
    owner = "jonhoo";
    repo = "hasmail";
    rev = "eb52536d26815383bfe5990cd5ace8bb9d036c8d";
    sha256 = "1p6kwa5xk1mb1fkkxz1b5rcyp5kb4zc8nfif1gk6fab6wbdj9ia1";
  };

  modSha256 = "0z3asz7v1izg81f9xifx9s2sp5hly173hajsn9idi3bkv0h78is2";

  buildInputs = [
    pkgconfig
    gobject-introspection
    pango
    cairo
    gtk2
  ];

  meta = with lib; {
    description = "Simple tray icon for detecting new email on IMAP servers";
    homepage = "https://github.com/jonhoo/hasmail";
    license = licenses.unlicense;
    maintainers = with maintainers; [ doronbehar ];
    platforms = platforms.all;
  };
}

Use only pname instead of name attr

{ lib
, buildGoModule
, fetchFromGitHub
, pkgconfig
, gobject-introspection
, pango
, cairo
, gtk2
}:

buildGoModule rec {
  pname = "hasmail-unstable";
  version = "2019-08-24";

  src = fetchFromGitHub {
    owner = "jonhoo";
    repo = "hasmail";
    rev = "eb52536d26815383bfe5990cd5ace8bb9d036c8d";
    sha256 = "1p6kwa5xk1mb1fkkxz1b5rcyp5kb4zc8nfif1gk6fab6wbdj9ia1";
  };

  modSha256 = "0z3asz7v1izg81f9xifx9s2sp5hly173hajsn9idi3bkv0h78is2";

  buildInputs = [
    pkgconfig
    gobject-introspection
    pango
    cairo
    gtk2
  ];

  meta = with lib; {
    description = "Simple tray icon for detecting new email on IMAP servers";
    homepage = "https://github.com/jonhoo/hasmail";
    license = licenses.unlicense;
    maintainers = with maintainers; [ doronbehar ];
    platforms = platforms.all;
  };
}


{ lib }:

self: super: {
  haskell = super.haskell // {
    compiler = super.haskell.compiler // lib.mapAttrs (n: v: v.overrideAttrs (drv: {
      patches = (drv.patches or []) ++ lib.optionals self.stdenv.targetPlatform.useAndroidPrebuilt [
        ./8.6.y/android-patches/force-relocation.patch
      ];
    })) { inherit (super.haskell.compiler) ghc865 ghcSplices; };
  };
  libffi = if self.stdenv.targetPlatform.useAndroidPrebuilt
    then
      # Use libffi-3.3-rc0 because the regular libffi is not compatible with android-ndk.
      # Google has its own forked libffi (https://android.googlesource.com/platform/external/libffi/)
      # but upstream also has a release candidate that fixes the same issues. We're using upstream here:
      super.libffi.overrideAttrs (drv: {
        name = "libffi-3.3-rc0";
        patches = [];
        src = builtins.fetchurl {
          url = "https://github.com/libffi/libffi/releases/download/v3.3-rc0/libffi-3.3-rc0.tar.gz";
          sha256 = "1kqfyar1xaxrylrw7j1nclqvcgr6a2cisazaamw1a18wpym6fga0";
        };
        # The new version of libffi doesn't require the same post-fixup hacks that 3.2.1 required. Also,
        # the postFixup script in nixpkgs-channel 19.03 hardcoded some paths to include "3.2.1" specifically,
        # which is no longer valid.
        postFixup = "";
      })
    else
      super.libffi;
}

Use vendored libffi on android

{ lib }:

let # Setting libffi to null causes GHC to use its own vendored libffi, which seems to be
    # necessary on android. See discussion here:
    # https://github.com/reflex-frp/reflex-platform/pull/506#issuecomment-511978967
    overrideLibffiOnAndroid = self: v: if self.stdenv.targetPlatform.useAndroidPrebuilt
      then v.override { libffi = null; }
      else v;
in self: super: {
  haskell = super.haskell // {
    compiler = super.haskell.compiler // lib.mapAttrs (n: v: (overrideLibffiOnAndroid self v).overrideAttrs (drv: {
      patches = (drv.patches or []) ++ lib.optionals self.stdenv.targetPlatform.useAndroidPrebuilt [
        ./8.6.y/android-patches/force-relocation.patch
      ];
    })) { inherit (super.haskell.compiler) ghc865 ghcSplices; };
  };
}


{stdenv, fetchurl, pkgconfig, libusb, readline, lua, libewf, perl,
gtk ? null, vte ? null, gtkdialog ? null,
python ? null,
ruby ? null,
useX11, rubyBindings, pythonBindings, luaBindings}:

assert useX11 -> (gtk != null && vte != null && gtkdialog != null);
assert rubyBindings -> ruby != null;
assert pythonBindings -> python != null;

let
  optional = stdenv.lib.optional;
in
stdenv.mkDerivation rec {
  name = "radare-1.5";

  src = fetchurl {
    url = "http://radare.org/get/${name}.tar.gz";
    sha256 = "1r0c9cc7z9likma8zicp2pbv2y85vjjmnk0k45wdhbvhgqh6il1h";
  };

  buildInputs = [pkgconfig readline libusb libewf perl]
    ++ optional useX11 [gtkdialog vte gtk]
    ++ optional rubyBindings [ruby]
    ++ optional pythonBindings [python]
    ++ optional luaBindings [lua];

  meta = {
    description = "Free advanced command line hexadecimal editor";
    homepage = http://radare.org/;
    license = stdenv.lib.licenses.gpl2Plus;
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; all;
  };
}

Fix radre for now by not using libewf and update it to latest

{stdenv, fetchurl, pkgconfig, libusb, readline, lua, libewf, perl,
gtk ? null, vte ? null, gtkdialog ? null,
python ? null,
ruby ? null,
useX11, rubyBindings, pythonBindings, luaBindings}:

assert useX11 -> (gtk != null && vte != null && gtkdialog != null);
assert rubyBindings -> ruby != null;
assert pythonBindings -> python != null;

let
  optional = stdenv.lib.optional;
in
stdenv.mkDerivation rec {
  name = "radare-1.5.2";

  src = fetchurl {
    url = "http://radare.org/get/${name}.tar.gz";
    sha256 = "1qdrmcnzfvfvqb27c7pknwm8jl2hqa6c4l66wzyddwlb8yjm46hd";
  };

  buildInputs = [pkgconfig readline libusb perl]
    ++ optional useX11 [gtkdialog vte gtk]
    ++ optional rubyBindings [ruby]
    ++ optional pythonBindings [python]
    ++ optional luaBindings [lua];

  meta = {
    description = "Free advanced command line hexadecimal editor";
    homepage = http://radare.org/;
    license = stdenv.lib.licenses.gpl2Plus;
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; all;
  };
}


{stdenv, fetchurl, ocaml, findlib}:

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

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

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

  buildInputs = [ocaml findlib];

  dontAddPrefix = true;

  doCheck = true;

  checkTarget = "test";

  createFindlibDestdir = true;

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

Update OCaml OUnit to version 2.0.0

{stdenv, fetchurl, ocaml, findlib}:

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

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

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

  buildInputs = [ocaml findlib];

  dontAddPrefix = true;

  doCheck = true;

  checkTarget = "test";

  createFindlibDestdir = true;

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


{ stdenv, fetchurl, m4, perl }:

stdenv.mkDerivation rec {
  name = "autoconf-2.64";

  src = fetchurl {
    url = "mirror://gnu/autoconf/${name}.tar.bz2";
    sha256 = "11damk9x09616cjdfxx9y73igd96zzylgq0l4j57qzify6nlqbw7";
  };

  buildInputs = [ m4 perl ];

  doCheck = true;

  # Don't fixup "#! /bin/sh" in Autoconf, otherwise it will use the
  # "fixed" path in generated files!
  dontPatchShebangs = true;

  meta = {
    homepage = http://www.gnu.org/software/autoconf/;
    description = "GNU Autoconf, a part of the GNU Build System";

    longDescription = ''
      GNU Autoconf is an extensible package of M4 macros that produce
      shell scripts to automatically configure software source code
      packages.  These scripts can adapt the packages to many kinds of
      UNIX-like systems without manual user intervention.  Autoconf
      creates a configuration script for a package from a template
      file that lists the operating system features that the package
      can use, in the form of M4 macro calls.
    '';

    license = "GPLv2+";

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

Disable the test suite on {Cyg,Dar}win.

{ stdenv, fetchurl, m4, perl }:

stdenv.mkDerivation rec {
  name = "autoconf-2.64";

  src = fetchurl {
    url = "mirror://gnu/autoconf/${name}.tar.bz2";
    sha256 = "11damk9x09616cjdfxx9y73igd96zzylgq0l4j57qzify6nlqbw7";
  };

  buildInputs = [ m4 perl ];

  # FIXME: The test suite fails on Darwin (see
  # http://thread.gmane.org/gmane.comp.sysutils.autoconf.bugs/6813) and on
  # Cygwin (see http://hydra.nixos.org/build/53814; yet to be reported
  # upstream).
  doCheck =
    (builtins.currentSystem != "i686-darwin")
    && (builtins.currentSystem != "i686-cygwin");

  # Don't fixup "#! /bin/sh" in Autoconf, otherwise it will use the
  # "fixed" path in generated files!
  dontPatchShebangs = true;

  meta = {
    homepage = http://www.gnu.org/software/autoconf/;
    description = "GNU Autoconf, a part of the GNU Build System";

    longDescription = ''
      GNU Autoconf is an extensible package of M4 macros that produce
      shell scripts to automatically configure software source code
      packages.  These scripts can adapt the packages to many kinds of
      UNIX-like systems without manual user intervention.  Autoconf
      creates a configuration script for a package from a template
      file that lists the operating system features that the package
      can use, in the form of M4 macro calls.
    '';

    license = "GPLv2+";

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


{ stdenv, fetchurl, openssl, libuuid }:

stdenv.mkDerivation rec {
  pname = "mosquitto";
  version = "1.4";

  name = "${pname}-${version}";

  src = fetchurl {
    url = http://mosquitto.org/files/source/mosquitto-1.4.tar.gz;
    sha256 = "1imw5ps0cqda41b574k8hgz9gdr8yy58f76fg8gw14pdnvf3l7sr";
  };

  buildInputs = [ openssl libuuid ];

  buildFlags = "mosquitto";

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

  meta = {
    homepage = http://mosquitto.org/;
    description = "An open source MQTT v3.1/3.1.1 broker";
    platforms = stdenv.lib.platforms.unix;
    # http://www.eclipse.org/legal/epl-v10.html (free software, copyleft)
    license = stdenv.lib.licenses.epl10;
  };
}

Use built-in Makefile for installation.

{ stdenv, fetchurl, openssl, libuuid }:

stdenv.mkDerivation rec {
  pname = "mosquitto";
  version = "1.4";

  name = "${pname}-${version}";

  src = fetchurl {
    url = http://mosquitto.org/files/source/mosquitto-1.4.tar.gz;
    sha256 = "1imw5ps0cqda41b574k8hgz9gdr8yy58f76fg8gw14pdnvf3l7sr";
  };

  buildInputs = [ openssl libuuid ];

  makeFlags = [
    "DESTDIR=$(out)"
    "PREFIX="
  ];

  preBuild = ''
    substituteInPlace config.mk \
      --replace "/usr/local" ""
  '';

  meta = {
    homepage = http://mosquitto.org/;
    description = "An open source MQTT v3.1/3.1.1 broker";
    platforms = stdenv.lib.platforms.unix;
    # http://www.eclipse.org/legal/epl-v10.html (free software, copyleft)
    license = stdenv.lib.licenses.epl10;
  };
}


{ stdenv
, fetchFromGitHub

, bzip2
, expat
, lmdb
, mcpp
, openssl
}:

# TODO: support for java, mono, python, & ruby
let
  version = "3.7.0";
in
stdenv.mkDerivation rec {
  name = "ice-${version}";

  src = fetchFromGitHub {
    version = 3;
    owner = "zeroc-ice";
    repo = "ice";
    rev = "v${version}";
    sha256 = "dc26d72374aa42e02a850f53d896da48ca47e4f6699638862b932fc6579bb80f";
  };

  buildInputs = [
    bzip2
    expat
    lmdb
    mcpp
    openssl
  ];

  postUnpack = ''
    export sourceRoot="$sourceRoot/cpp"
  '';

  preConfigure = ''
    makeFlagsArray+=("prefix=$out")
  '';

  buildFlags = [
    "srcs"
  ];

  meta = with stdenv.lib; {
    description = "The internet communications engine";
    homepage = "http://www.zeroc.com/ice.html";
    license = licenses.gpl2;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}

Clean up build and install slice files

{ stdenv
, fetchFromGitHub

, bzip2
, expat
, lmdb
, mcpp
, openssl
}:

# TODO: support for java, mono, python, & ruby
let
  version = "3.7.0";
in
stdenv.mkDerivation rec {
  name = "ice-${version}";

  src = fetchFromGitHub {
    version = 3;
    owner = "zeroc-ice";
    repo = "ice";
    rev = "v${version}";
    sha256 = "dc26d72374aa42e02a850f53d896da48ca47e4f6699638862b932fc6579bb80f";
  };

  buildInputs = [
    bzip2
    expat
    lmdb
    mcpp
    openssl
  ];

  postUnpack = ''
    export sourceRoot="$sourceRoot/cpp"
  '';

  preConfigure = ''
    makeFlagsArray+=("prefix=$out")
  '';

  makeFlags = [
    # Required to put docs / manpages in $out/share
    "USR_DIR_INSTALL=yes"
  ];

  buildFlags = [
    "srcs"
  ];

  postInstall = ''
    install_slice() {
      local actualMakeFlags
      commonMakeFlags 'install'
      actualMakeFlags+=("-C" ".." "install-slice")
      printMakeFlags 'install-slice'
      make "''${actualMakeFlags[@]}"
    }
    install_slice
  '';

  meta = with stdenv.lib; {
    description = "The internet communications engine";
    homepage = "http://www.zeroc.com/ice.html";
    license = licenses.gpl2;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}


{ stdenv, fetchurl, zlib, bzip2, openssl, attr, lzo, libgcrypt, e2fsprogs }:

stdenv.mkDerivation rec {
  name = "dar-2.4.15";

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

  buildInputs = [ zlib bzip2 openssl lzo libgcrypt ]
    ++ stdenv.lib.optional stdenv.isLinux [ attr e2fsprogs ];

  configureFlags = "--disable-dar-static";

  meta = {
    homepage = http://dar.linux.free.fr/;
    description = "Disk ARchiver, allows backing up files into indexed archives";
    maintainers = [ stdenv.lib.maintainers.viric ];
    platforms = stdenv.lib.platforms.unix;
  };
}

Update from 2.4.15 to 2.4.17

{ stdenv, fetchurl, zlib, bzip2, openssl, attr, lzo, libgcrypt, e2fsprogs }:

stdenv.mkDerivation rec {
  name = "dar-2.4.17";

  src = fetchurl {
    url = "mirror://sourceforge/dar/${name}.tar.gz";
    sha256 = "0g43g6a633j6ipgwdvgwngnrnzhfwkhl2iwih1314xwbd4wir1jx";
  };

  buildInputs = [ zlib bzip2 openssl lzo libgcrypt ]
    ++ stdenv.lib.optional stdenv.isLinux [ attr e2fsprogs ];

  configureFlags = "--disable-dar-static";

  meta = {
    homepage = http://dar.linux.free.fr/;
    description = "Disk ARchiver, allows backing up files into indexed archives";
    maintainers = [ stdenv.lib.maintainers.viric ];
    platforms = stdenv.lib.platforms.unix;
  };
}


{ lib, buildGoModule, fetchFromGitHub }:

buildGoModule rec {
  pname = "unifi-poller";
  version = "2.1.7";

  src = fetchFromGitHub {
    owner = "unifi-poller";
    repo = "unifi-poller";
    rev = "v${version}";
    sha256 = "sha256-79aBqYS8B+gIqmhu/UIA7g+FvTS/68qsK7qi5MGH10k=";
  };

  vendorSha256 = "sha256-WVYQ3cZOO+EyJRTFcMjziDHwqqinm1IvxvSLuHTaqT8=";

  ldflags = [
    "-w" "-s"
    "-X github.com/prometheus/common/version.Branch=master"
    "-X github.com/prometheus/common/version.BuildDate=unknown"
    "-X github.com/prometheus/common/version.Revision=${src.rev}"
    "-X github.com/prometheus/common/version.Version=${version}-0"
  ];

  meta = with lib; {
    description = "Collect ALL UniFi Controller, Site, Device & Client Data - Export to InfluxDB or Prometheus";
    homepage = "https://github.com/unifi-poller/unifi-poller";
    license = licenses.mit;
    maintainers = with maintainers; [ ];
  };
}

Revert "unifi-poller: 2.1.3 -> 2.1.7"

{ lib, buildGoModule, fetchFromGitHub }:

buildGoModule rec {
  pname = "unifi-poller";
  version = "2.1.3";

  src = fetchFromGitHub {
    owner = "unifi-poller";
    repo = "unifi-poller";
    rev = "v${version}";
    sha256 = "sha256-xh9s1xAhIeEmeDprl7iPdE6pxmxZjzgMvilobiIoJp0=";
  };

  vendorSha256 = "sha256-HoYgBKTl9HIMVzzzNYtRrfmqb7HCpPHVPeR4gUXneWk=";

  ldflags = [
    "-w" "-s"
    "-X github.com/prometheus/common/version.Branch=master"
    "-X github.com/prometheus/common/version.BuildDate=unknown"
    "-X github.com/prometheus/common/version.Revision=${src.rev}"
    "-X github.com/prometheus/common/version.Version=${version}-0"
  ];

  meta = with lib; {
    description = "Collect ALL UniFi Controller, Site, Device & Client Data - Export to InfluxDB or Prometheus";
    homepage = "https://github.com/unifi-poller/unifi-poller";
    license = licenses.mit;
    maintainers = with maintainers; [ ];
  };
}


{ stdenv
, cmake
, fetchFromGitHub
, ninja

, glib
, zlib
}:

let
  version = "0.4.12";
in
stdenv.mkDerivation rec {
  name = "libproxy-${version}";

  src = fetchFromGitHub {
    owner = "libproxy";
    repo = "libproxy";
    rev = version;
    sha256 = "845dc3a4f29349a9e62c0235e79fc753115fd519f2e4857aaa0f4c2503e59994";
  };

  nativeBuildInputs = [
    cmake
    ninja
  ];

  buildInputs = [
    glib
    zlib
  ];

  meta = with stdenv.lib; {
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}

Remove use of ninja as it is broken

{ stdenv
, cmake
, fetchFromGitHub

, glib
, zlib
}:

let
  version = "0.4.12";
in
stdenv.mkDerivation rec {
  name = "libproxy-${version}";

  src = fetchFromGitHub {
    owner = "libproxy";
    repo = "libproxy";
    rev = version;
    sha256 = "845dc3a4f29349a9e62c0235e79fc753115fd519f2e4857aaa0f4c2503e59994";
  };

  nativeBuildInputs = [
    cmake
  ];

  buildInputs = [
    glib
    zlib
  ];

  meta = with stdenv.lib; {
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}


{ stdenv, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  name = "cli53-${version}";
  version = "0.8.8";

  goPackagePath = "github.com/barnybug/cli53";

  src = fetchFromGitHub {
    owner = "barnybug";
    repo = "cli53";
    rev = version;
    sha256 = "1hbx64rn25qzp2xlfwv8xaqyfcax9b6pl30j9vciw7cb346i84gc";
  };

  buildPhase = ''
    pushd go/src/${goPackagePath}/cmd/cli53
    go get .
    popd
  '';

  goDeps = ./deps.nix;

  meta = with stdenv.lib; {
    description = "CLI tool for the Amazon Route 53 DNS service";
    homepage = https://github.com/barnybug/cli53;
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ benley ];
  };
}

Revert "cli53: 0.4.4 -> 0.8.8"

{ lib, python2Packages, fetchurl }:

python2Packages.buildPythonApplication rec {
  name = "cli53-${version}";
  version = "0.4.4";

  src = fetchurl {
    url = "mirror://pypi/c/cli53/${name}.tar.gz";
    sha256 = "0s9jzigq6a16m2c3qklssx2lz16cf13g5zh80vh24kxazaxqzbig";
  };

  propagatedBuildInputs = with python2Packages; [
    argparse
    boto
    dns
  ];

  meta = {
    description = "CLI tool for the Amazon Route 53 DNS service";
    homepage = https://github.com/barnybug/cli53;
    license = lib.licenses.mit;
    maintainers = with lib.maintainers; [ benley ];
  };
}


{stdenv, fetchurl, intltool, pkgconfig, qt4, gtk2, gtk3, kdelibs, cmake, ... }:

stdenv.mkDerivation rec {
  version = "1.8.6";
  name = "uim-${version}";

  buildInputs = [
    intltool
    pkgconfig
    qt4
    gtk2
    gtk3
    kdelibs
    cmake
  ];

  patches = [ ./immodules_cache.patch ];

  configureFlags = [
    "--with-gtk2"
    "--with-gtk3"
    "--enable-kde4-applet"
    "--enable-notify=knotify4"
    "--enable-pref"
    "--with-qt4"
    "--with-qt4-immodule"
    "--with-skk"
    "--with-x"
  ];

  dontUseCmakeConfigure = true;

  src = fetchurl {
    url = "http://uim.googlecode.com/files/uim-${version}.tar.bz2";
    sha1 = "43b9dbdead6797880e6cfc9c032ecb2d37d42777";
  };

  meta = {
    homepage = "http://code.google.com/p/uim/";
    description = "A multilingual input method framework";
    license = stdenv.lib.licenses.bsd3;
    platforms = stdenv.lib.platforms.linux;
  };
}

Add anthy support to uim

{stdenv, fetchurl, intltool, pkgconfig, qt4, gtk2, gtk3, kdelibs, cmake, anthy, ... }:

stdenv.mkDerivation rec {
  version = "1.8.6";
  name = "uim-${version}";

  buildInputs = [
    intltool
    pkgconfig
    qt4
    gtk2
    gtk3
    kdelibs
    cmake
    anthy
  ];

  patches = [ ./immodules_cache.patch ];

  configureFlags = [
    "--with-gtk2"
    "--with-gtk3"
    "--enable-kde4-applet"
    "--enable-notify=knotify4"
    "--enable-pref"
    "--with-qt4"
    "--with-qt4-immodule"
    "--with-skk"
    "--with-x"
    "--with-anthy-utf8"
  ];

  dontUseCmakeConfigure = true;

  src = fetchurl {
    url = "http://uim.googlecode.com/files/uim-${version}.tar.bz2";
    sha1 = "43b9dbdead6797880e6cfc9c032ecb2d37d42777";
  };

  meta = {
    homepage = "http://code.google.com/p/uim/";
    description = "A multilingual input method framework";
    license = stdenv.lib.licenses.bsd3;
    platforms = stdenv.lib.platforms.linux;
  };
}


{ config, pkgs, ... }:

with pkgs.lib;

let virtualbox = config.boot.kernelPackages.virtualbox; in

{
  boot.kernelModules = [ "vboxdrv" "vboxnetadp" "vboxnetflt" ];
  boot.extraModulePackages = [ virtualbox ];
  environment.systemPackages = [ virtualbox ];

  users.extraGroups = singleton { name = "vboxusers"; };

  services.udev.extraRules =
    ''
      KERNEL=="vboxdrv",    OWNER="root", GROUP="vboxusers", MODE="0660"
      KERNEL=="vboxnetctl", OWNER="root", GROUP="root",      MODE="0600"
    '';

  # Since we lack the right setuid binaries, set up a host-only network by default.

  jobs."create-vboxnet0" =
    { task = true;
      path = [ virtualbox ];
      startOn = "starting network-interfaces";
      script =
        ''
          if ! [ -e /sys/class/net/vboxnet0 ]; then
            VBoxManage hostonlyif create
          fi
        '';
    };

  networking.interfaces = [ { name = "vboxnet0"; ipAddress = "192.168.56.1"; subnetMask = "255.255.255.0"; } ];
}

Fix the dependencies of the vboxnet0 service

{ config, pkgs, ... }:

with pkgs.lib;

let virtualbox = config.boot.kernelPackages.virtualbox; in

{
  boot.kernelModules = [ "vboxdrv" "vboxnetadp" "vboxnetflt" ];
  boot.extraModulePackages = [ virtualbox ];
  environment.systemPackages = [ virtualbox ];

  users.extraGroups = singleton { name = "vboxusers"; };

  services.udev.extraRules =
    ''
      KERNEL=="vboxdrv",    OWNER="root", GROUP="vboxusers", MODE="0660", TAG+="systemd"
      KERNEL=="vboxnetctl", OWNER="root", GROUP="root",      MODE="0600", TAG+="systemd"
    '';

  # Since we lack the right setuid binaries, set up a host-only network by default.

  jobs."vboxnet0" =
    { description = "VirtualBox vboxnet0 Interface";
      requires = [ "dev-vboxnetctl.device" ];
      after = [ "dev-vboxnetctl.device" ];
      before = [ "network-interfaces.service" ];
      wantedBy = [ "multi-user.target" ];
      path = [ virtualbox ];
      preStart =
        ''
          if ! [ -e /sys/class/net/vboxnet0 ]; then
            VBoxManage hostonlyif create
          fi
        '';
      postStop =
        ''
          VBoxManage hostonlyif remove vboxnet0
        '';
    };

  networking.interfaces = [ { name = "vboxnet0"; ipAddress = "192.168.56.1"; subnetMask = "255.255.255.0"; } ];
}


{ lib, buildPythonPackage, fetchPypi
, cryptography, ecdsa
, pytestrunner, pytestcov, pytest_37 }:

buildPythonPackage rec {
  pname = "PyJWT";
  version = "1.6.4";

  src = fetchPypi {
    inherit pname version;
    sha256 = "4ee413b357d53fd3fb44704577afac88e72e878716116270d722723d65b42176";
  };

  propagatedBuildInputs = [ cryptography ecdsa ];

  checkInputs = [ pytestrunner pytestcov pytest_37 ];

  # pytest 3.9.0 changed behavior of deprecated_call, see release notes
  postPatch = ''
    for x in tests/test_api_*py; do
      substituteInPlace "$x" --replace AssertionError pytest.fail.Exception
    done
  '';

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

Revert "python: pyjwt: fix build"

{ lib, buildPythonPackage, fetchPypi
, cryptography, ecdsa
, pytestrunner, pytestcov, pytest }:

buildPythonPackage rec {
  pname = "PyJWT";
  version = "1.6.4";

  src = fetchPypi {
    inherit pname version;
    sha256 = "4ee413b357d53fd3fb44704577afac88e72e878716116270d722723d65b42176";
  };

  propagatedBuildInputs = [ cryptography ecdsa ];

  checkInputs = [ pytestrunner pytestcov pytest ];

  # pytest 3.9.0 changed behavior of deprecated_call, see release notes
  postPatch = ''
    for x in tests/test_api_*py; do
      substituteInPlace "$x" --replace AssertionError pytest.fail.Exception
    done
  '';

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


{ mkDerivation, reflex, reflex-dom, file-embed, cabal-macosx
}:

mkDerivation {
  pname = "reflex-todomvc";
  version = "0.1";
  src = builtins.filterSource (path: type: baseNameOf path != ".git") ./.;
  isExecutable = true;
  isLibrary = true;
  buildDepends = [
    reflex
    reflex-dom
    file-embed
    cabal-macosx
  ];
  license = null;
}

Add jsaddle-warp, -wkwebview & -webkit2gtk to nix

{ mkDerivation, reflex, reflex-dom, file-embed, cabal-macosx, jsaddle-warp, jsaddle-webkit2gtk, jsaddle-wkwebview, ghc, stdenv
}:

mkDerivation {
  pname = "reflex-todomvc";
  version = "0.1";
  src = builtins.filterSource (path: type: baseNameOf path != ".git") ./.;
  isExecutable = true;
  isLibrary = true;
  buildDepends = [
    reflex
    reflex-dom
    file-embed
    cabal-macosx
  ] ++ (if ghc.isGhcjs or false then [
  ] else if stdenv.isDarwin then [
    jsaddle-wkwebview
#    jsaddle-webkit2gtk
    jsaddle-warp
  ] else [
    jsaddle-webkit2gtk
    jsaddle-warp
  ]);
  license = null;
}


{ stdenv, fetchurl, groff }:

stdenv.mkDerivation rec {
  name = "mdadm-3.3.2";

  src = fetchurl {
    url = "mirror://kernel/linux/utils/raid/mdadm/${name}.tar.xz";
    sha256 = "132vdvh3myjgcjn6i9w90ck16ddjxjcszklzkyvr4f5ifqd7wfhg";
  };

  nativeBuildInputs = [ groff ];

  preConfigure = "sed -e 's@/lib/udev@\${out}/lib/udev@' -e 's@ -Werror @ @' -i Makefile";

  # Force mdadm to use /var/run/mdadm.map for its map file (or
  # /dev/.mdadm/map as a fallback).
  preBuild =
    ''
      makeFlagsArray=(INSTALL=install BINDIR=$out/sbin MANDIR=$out/share/man RUN_DIR=/dev/.mdadm)
      if [[ -n "$crossConfig" ]]; then
        makeFlagsArray+=(CROSS_COMPILE=$crossConfig-)
      fi
    '';

  meta = {
    description = "Programs for managing RAID arrays under Linux";
    homepage = http://neil.brown.name/blog/mdadm;
  };
}

Revert "mdadm: 3.3 -> 3.3.2".

{ stdenv, fetchurl, groff }:

stdenv.mkDerivation rec {
  name = "mdadm-3.3";

  # WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING
  #  Do NOT update this if you're not ABSOLUTELY certain that it will work.
  #  Please check the update using the NixOS VM test, BEFORE pushing:
  #    nix-build nixos/release.nix -A tests.installer.swraid.x86_64-linux
  # Discussion:
  #   https://github.com/NixOS/nixpkgs/commit/7719f7f
  #   https://github.com/NixOS/nixpkgs/commit/666cf99
  #   https://github.com/NixOS/nixpkgs/pull/6006
  # WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING -- WARNING
  src = fetchurl {
    url = "mirror://kernel/linux/utils/raid/mdadm/${name}.tar.bz2";
    sha256 = "0igdqflihiq1dp5qlypzw0xfl44f4n3bckl7r2x2wfgkplcfa1ww";
  };

  nativeBuildInputs = [ groff ];

  preConfigure = "sed -e 's@/lib/udev@\${out}/lib/udev@' -e 's@ -Werror @ @' -i Makefile";

  # Force mdadm to use /var/run/mdadm.map for its map file (or
  # /dev/.mdadm/map as a fallback).
  preBuild =
    ''
      makeFlagsArray=(INSTALL=install BINDIR=$out/sbin MANDIR=$out/share/man RUN_DIR=/dev/.mdadm)
      if [[ -n "$crossConfig" ]]; then
        makeFlagsArray+=(CROSS_COMPILE=$crossConfig-)
      fi
    '';

  meta = {
    description = "Programs for managing RAID arrays under Linux";
    homepage = http://neil.brown.name/blog/mdadm;
  };
}


{ stdenv, fetchurl, libxml2, pkgconfig
, compressionSupport ? true, zlib ? null
, sslSupport ? true, openssl ? null
, static ? false
, shared ? true
}:

assert compressionSupport -> zlib != null;
assert sslSupport -> openssl != null;
assert static || shared;

let
   inherit (stdenv.lib) optionals;
in

stdenv.mkDerivation rec {
  name = "neon-0.30.1";

  src = fetchurl {
    url = "http://www.webdav.org/neon/${name}.tar.gz";
    sha256 = "1pawhk02x728xn396a1kcivy9gqm94srmgad6ymr9l0qvk02dih0";
  };

  patches = optionals stdenv.isDarwin [ ./0.29.6-darwin-fix-configure.patch ];

  buildInputs = [libxml2 pkgconfig openssl]
    ++ stdenv.lib.optional compressionSupport zlib;

  configureFlags = ''
    ${if shared then "--enable-shared" else "--disable-shared"}
    ${if static then "--enable-static" else "--disable-static"}
    ${if compressionSupport then "--with-zlib" else "--without-zlib"}
    ${if sslSupport then "--with-ssl" else "--without-ssl"}
    --enable-shared
  '';

  passthru = {inherit compressionSupport sslSupport;};

  meta = {
    description = "An HTTP and WebDAV client library";
    homepage = http://www.webdav.org/neon/;
  };
}

Put version into own variable

{ stdenv, fetchurl, libxml2, pkgconfig
, compressionSupport ? true, zlib ? null
, sslSupport ? true, openssl ? null
, static ? false
, shared ? true
}:

assert compressionSupport -> zlib != null;
assert sslSupport -> openssl != null;
assert static || shared;

let
   inherit (stdenv.lib) optionals;
in

stdenv.mkDerivation rec {
  version = "0.30.1";
  name = "neon-${version}";

  src = fetchurl {
    url = "http://www.webdav.org/neon/${name}.tar.gz";
    sha256 = "1pawhk02x728xn396a1kcivy9gqm94srmgad6ymr9l0qvk02dih0";
  };

  patches = optionals stdenv.isDarwin [ ./0.29.6-darwin-fix-configure.patch ];

  buildInputs = [libxml2 pkgconfig openssl]
    ++ stdenv.lib.optional compressionSupport zlib;

  configureFlags = ''
    ${if shared then "--enable-shared" else "--disable-shared"}
    ${if static then "--enable-static" else "--disable-static"}
    ${if compressionSupport then "--with-zlib" else "--without-zlib"}
    ${if sslSupport then "--with-ssl" else "--without-ssl"}
    --enable-shared
  '';

  passthru = {inherit compressionSupport sslSupport;};

  meta = {
    description = "An HTTP and WebDAV client library";
    homepage = http://www.webdav.org/neon/;
  };
}


{ stdenv, fetchurl, nasm, perl, libuuid }:

stdenv.mkDerivation rec {
  name = "syslinux-6.03";

  src = fetchurl {
    url = "mirror://kernel/linux/utils/boot/syslinux/${name}.tar.xz";
    sha256 = "03l5iifwlg1wyb4yh98i0b7pd4j55a1c9y74q1frs47a5dnrilr6";
  };

  patches = [ ./perl-deps.patch ];

  buildInputs = [ nasm perl libuuid ];

  enableParallelBuilding = false; # problems on Hydra

  preBuild = ''
    substituteInPlace Makefile --replace /bin/pwd $(type -P pwd)
    substituteInPlace gpxe/src/Makefile.housekeeping --replace /bin/echo $(type -P echo)
    substituteInPlace gpxe/src/Makefile --replace /usr/bin/perl $(type -P perl)
  '';

  makeFlags = [
    "BINDIR=$(out)/bin"
    "SBINDIR=$(out)/sbin"
    "LIBDIR=$(out)/lib"
    "INCDIR=$(out)/include"
    "DATADIR=$(out)/share"
    "MANDIR=$(out)/share/man"
    "PERL=perl"
    "bios"
  ];

  meta = with stdenv.lib; {
    homepage = http://www.syslinux.org/;
    description = "A lightweight bootloader";
    license = licenses.gpl2;
    platforms = platforms.linux;
  };
}

Revert "syslinux: disable parallel building"

{ stdenv, fetchurl, nasm, perl, libuuid }:

stdenv.mkDerivation rec {
  name = "syslinux-6.03";

  src = fetchurl {
    url = "mirror://kernel/linux/utils/boot/syslinux/${name}.tar.xz";
    sha256 = "03l5iifwlg1wyb4yh98i0b7pd4j55a1c9y74q1frs47a5dnrilr6";
  };

  patches = [ ./perl-deps.patch ];

  buildInputs = [ nasm perl libuuid ];

  enableParallelBuilding = true;

  preBuild = ''
    substituteInPlace Makefile --replace /bin/pwd $(type -P pwd)
    substituteInPlace gpxe/src/Makefile.housekeeping --replace /bin/echo $(type -P echo)
    substituteInPlace gpxe/src/Makefile --replace /usr/bin/perl $(type -P perl)
  '';

  makeFlags = [
    "BINDIR=$(out)/bin"
    "SBINDIR=$(out)/sbin"
    "LIBDIR=$(out)/lib"
    "INCDIR=$(out)/include"
    "DATADIR=$(out)/share"
    "MANDIR=$(out)/share/man"
    "PERL=perl"
    "bios"
  ];

  meta = with stdenv.lib; {
    homepage = http://www.syslinux.org/;
    description = "A lightweight bootloader";
    license = licenses.gpl2;
    platforms = platforms.linux;
  };
}


{ config, pkgs, ... }:

with pkgs.lib;

{

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

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

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

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

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

    jobs.pommed = { name = "pommed";

      description = "Pommed hotkey management";

      startOn = "started dbus";

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

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

      daemonType = "fork";

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

Remove unnecessary (AFAICT) call to toPath

{ config, pkgs, ... }:

with pkgs.lib;

{

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

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

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

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

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

    jobs.pommed = { name = "pommed";

      description = "Pommed hotkey management";

      startOn = "started dbus";

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

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

      daemonType = "fork";

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


{ pkgs ? import ../nixpkgs {} }:
pkgs.stdenv.mkDerivation rec {
  name = "shcl";
  src = ./.;
  env = pkgs.buildEnv { name = name; paths = buildInputs; };
  buildInputs = [
    pkgs.clang
    pkgs.libedit
    pkgs.lispPackages.alexandria
    pkgs.lispPackages.bordeaux-threads
    pkgs.lispPackages.cffi
    pkgs.lispPackages.cffi-grovel
    pkgs.lispPackages.cl-cli
    pkgs.lispPackages.cl-fad
    pkgs.lispPackages.closer-mop
    pkgs.lispPackages.cl-ppcre
    pkgs.lispPackages.fset
    pkgs.lispPackages.lisp-namespace
    pkgs.lispPackages.quicklisp
    pkgs.lispPackages.swank
    pkgs.lispPackages.trivial-garbage
    pkgs.lispPackages.trivial-gray-streams
    pkgs.sbcl
  ];
  LD_LIBRARY_PATH = "${pkgs.stdenv.lib.makeLibraryPath buildInputs}";
  installPhase = ''
    mkdir -p $out/bin
    cp shcl $out/bin
  '';
  dontStrip = true;
}

Bring prove into nix environment for testing

{ pkgs ? import ../nixpkgs {} }:
pkgs.stdenv.mkDerivation rec {
  name = "shcl";
  src = ./.;
  env = pkgs.buildEnv { name = name; paths = buildInputs; };
  buildInputs = [
    pkgs.clang
    pkgs.libedit
    pkgs.lispPackages.alexandria
    pkgs.lispPackages.bordeaux-threads
    pkgs.lispPackages.cffi
    pkgs.lispPackages.cffi-grovel
    pkgs.lispPackages.cl-cli
    pkgs.lispPackages.cl-fad
    pkgs.lispPackages.closer-mop
    pkgs.lispPackages.cl-ppcre
    pkgs.lispPackages.fset
    pkgs.lispPackages.lisp-namespace
    pkgs.lispPackages.quicklisp
    pkgs.lispPackages.swank
    pkgs.lispPackages.trivial-garbage
    pkgs.lispPackages.trivial-gray-streams
    pkgs.sbcl
    # For test
    pkgs.lispPackages.prove
  ];
  LD_LIBRARY_PATH = "${pkgs.stdenv.lib.makeLibraryPath buildInputs}";
  installPhase = ''
    mkdir -p $out/bin
    cp shcl $out/bin
  '';
  dontStrip = true;
}


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

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

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

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

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

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

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


{ fetchurl, stdenv }:

stdenv.mkDerivation rec {
  name = "paxctl-${version}";
  version = "0.7";

  src = fetchurl {
    url = "https://pax.grsecurity.net/${name}.tar.bz2";
    sha256 = "1j6dg6wd1v7na5i4xj8zmbff0mdqdnw6cvqy0rsbz5anra27f1zp";
  };

  preBuild = ''
    sed "s|--owner 0 --group 0||g" -i Makefile
  '';

  makeFlags = [
    "DESTDIR=$(out)"
    "MANDIR=share/man/man1"
  ];

  meta = with stdenv.lib; {
    description = "A tool for controlling PaX flags on a per binary basis";
    homepage    = "https://pax.grsecurity.net";
    license     = licenses.gpl2;
    platforms   = platforms.linux;
    maintainers = with maintainers; [ thoughtpolice wizeman ];
  };
}

Use http instead of https

{ fetchurl, stdenv }:

stdenv.mkDerivation rec {
  name = "paxctl-${version}";
  version = "0.7";

  src = fetchurl {
    url = "http://pax.grsecurity.net/${name}.tar.bz2";
    sha256 = "1j6dg6wd1v7na5i4xj8zmbff0mdqdnw6cvqy0rsbz5anra27f1zp";
  };

  preBuild = ''
    sed "s|--owner 0 --group 0||g" -i Makefile
  '';

  makeFlags = [
    "DESTDIR=$(out)"
    "MANDIR=share/man/man1"
  ];

  meta = with stdenv.lib; {
    description = "A tool for controlling PaX flags on a per binary basis";
    homepage    = "https://pax.grsecurity.net";
    license     = licenses.gpl2;
    platforms   = platforms.linux;
    maintainers = with maintainers; [ thoughtpolice wizeman ];
  };
}


{stdenv, fetchurl, ocaml, findlib, ocaml_lwt, menhir, ocsigen_deriving, camlp4,
 cmdliner}:

stdenv.mkDerivation {
  name = "js_of_ocaml-2.5";
  src = fetchurl {
    url = https://github.com/ocsigen/js_of_ocaml/archive/2.5.tar.gz;
    sha256 = "1prm08nf8szmd3p13ysb0yx1cy6lr671bnwsp25iny8hfbs39sjv";
    };

  buildInputs = [ocaml findlib ocaml_lwt menhir ocsigen_deriving
                 cmdliner camlp4];

  patches = [ ./Makefile.conf.diff ];

  createFindlibDestdir = true;

  meta =  {
    homepage = http://ocsigen.org/js_of_ocaml/;
    description = "Compiler of OCaml bytecode to Javascript. It makes it possible to run Ocaml programs in a Web browser";
    license = "LGPL";
    platforms = ocaml.meta.platforms;
    maintainers = [
      stdenv.lib.maintainers.gal_bolle
    ];
  };

}

Build js_of_ocaml with tyxml support

{stdenv, fetchurl, ocaml, findlib, ocaml_lwt, menhir, ocsigen_deriving, camlp4,
 cmdliner, tyxml, reactivedata}:

stdenv.mkDerivation {
  name = "js_of_ocaml-2.5";
  src = fetchurl {
    url = https://github.com/ocsigen/js_of_ocaml/archive/2.5.tar.gz;
    sha256 = "1prm08nf8szmd3p13ysb0yx1cy6lr671bnwsp25iny8hfbs39sjv";
    };

  buildInputs = [ocaml findlib ocaml_lwt menhir ocsigen_deriving
                 cmdliner tyxml camlp4 reactivedata];

  patches = [ ./Makefile.conf.diff ];

  createFindlibDestdir = true;

  meta =  {
    homepage = http://ocsigen.org/js_of_ocaml/;
    description = "Compiler of OCaml bytecode to Javascript. It makes it possible to run Ocaml programs in a Web browser";
    license = "LGPL";
    platforms = ocaml.meta.platforms;
    maintainers = [
      stdenv.lib.maintainers.gal_bolle
    ];
  };

}


{ lib
, buildPythonPackage
, fetchPypi
}:

buildPythonPackage rec {
  pname = "kiwisolver";
  version = "1.0.1";

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

  # Does not include tests
  doCheck = false;

  meta = {
    description = "A fast implementation of the Cassowary constraint solver";
    homepage = https://github.com/nucleic/kiwi;
    license = lib.licenses.bsd3;
  };

}

Fix the problem of it not compling in macOS

{ lib
, buildPythonPackage
, fetchPypi
, stdenv
, libcxx
}:

buildPythonPackage rec {
  pname = "kiwisolver";
  version = "1.0.1";

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

  NIX_CFLAGS_COMPILE = stdenv.lib.optionalString stdenv.isDarwin "-I${libcxx}/include/c++/v1";

  # Does not include tests
  doCheck = false;

  meta = {
    description = "A fast implementation of the Cassowary constraint solver";
    homepage = https://github.com/nucleic/kiwi;
    license = lib.licenses.bsd3;
  };

}


{ config, pkgs, ... }:

let
  homedir = builtins.getEnv "HOME";
in
{
  nixpkgs.config.allowUnfree = true;

  programs.home-manager.enable = true;

  imports = [
    ../../applications/ammonite
    ../../applications/codium
    ../../applications/coursier
    ../../applications/direnv
    ../../applications/emacs
    ../../applications/fzf
    ../../applications/git
    ../../applications/neovim
    ../../applications/sbt
    ../../applications/utils
    ../../applications/zsh
  ];

  fonts.fontconfig.enable = true;

  home.packages = with pkgs; [
    (nerdfonts.override { fonts = [ "FiraCode" ]; })

    # Cli tools
    bat
    kubectl
    jq
    xsel
    httpie

    # Global dev tools
    graalvm11-ce
    (pkgs.bloop.override { jre = pkgs.graalvm11-ce; })

    # Graphics
    keepassxc
    slack
  ];

  home.file = {
    ".xprofile".text = ''
      export XDG_DATA_DIRS=$HOME/.nix-profile/share:$HOME/.local/share:/usr/local/share:/usr/share
    '';
  };
}

Use kubectl from stable nix

{ config, pkgs, ... }:

let
  homedir = builtins.getEnv "HOME";

  sources = import ../../nix/sources.nix;
  nixpkgs = sources."nixpkgs";
  stablepkgs = import nixpkgs {};
in
{
  nixpkgs.config.allowUnfree = true;

  programs.home-manager.enable = true;

  imports = [
    ../../applications/ammonite
    ../../applications/codium
    ../../applications/coursier
    ../../applications/direnv
    ../../applications/emacs
    ../../applications/fzf
    ../../applications/git
    ../../applications/neovim
    ../../applications/sbt
    ../../applications/utils
    ../../applications/zsh
  ];

  fonts.fontconfig.enable = true;

  home.packages = with pkgs; [
    (nerdfonts.override { fonts = [ "FiraCode" ]; })

    # Cli tools
    bat
    stablepkgs.kubectl
    jq
    xsel
    httpie

    # Global dev tools
    graalvm11-ce
    (pkgs.bloop.override { jre = pkgs.graalvm11-ce; })

    # Graphics
    keepassxc
    slack
  ];

  home.file = {
    ".xprofile".text = ''
      export XDG_DATA_DIRS=$HOME/.nix-profile/share:$HOME/.local/share:/usr/local/share:/usr/share
    '';
  };
}


{ pkgs ? import <nixpkgs> {} }:
let
  inherit (pkgs.haskell.packages) ghcjsHEAD;
in { miso-release = import ./default.nix { nixpkgs = pkgs; };
     miso-ghcjs8 = ghcjsHEAD.callPackage ./miso-ghcjs.nix {};
   }

Add haskell-miso and sse example to CI

{ pkgs ? import <nixpkgs> {} }:
let
  inherit (pkgs.haskell.packages) ghcjsHEAD;
in { miso-release = import ./default.nix { nixpkgs = pkgs; };
     miso-ghcjs8 = ghcjsHEAD.callPackage ./miso-ghcjs.nix {};
     haskell-miso.org = import ./examples/haskell-miso.org {};
     sse-example = import ./examples/sse {};
   }


{ config, lib, pkgs, ... }:

with lib;

let
  cpupower = config.boot.kernelPackages.cpupower;
  cfg = config.powerManagement;
in

{
  ###### interface

  options = {

    powerManagement.cpuFreqGovernor = mkOption {
      type = types.nullOr types.str;
      default = null;
      example = "ondemand";
      description = ''
        Configure the governor used to regulate the frequence of the
        available CPUs. By default, the kernel configures the
        on-demand governor.
      '';
    };

  };

  ###### implementation

  config = mkIf (!config.boot.isContainer && config.powerManagement.cpuFreqGovernor != null) {

    boot.kernelModules = [ "acpi-cpufreq" "speedstep-lib" "pcc-cpufreq"
      "cpufreq_${cfg.cpuFreqGovernor}"
    ];

    environment.systemPackages = [ cpupower ];

    systemd.services.cpufreq = {
      description = "CPU Frequency Governor Setup";
      after = [ "systemd-modules-load.service" ];
      wantedBy = [ "multi-user.target" ];
      path = [ cpupower ];
      unitConfig.ConditionVirtualization = false;
      serviceConfig = {
        Type = "oneshot";
        RemainAfterExit = "yes";
        ExecStart = "${cpupower}/bin/cpupower frequency-set -g ${cfg.cpuFreqGovernor}";
        SuccessExitStatus = "0 237";
      };
    };

  };
}

Remove non-cpufreq_* modules since they are loaded by udev.

{ config, lib, pkgs, ... }:

with lib;

let
  cpupower = config.boot.kernelPackages.cpupower;
  cfg = config.powerManagement;
in

{
  ###### interface

  options = {

    powerManagement.cpuFreqGovernor = mkOption {
      type = types.nullOr types.str;
      default = null;
      example = "ondemand";
      description = ''
        Configure the governor used to regulate the frequence of the
        available CPUs. By default, the kernel configures the
        on-demand governor.
      '';
    };

  };

  ###### implementation

  config = mkIf (!config.boot.isContainer && config.powerManagement.cpuFreqGovernor != null) {

    boot.kernelModules = [ "cpufreq_${cfg.cpuFreqGovernor}" ];

    environment.systemPackages = [ cpupower ];

    systemd.services.cpufreq = {
      description = "CPU Frequency Governor Setup";
      after = [ "systemd-modules-load.service" ];
      wantedBy = [ "multi-user.target" ];
      path = [ cpupower ];
      unitConfig.ConditionVirtualization = false;
      serviceConfig = {
        Type = "oneshot";
        RemainAfterExit = "yes";
        ExecStart = "${cpupower}/bin/cpupower frequency-set -g ${cfg.cpuFreqGovernor}";
        SuccessExitStatus = "0 237";
      };
    };

  };
}


{ pkgs ? import <nixpkgs> {} }:

let
  myEmacs = pkgs.emacs;
  emacsWithPackages = (pkgs.emacsPackagesNgGen myEmacs).emacsWithPackages;
in

emacsWithPackages (epkgs: with {
  elpa = epkgs.elpaPackages;
  melpa = epkgs.melpaPackages;
  melpaStable = epkgs.melpaStablePackages;
  org = epkgs.orgPackages;
}; (with elpa; [
  mmm-mode
]) ++ (with melpa; [
  avy
  better-defaults
  # clj-refactor
  # clojure-mode
  # TODO: company-lsp
  # TODO: cquery
  crux
  dhall-mode
  direnv
  dockerfile-mode
  editorconfig
  elixir-mode
  enh-ruby-mode
  # erlang
  fill-column-indicator
  fish-mode
  # gap-mode
  go-mode
  graphviz-dot-mode
  haskell-mode
  helm-ag
  # TODO: hindent
  hl-todo
  htmlize
  idris-mode
  j-mode
  kubernetes-tramp
  # TODO: lsp-haskell
  # TODO: lsp-mode
  # TODO: lsp-ui
  magit
  markdown-mode
  multiple-cursors
  nix-mode
  paredit
  rainbow-delimiters
  robe
  rust-mode
  rvm
  smex
  tuareg
  use-package
  whitespace-cleanup-mode
  yaml-mode
]) ++ (with melpaStable; [
  ess
]) ++ (with org; [
]))

Add back erlang and gap-mode

{ pkgs ? import <nixpkgs> {} }:

let
  myEmacs = pkgs.emacs;
  emacsWithPackages = (pkgs.emacsPackagesNgGen myEmacs).emacsWithPackages;
in

emacsWithPackages (epkgs: with {
  elpa = epkgs.elpaPackages;
  melpa = epkgs.melpaPackages;
  melpaStable = epkgs.melpaStablePackages;
  org = epkgs.orgPackages;
}; (with elpa; [
  mmm-mode
]) ++ (with melpa; [
  avy
  better-defaults
  # clj-refactor
  # clojure-mode
  # TODO: company-lsp
  # TODO: cquery
  crux
  dhall-mode
  direnv
  dockerfile-mode
  editorconfig
  elixir-mode
  enh-ruby-mode
  erlang
  fill-column-indicator
  fish-mode
  gap-mode
  go-mode
  graphviz-dot-mode
  haskell-mode
  helm-ag
  # TODO: hindent
  hl-todo
  htmlize
  idris-mode
  j-mode
  kubernetes-tramp
  # TODO: lsp-haskell
  # TODO: lsp-mode
  # TODO: lsp-ui
  magit
  markdown-mode
  multiple-cursors
  nix-mode
  paredit
  rainbow-delimiters
  robe
  rust-mode
  rvm
  smex
  tuareg
  use-package
  whitespace-cleanup-mode
  yaml-mode
]) ++ (with melpaStable; [
  ess
]) ++ (with org; [
]))


{ stdenv, fetchurl, m4 }:

stdenv.mkDerivation rec {
  name = "gforth-0.7.3";
  src = fetchurl {
    url = "http://ftp.gnu.org/gnu/gforth/gforth-0.7.3.tar.gz";
    sha256 = "1c1bahc9ypmca8rv2dijiqbangm1d9av286904yw48ph7ciz4qig";
  };
  buildInputs = [ m4 ];
}

Install gforth.el & add meta-data.

{ stdenv, fetchurl, m4 }:

let
  version = "0.7.3";
in
stdenv.mkDerivation {
  name = "gforth-${version}";
  src = fetchurl {
    url = "http://ftp.gnu.org/gnu/gforth/gforth-${version}.tar.gz";
    sha256 = "1c1bahc9ypmca8rv2dijiqbangm1d9av286904yw48ph7ciz4qig";
  };

  buildInputs = [ m4 ];

  postInstall = ''
    mkdir -p $out/share/emacs/site-lisp
    cp gforth.el $out/share/emacs/site-lisp/
  '';

  meta = {
    description = "The Forth implementation of the GNU project";
    homepage = https://www.gnu.org/software/gforth/;
    license = stdenv.lib.licenses.gpl3;
    platforms = stdenv.lib.platforms.all;
    maintainers = with stdenv.lib.maintainers; [ the-kenny ];
  };
}


{ stdenv, fetchurl, texinfo, ncurses, xz, autoconf }:

stdenv.mkDerivation rec {
  pname = "texinfo";
  version = "4.13a";

  src = fetchurl {
    url = "mirror://gnu/texinfo/${pname}-${version}.tar.lzma";
    sha256 = "1rf9ckpqwixj65bw469i634897xwlgkm5i9g2hv3avl6mv7b0a3d";
  };

  autoconfSrc = autoconf.src;

  # We need texinfo4 to build documentation of GNU m4, and version of
  # config.guess bundled in texinfo4 is too old to recognize some CI
  # platforms (see #172225).
  #
  # Using autoreconfHook results in infinity recursion.
  postPatch = ''
    tar xf $autoconfSrc
    cp -v ./autoconf-*/build-aux/config.guess ./build-aux/config.guess
  '';

  buildInputs = [ ncurses ];
  nativeBuildInputs = [ xz ];

  # Disabled because we don't have zdiff in the stdenv bootstrap.
  #doCheck = true;

  meta = texinfo.meta // { branch = version; };
}

Revert "texinfo4: use recent config.guess script"

{ stdenv, fetchurl, texinfo, ncurses, xz }:

stdenv.mkDerivation rec {
  pname = "texinfo";
  version = "4.13a";

  src = fetchurl {
    url = "mirror://gnu/texinfo/${pname}-${version}.tar.lzma";
    sha256 = "1rf9ckpqwixj65bw469i634897xwlgkm5i9g2hv3avl6mv7b0a3d";
  };

  buildInputs = [ ncurses ];
  nativeBuildInputs = [ xz ];

  # Disabled because we don't have zdiff in the stdenv bootstrap.
  #doCheck = true;

  meta = texinfo.meta // { branch = version; };
}


{ stdenv, fetchurl, attr, acl, zlib, libuuid, e2fsprogs, lzo }:

stdenv.mkDerivation rec {
  name = "btrfs-progs-v3.12";

  src = fetchurl {
    url = "mirror://kernel/linux/kernel/people/mason/btrfs-progs/${name}.tar.xz";
    sha256 = "1pwcjf9jqdiy8445r1xkazqa07xmapnn0ylyz7yzphci3ib66zh9";
  };

  buildInputs = [ attr acl zlib libuuid e2fsprogs lzo ];

  # for btrfs to get the rpath to libgcc_s, needed for pthread_cancel to work
  NIX_CFLAGS_LINK = "-lgcc_s";

  makeFlags = "prefix=$(out)";

  meta = {
    description = "Utilities for the btrfs filesystem";
    homepage = https://btrfs.wiki.kernel.org/;
    maintainers = [ stdenv.lib.maintainers.raskin ];
    platforms = stdenv.lib.platforms.linux;
  };
}

Fix btrfsprogs so nix detects the version

{ stdenv, fetchurl, attr, acl, zlib, libuuid, e2fsprogs, lzo }:

stdenv.mkDerivation rec {
  name = "btrfs-progs-3.12";

  src = fetchurl {
    url = "mirror://kernel/linux/kernel/people/mason/btrfs-progs/${name}.tar.xz";
    sha256 = "1pwcjf9jqdiy8445r1xkazqa07xmapnn0ylyz7yzphci3ib66zh9";
  };

  buildInputs = [ attr acl zlib libuuid e2fsprogs lzo ];

  # for btrfs to get the rpath to libgcc_s, needed for pthread_cancel to work
  NIX_CFLAGS_LINK = "-lgcc_s";

  makeFlags = "prefix=$(out)";

  meta = {
    description = "Utilities for the btrfs filesystem";
    homepage = https://btrfs.wiki.kernel.org/;
    maintainers = [ stdenv.lib.maintainers.raskin ];
    platforms = stdenv.lib.platforms.linux;
  };
}


# Edit this configuration file to define what should be installed on
# the system.  Help is available in the configuration.nix(5) man page
# or the NixOS manual available on virtual console 8 (Alt+F8).

{ config, pkgs, ... }:

{
  nixpkgs.config.firefox =
    { #enableGnomeExtensions = true;
      #enableGoogleTalkPlugin = true;
      enableAdobeFlash = true;
    };

  environment.systemPackages = with pkgs;
    [ # Shells
      zsh

      # Editors
      vim
      emacs

      # Browser
      firefoxWrapper

      # Development
      # (git.override { guiSupport = true; })
      git

      # Desktop Env
      dmenu

      # Bits of Gnome
      # gnome3.gnome_terminal
      evince

      # Terminal emulator
      termite

      # Admin
      gparted

      # Nix
      nix-repl
    ];

  #nix.binaryCaches = builtins.concatLists [ config.nix.binaryCaches.default [ "https://hydra.nixos.org/" "http://hydra.cryp.to" ] ];
  nix.binaryCaches = [ "http://cache.nixos.org/" "https://hydra.nixos.org/" "http://hydra.cryp.to" ];
}

Add a file more admin tools

# Edit this configuration file to define what should be installed on
# the system.  Help is available in the configuration.nix(5) man page
# or the NixOS manual available on virtual console 8 (Alt+F8).

{ config, pkgs, ... }:

{
  nixpkgs.config.firefox =
    { #enableGnomeExtensions = true;
      #enableGoogleTalkPlugin = true;
      enableAdobeFlash = true;
    };

  environment.systemPackages = with pkgs;
    [ # Shells
      zsh

      # Editors
      vim
      emacs

      # Browser
      firefoxWrapper

      # Development
      # (git.override { guiSupport = true; })
      git

      # Desktop Env
      dmenu

      # Bits of Gnome
      # gnome3.gnome_terminal
      evince

      # Terminal emulator
      termite

      # Admin
      acpi
      file
      gparted
      htop
      tree

      # Nix
      nix-repl
    ];

  #nix.binaryCaches = builtins.concatLists [ config.nix.binaryCaches.default [ "https://hydra.nixos.org/" "http://hydra.cryp.to" ] ];
  nix.binaryCaches = [ "http://cache.nixos.org/" "https://hydra.nixos.org/" "http://hydra.cryp.to" ];
}


{stdenv, fetchurl, gmp, static ? false}:

stdenv.mkDerivation rec {
  name = "isl-0.08";

  src = fetchurl {
    url = "http://www.kotnet.org/~skimo/isl/${name}.tar.bz2";
    sha256 = "16rqvajcp9x6j76mg9q6bprqkgsm1zprx50j90s6v996y7ww3j9l";
  };

  buildInputs = [ gmp ];

  dontDisableStatic = static;
  configureFlags =
    stdenv.lib.optionals static [ " --enable-static" "--disable-shared" ];

  meta = {
    homepage = http://www.kotnet.org/~skimo/isl/;
    license = "LGPLv2.1";
    description = "A library for manipulating sets and relations of integer points bounded by linear constraints.";
    maintainers = [ stdenv.lib.maintainers.shlevy ];
    platforms = stdenv.lib.platforms.all;
  };
}

Downgrade to 0.07 so that CLooG builds.

{stdenv, fetchurl, gmp, static ? false}:

stdenv.mkDerivation rec {
  name = "isl-0.07";             # CLooG 0.16.3 fails to build with ISL 0.08.

  src = fetchurl {
    url = "http://www.kotnet.org/~skimo/isl/${name}.tar.bz2";
    sha256 = "0kpxmvhrwwdygqqafqzjf9xiksq7paac2x24g9jhr3f9ajj3zkyx";
  };

  buildInputs = [ gmp ];

  dontDisableStatic = static;
  configureFlags =
    stdenv.lib.optionals static [ " --enable-static" "--disable-shared" ];

  meta = {
    homepage = http://www.kotnet.org/~skimo/isl/;
    license = "LGPLv2.1";
    description = "A library for manipulating sets and relations of integer points bounded by linear constraints.";
    maintainers = [ stdenv.lib.maintainers.shlevy ];
    platforms = stdenv.lib.platforms.all;
  };
}


{ config, lib, pkgs, ... }:

with lib;

{

  imports =
    [ ../../../modules/installer/cd-dvd/channel.nix
      ../../../modules/virtualisation/amazon-image.nix
    ];

  system.build.amazonImage = import ../../../lib/make-disk-image.nix {
    inherit pkgs lib config;
    partitioned = config.ec2.hvm;
    diskSize = 8192;
    configFile = pkgs.writeText "configuration.nix"
      ''
        {
          imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];
          ${optionalString config.ec2.hvm ''
            ec2.hvm = true;
          ''}
        }
      '';
  };

}

Make EBS volumes much smaller

{ config, lib, pkgs, ... }:

with lib;

{

  imports =
    [ ../../../modules/installer/cd-dvd/channel.nix
      ../../../modules/virtualisation/amazon-image.nix
    ];

  system.build.amazonImage = import ../../../lib/make-disk-image.nix {
    inherit pkgs lib config;
    partitioned = config.ec2.hvm;
    diskSize = if config.ec2.hvm then 2048 else 8192;
    configFile = pkgs.writeText "configuration.nix"
      ''
        {
          imports = [ <nixpkgs/nixos/modules/virtualisation/amazon-image.nix> ];
          ${optionalString config.ec2.hvm ''
            ec2.hvm = true;
          ''}
        }
      '';
  };

}


{ stdenv, fetchFromGitHub, libX11, imlib2, giflib, libexif }:

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

  src = fetchFromGitHub {
    owner = "muennich";
    repo = "sxiv";
    rev = "v${version}";
    sha256 = "1f4gz1qjhb44bbb3q5fqk439zyipkwnr19zhg89yq2pgmzzzqr2h";
  };

  postUnpack = ''
    substituteInPlace $sourceRoot/Makefile \
      --replace /usr/local $out
  '';

  buildInputs = [ libX11 imlib2 giflib libexif ];
  meta = {
    description = "Simple X Image Viewer";
    homepage = "https://github.com/muennich/sxiv";
    license = stdenv.lib.licenses.gpl2Plus;
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [ fuuzetsu ];
  };
}

Add support for custom config

{ stdenv, fetchFromGitHub, libX11, imlib2, giflib, libexif, conf ? null }:

with stdenv.lib;

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

  src = fetchFromGitHub {
    owner = "muennich";
    repo = "sxiv";
    rev = "v${version}";
    sha256 = "1f4gz1qjhb44bbb3q5fqk439zyipkwnr19zhg89yq2pgmzzzqr2h";
  };

  postUnpack = ''
    substituteInPlace $sourceRoot/Makefile \
      --replace /usr/local $out
  '';

  configFile = optionalString (conf!=null) (builtins.toFile "config.def.h" conf);
  preBuild = optionalString (conf!=null) "cp ${configFile} config.def.h";

  buildInputs = [ libX11 imlib2 giflib libexif ];

  meta = {
    description = "Simple X Image Viewer";
    homepage = "https://github.com/muennich/sxiv";
    license = stdenv.lib.licenses.gpl2Plus;
    platforms = stdenv.lib.platforms.linux;
    maintainers = with maintainers; [ jfrankenau fuuzetsu ];
  };
}