{ stdenv
, fetchPypi
, python
, wrapPython
, unzip
}:

# Should use buildPythonPackage here somehow
stdenv.mkDerivation rec {
  pname = "setuptools";
  version = "38.2.3";
  name = "${python.libPrefix}-${pname}-${version}";
  pythonModule = python;

  src = fetchPypi {
    inherit pname version;
    extension = "zip";
    sha256 = "124jlg72bbk2xxv5wqbwcl4h5cdslslzk92rxjxiplg79l499hv3";
  };

  buildInputs = [ python wrapPython unzip ];
  doCheck = false;  # requires pytest
  installPhase = ''
      dst=$out/${python.sitePackages}
      mkdir -p $dst
      export PYTHONPATH="$dst:$PYTHONPATH"
      ${python.interpreter} setup.py install --prefix=$out
      wrapPythonPrograms
  '';

  pythonPath = [];

  meta = with stdenv.lib; {
    description = "Utilities to facilitate the installation of Python packages";
    homepage = https://pypi.python.org/pypi/setuptools;
    license = with licenses; [ psfl zpl20 ];
    platforms = platforms.all;
    priority = 10;
  };
}

Revert "pythonPackages.setuptools: make compatible with hasPythonModule"

{ stdenv
, fetchPypi
, python
, wrapPython
, unzip
}:

# Should use buildPythonPackage here somehow
stdenv.mkDerivation rec {
  pname = "setuptools";
  version = "38.2.3";
  name = "${python.libPrefix}-${pname}-${version}";

  src = fetchPypi {
    inherit pname version;
    extension = "zip";
    sha256 = "124jlg72bbk2xxv5wqbwcl4h5cdslslzk92rxjxiplg79l499hv3";
  };

  buildInputs = [ python wrapPython unzip ];
  doCheck = false;  # requires pytest
  installPhase = ''
      dst=$out/${python.sitePackages}
      mkdir -p $dst
      export PYTHONPATH="$dst:$PYTHONPATH"
      ${python.interpreter} setup.py install --prefix=$out
      wrapPythonPrograms
  '';

  pythonPath = [];

  meta = with stdenv.lib; {
    description = "Utilities to facilitate the installation of Python packages";
    homepage = https://pypi.python.org/pypi/setuptools;
    license = with licenses; [ psfl zpl20 ];
    platforms = platforms.all;
    priority = 10;
  };
}


{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/f366af7a1b3891d9370091ab03150d3a6ee138fa.tar.gz") { } }:
with pkgs;
stdenv.mkDerivation {
  name = "advent-of-code-2019";

  buildInputs = [
    cargo
    libiconv
    rls
    rustPlatform.rust.rustc
    rustPlatform.rustcSrc
    rustfmt
  ];
}

Add ncurses as a dependency.

{ pkgs ? import (fetchTarball "https://github.com/NixOS/nixpkgs/archive/f366af7a1b3891d9370091ab03150d3a6ee138fa.tar.gz") { } }:
with pkgs;
stdenv.mkDerivation {
  name = "advent-of-code-2019";

  buildInputs = [
    cargo
    libiconv
    ncurses
    rls
    rustPlatform.rust.rustc
    rustPlatform.rustcSrc
    rustfmt
  ];
}


{ stdenv, lib, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  name = "consul-alerts-${version}";
  version = "0.5.0";
  rev = "v${version}";

  goPackagePath = "github.com/AcalephStorage/consul-alerts";

  goDeps = ./deps.nix;

  src = fetchFromGitHub {
    inherit rev;
    owner = "AcalephStorage";
    repo = "consul-alerts";
    sha256 = "0dff2cpk3lkgjsh97rvlrpacpka0kwm29691diyvj7lb9ydzlx3r";
  };
}

Add `meta` and myself as maintainer

{ stdenv, lib, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  name = "consul-alerts-${version}";
  version = "0.5.0";
  rev = "v${version}";

  goPackagePath = "github.com/AcalephStorage/consul-alerts";

  goDeps = ./deps.nix;

  src = fetchFromGitHub {
    inherit rev;
    owner = "AcalephStorage";
    repo = "consul-alerts";
    sha256 = "0dff2cpk3lkgjsh97rvlrpacpka0kwm29691diyvj7lb9ydzlx3r";
  };

  meta = with stdenv.lib; {
    description = "An extendable open source continuous integration server";
    homepage = https://github.com/AcalephStorage/consul-alerts;
    # As per README
    platforms = platforms.linux ++ platforms.freebsd ++ platforms.darwin;
    license = licenses.gpl2;
    maintainers = with maintainers; [ nh2 ];
  };
}


args :
let
  lib = args.lib;
  fetchurl = args.fetchurl;

  version = lib.attrByPath ["version"] "0.9.1" args;
  buildInputs = with args; [
    libtool libjpeg openssl libX11 libXdamage xproto damageproto
    xextproto libXext fixesproto libXfixes xineramaproto libXinerama
    libXrandr randrproto libXtst zlib
  ];
in
rec {
  src = fetchurl {
    url = "http://downloads.sourceforge.net/libvncserver/LibVNCServer-${version}.tar.gz";
    sha256 = "10pjhfv0vnfphy4bghygm1bfz983ca6y91mmpsyn1wy16zyagg8g";
  };

  inherit buildInputs;
  configureFlags = [];

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

  name = "libvncserver-" + version;
  meta = {
    description = "VNC server library";
  };
}

Advance to version 0.9.9. Note: Fixes KDE4.10 build.

args :
let
  lib = args.lib;
  fetchurl = args.fetchurl;

  version = lib.attrByPath ["version"] "0.9.9" args;
  buildInputs = with args; [
    libtool libjpeg openssl libX11 libXdamage xproto damageproto
    xextproto libXext fixesproto libXfixes xineramaproto libXinerama
    libXrandr randrproto libXtst zlib
  ];
in
rec {
  src = fetchurl {
    url = "http://downloads.sourceforge.net/libvncserver/LibVNCServer-${version}.tar.gz";
    sha256 = "1y83z31wbjivbxs60kj8a8mmjmdkgxlvr2x15yz95yy24lshs1ng";
  };

  inherit buildInputs;
  configureFlags = [];

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

  name = "libvncserver-" + version;
  meta = {
    description = "VNC server library";
  };
}


{ stdenv, fetchurl, file, zlib, libgnurx }:

stdenv.mkDerivation rec {
  name = "file-${version}";
  version = "5.36";

  src = fetchurl {
    urls = [
      "ftp://ftp.astron.com/pub/file/${name}.tar.gz"
      "https://distfiles.macports.org/file/${name}.tar.gz"
    ];
    sha256 = "0ya330cdkvfi2d28h8gvhghj4gnhysmifmryysl0a97xq2884q7v";
  };

  nativeBuildInputs = stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) file;
  buildInputs = [ zlib ]
              ++ stdenv.lib.optional stdenv.hostPlatform.isWindows libgnurx;

  doCheck = true;

  makeFlags = if stdenv.hostPlatform.isWindows then "FILE_COMPILE=file"
              else null;

  meta = with stdenv.lib; {
    homepage = https://darwinsys.com/file;
    description = "A program that shows the type of files";
    license = licenses.bsd2;
    platforms = platforms.all;
  };
}

Revert "file: 5.35 -> 5.36"

{ stdenv, fetchurl, file, zlib, libgnurx }:

stdenv.mkDerivation rec {
  name = "file-${version}";
  version = "5.35";

  src = fetchurl {
    urls = [
      "ftp://ftp.astron.com/pub/file/${name}.tar.gz"
      "https://distfiles.macports.org/file/${name}.tar.gz"
    ];
    sha256 = "0ijm1fabm68ykr1zbx0bxnka5jr3n42sj8y5mbkrnxs0fj0mxi1h";
  };

  nativeBuildInputs = stdenv.lib.optional (stdenv.hostPlatform != stdenv.buildPlatform) file;
  buildInputs = [ zlib ]
              ++ stdenv.lib.optional stdenv.hostPlatform.isWindows libgnurx;

  doCheck = true;

  makeFlags = if stdenv.hostPlatform.isWindows then "FILE_COMPILE=file"
              else null;

  meta = with stdenv.lib; {
    homepage = https://darwinsys.com/file;
    description = "A program that shows the type of files";
    license = licenses.bsd2;
    platforms = platforms.all;
  };
}


{ config, pkgs, ... }:

{
  nixpkgs.config.allowUnfree = true;

  nixpkgs.overlays = [ (import ./overlay) ];

  nix.useSandbox = true;

  system.autoUpgrade = {
    enable = true;
    channel = https://nixos.org/channels/nixos-unstable;
    dates = "0/1:00:00"; # means "every hour on the hour"
  };

  # run nix-collect-garbage automatically
  nix.gc = {
    automatic = true;
    dates = "0/1:00:00"; # means "every hour on the hour"
  };

  system.stateVersion = "unstable";
}

Remove automatic nixos-rebuild switch and nix-collect-garbage services. Could they be the cause of the firefox window-switching issue?

{ config, pkgs, ... }:

{
  nixpkgs.config.allowUnfree = true;

  nixpkgs.overlays = [ (import ./overlay) ];

  nix.useSandbox = true;

  system.stateVersion = "unstable";
}


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

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

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

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

  configurePhase = "";

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

  installPhase = ":";

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

Fix oiio build; maybe will fix blender build

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

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

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

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

  cmakeFlags = [
    "-DUSE_PYTHON=OFF"
  ];

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

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


{ stdenv, fetchurl, openssl }:

stdenv.mkDerivation {
  name = "stunnel-4.56";

  src = fetchurl {
    url = http://www.stunnel.org/downloads/stunnel-4.56.tar.gz;
    sha256 = "14qjhwfa0y17ipnd5mc970vfmralvgaxfl6fk0rl91vdwbxjrblw";
  };

  buildInputs = [openssl];

  meta = {
    description = "Stunnel - Universal SSL wrapper";
    homepage = http://www.stunnel.org/;
    license = "GPLv2";
  };
}

Add explicit openssl reference (latest stunnel version did not build for me otherwise)

{ stdenv, fetchurl, openssl }:

stdenv.mkDerivation {
  name = "stunnel-4.56";

  src = fetchurl {
    url = http://www.stunnel.org/downloads/stunnel-4.56.tar.gz;
    sha256 = "14qjhwfa0y17ipnd5mc970vfmralvgaxfl6fk0rl91vdwbxjrblw";
  };

  buildInputs = [openssl];

  configureFlags = [
    "--with-ssl=${openssl}"
  ];

  meta = {
    description = "Stunnel - Universal SSL wrapper";
    homepage = http://www.stunnel.org/;
    license = "GPLv2";
  };
}


{ lib, pkgs, fetchFromGitHub, python3Packages, nix-prefetch-scripts }:
python3Packages.buildPythonApplication rec {
  version = "0.2.2";
  name = "nix-update-source-${version}";
  src = fetchFromGitHub {
    owner = "timbertson";
    repo = "nix-update-source";
    rev = "version-${version}";
    sha256 = "0liigkr37ib2xy269bcp53ivpir4mpg6lzwnfrsqc4kbkz3l16gg";
  };
  propagatedBuildInputs = [ nix-prefetch-scripts ];
  passthru = {
    fetch = path:
      let
        fetchers = {
          # whitelist of allowed fetchers
          inherit (pkgs) fetchgit fetchurl fetchFromGitHub;
        };
        json = lib.importJSON path;
        fetchFn = builtins.getAttr json.fetch.fn fetchers;
        src = fetchFn json.fetch.args;
      in
      json // json.fetch // { inherit src; };
  };
  meta = {
    description = "Utility to autimate updating of nix derivation sources";
    maintainers = with lib.maintainers; [ timbertson ];
  };
}

Revert "nix-update-source: 0.2.1 -> 0.2.2"

{ lib, pkgs, fetchFromGitHub, python3Packages, nix-prefetch-scripts }:
python3Packages.buildPythonApplication rec {
  version = "0.2.1";
  name = "nix-update-source-${version}";
  src = fetchFromGitHub {
    owner = "timbertson";
    repo = "nix-update-source";
    rev = "version-${version}";
    sha256 = "1w3aj0kjp8zhxkzqxnm5srrsqsvrmxhn4sqkr4kjffh61jg8jq8a";
  };
  propagatedBuildInputs = [ nix-prefetch-scripts ];
  passthru = {
    fetch = path:
      let
        fetchers = {
          # whitelist of allowed fetchers
          inherit (pkgs) fetchgit fetchurl fetchFromGitHub;
        };
        json = lib.importJSON path;
        fetchFn = builtins.getAttr json.fetch.fn fetchers;
        src = fetchFn json.fetch.args;
      in
      json // { inherit src; };
  };
  meta = {
    description = "Utility to autimate updating of nix derivation sources";
    maintainers = with lib.maintainers; [ timbertson ];
  };
}


{ stdenv, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args:

let
  version = "4.12";
  revision = "a";
  sha256 = "1vh104y40b7lkmgdbr0rd56i6qydinijfnnzn5aj5fi4n0n750v6";
in

import ./generic.nix (args // {
  version = "${version}-${revision}";
  extraMeta.branch = "4.12";
  modDirVersion = "${version}.0";

  src = fetchFromGitHub {
    inherit sha256;
    owner = "copperhead";
    repo = "linux-hardened";
    rev = "${version}.${revision}";
  };

  kernelPatches = args.kernelPatches;

  features.iwlwifi = true;
  features.efiBootStub = true;
  features.needsCifsUtils = true;
  features.netfilterRPFilter = true;
} // (args.argsOverride or {}))

Revert "linux-copperhead: 4.11.8.a -> 4.12.a"

{ stdenv, hostPlatform, fetchFromGitHub, perl, buildLinux, ... } @ args:

let
  version = "4.11.8";
  revision = "a";
  sha256 = "02wy5gpgl2hz06dlqcgg9i3ydnxkyw0m1350vc5xyh6ld5r7jnn5";
in

import ./generic.nix (args // {
  version = "${version}-${revision}";
  extraMeta.branch = "4.11";
  modDirVersion = version;

  src = fetchFromGitHub {
    inherit sha256;
    owner = "copperhead";
    repo = "linux-hardened";
    rev = "${version}.${revision}";
  };

  kernelPatches = args.kernelPatches;

  features.iwlwifi = true;
  features.efiBootStub = true;
  features.needsCifsUtils = true;
  features.netfilterRPFilter = true;
} // (args.argsOverride or {}))


{ buildDunePackage, lib, fetchurl, ocaml }:

buildDunePackage rec {
  pname = "stdlib-shims";
  version = "0.2.0";
  src = fetchurl {
    url = "https://github.com/ocaml/${pname}/releases/download/${version}/${pname}-${version}.tbz";
    sha256 = "0nb5flrczpqla1jy2pcsxm06w4jhc7lgbpik11amwhfzdriz0n9c";
  };
  minimumOCamlVersion = "4.02";
  doCheck = true;
  meta = {
    description = "Shims for forward-compatibility between versions of the OCaml standard library";
    homepage = "https://github.com/ocaml/stdlib-shims";
    inherit (ocaml.meta) license;
    maintainers = [ lib.maintainers.vbgl ];
  };
}

Revert "ocamlPackages.stdlib-shims: 0.1.0 -> 0.2.0"

{ buildDunePackage, lib, fetchurl, ocaml }:

buildDunePackage rec {
  pname = "stdlib-shims";
  version = "0.1.0";
  src = fetchurl {
    url = "https://github.com/ocaml/${pname}/releases/download/${version}/${pname}-${version}.tbz";
    sha256 = "1jv6yb47f66239m7hsz7zzw3i48mjpbvfgpszws48apqx63wjwsk";
  };
  minimumOCamlVersion = "4.02";
  doCheck = true;
  meta = {
    description = "Shims for forward-compatibility between versions of the OCaml standard library";
    homepage = "https://github.com/ocaml/stdlib-shims";
    inherit (ocaml.meta) license;
    maintainers = [ lib.maintainers.vbgl ];
  };
}


{ stdenv
, lib
, fetchPypi
, buildPythonPackage
, isPy3k
, python
}:

buildPythonPackage rec {
  pname = "docutils";
  version = "0.18.1";

  src = fetchPypi {
    inherit pname version;
    sha256 = "679987caf361a7539d76e584cbeddc311e3aee937877c87346f31debc63e9d06";
  };

  # Only Darwin needs LANG, but we could set it in general.
  # It's done here conditionally to prevent mass-rebuilds.
  checkPhase = lib.optionalString (isPy3k && stdenv.isDarwin) ''LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8" '' + ''
    ${python.interpreter} test/alltests.py
  '';

  # Create symlinks lacking a ".py" suffix, many programs depend on these names
  postFixup = ''
    for f in $out/bin/*.py; do
      ln -s $(basename $f) $out/bin/$(basename $f .py)
    done
  '';

  meta = with lib; {
    description = "Python Documentation Utilities";
    homepage = "http://docutils.sourceforge.net/";
    license = with licenses; [ publicDomain bsd2 psfl gpl3Plus ];
    maintainers = with maintainers; [ AndersonTorres ];
  };
}

Revert "python3Packages.docutils: 0.17.1 -> 0.18.1"

{ stdenv
, lib
, fetchPypi
, buildPythonPackage
, isPy3k
, python
}:

buildPythonPackage rec {
  pname = "docutils";
  version = "0.17.1";

  src = fetchPypi {
    inherit pname version;
    sha256 = "686577d2e4c32380bb50cbb22f575ed742d58168cee37e99117a854bcd88f125";
  };

  # Only Darwin needs LANG, but we could set it in general.
  # It's done here conditionally to prevent mass-rebuilds.
  checkPhase = lib.optionalString (isPy3k && stdenv.isDarwin) ''LANG="en_US.UTF-8" LC_ALL="en_US.UTF-8" '' + ''
    ${python.interpreter} test/alltests.py
  '';

  # Create symlinks lacking a ".py" suffix, many programs depend on these names
  postFixup = ''
    for f in $out/bin/*.py; do
      ln -s $(basename $f) $out/bin/$(basename $f .py)
    done
  '';

  meta = with lib; {
    description = "Python Documentation Utilities";
    homepage = "http://docutils.sourceforge.net/";
    license = with licenses; [ publicDomain bsd2 psfl gpl3Plus ];
    maintainers = with maintainers; [ AndersonTorres ];
  };
}


with import <nixpkgs> {}; {
    TankDriverEnv = stdenv.mkDerivation {
        name = "TankDriver";
        buildInputs = [ mesa mono dotnetPackages.Nuget xorg.libX11 ];
        LD_LIBRARY_PATH="${xorg.libX11}/lib:${mesa}/lib";
    };
}

Use mono 4.6 available since 16.09

with import <nixpkgs> {}; {
    TankDriverEnv = stdenv.mkDerivation {
        name = "TankDriver";
        buildInputs = [ mesa mono46 dotnetPackages.Nuget xorg.libX11 ];
        LD_LIBRARY_PATH="${xorg.libX11}/lib:${mesa}/lib";
    };
}


{ stdenv, fetchurl, libogg, pkgconfig }:

stdenv.mkDerivation rec {
  name = "libvorbis-1.3.5";

  src = fetchurl {
    url = "http://downloads.xiph.org/releases/vorbis/${name}.tar.xz";
    sha256 = "1lg1n3a6r41492r7in0fpvzc7909mc5ir9z0gd3qh2pz4yalmyal";
  };

  nativeBuildInputs = [ pkgconfig ];
  propagatedBuildInputs = [ libogg ];

  doCheck = true;

  meta = with stdenv.lib; {
    homepage = http://xiph.org/vorbis/;
    license = licenses.bsd3;
    maintainers = [ maintainers.emery ];
    platforms = platforms.all;
  };
}

Revert "libvorbis: propagate libogg dependency"

{ stdenv, fetchurl, libogg, pkgconfig }:

stdenv.mkDerivation rec {
  name = "libvorbis-1.3.5";

  src = fetchurl {
    url = "http://downloads.xiph.org/releases/vorbis/${name}.tar.xz";
    sha256 = "1lg1n3a6r41492r7in0fpvzc7909mc5ir9z0gd3qh2pz4yalmyal";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ libogg ];

  doCheck = true;

  meta = with stdenv.lib; {
    homepage = http://xiph.org/vorbis/;
    license = licenses.bsd3;
    maintainers = [ maintainers.emery ];
    platforms = platforms.all;
  };
}


{ pkgs }:
let
  marge = pkgs.callPackage ./marge.nix {};
  version = marge.version;
  basicShadow =
    # minimal user setup, so ssh won't whine 'No user exists for uid 0'
    pkgs.runCommand "basic-shadow-setup" {}
      ''
        mkdir -p $out
        cd $out
        mkdir -p root/.ssh
        mkdir -p etc/pam.d
        echo "root:x:0:0::/root:/bin/sh" >etc/passwd
        echo "root:!x:::::::" > etc/shadow
        echo "root:x:0:" > etc/group
        echo "root:x::" > etc/gshadow
        cat > etc/pam.d/other <<EOF
        account sufficient pam_unix.so
        auth sufficient pam_rootok.so
        password requisite pam_unix.so nullok sha512
        session required pam_unix.so
        EOF
      '';
in
  pkgs.dockerTools.buildImage {
    name = "smarkets/marge-bot";
    tag = "${version}";
    contents =
      with pkgs; [
        basicShadow
        bash
        coreutils
        git
        glibcLocales
        openssh
      ] ++ [ marge ];
    config = {
      Entrypoint = [ "/bin/marge.app" ];
      Env = ["LANG=en_US.UTF-8" ''LOCALE_ARCHIVE=/lib/locale/locale-archive''];
    };
  }

Make the docker image smaller; cosmetics

{ pkgs }:
let
  marge = pkgs.callPackage ./marge.nix {};
  version = marge.version;
  basicShadow =
    # minimal user setup, so ssh won't whine 'No user exists for uid 0'
    pkgs.runCommand "basic-shadow-setup" {}
      ''
        mkdir -p $out
        cd $out
        mkdir -p root/.ssh
        mkdir -p etc/pam.d
        echo "root:x:0:0::/root:/bin/sh" >etc/passwd
        echo "root:!x:::::::" >etc/shadow
        echo "root:x:0:" >etc/group
        echo "root:x::" >etc/gshadow
        cat >etc/pam.d/other <<\EOF
        account sufficient pam_unix.so
        auth sufficient pam_rootok.so
        password requisite pam_unix.so nullok sha512
        session required pam_unix.so
        EOF
      '';
in
  pkgs.dockerTools.buildImage {
    name = "smarkets/marge-bot";
    tag = "${version}";
    contents =
      with pkgs; [
        basicShadow
        busybox
        gitMinimal
        openssh
      ] ++ [ marge ];
    config = {
      Entrypoint = [ "/bin/marge.app" ];
      Env = ["LANG=en_US.UTF-8" ''LOCALE_ARCHIVE=/lib/locale/locale-archive''];
    };
  }


{ nixpkgs ? (fetchTarball "channel:nixos-18.09")
}:

with nixpkgs;

let

  # Create an sdist given a derivation.
  # Should add an sdist and wheel output to buildPythonPackage
  create-sdist = drv:
    drv.overridePythonAttrs(oldAttrs: with oldAttrs; rec {
      name = "${pname}-${version}-sdist";

      postBuild = ''
        rm -rf dist
        ${drv.pythonModule.interpreter} nix_run_setup sdist

      '';

      installPhase = ''
        mkdir -p $out
        mv dist/*.tar.gz $out/
      '';

      fixupPhase = "true";
      doCheck = false;
      propagatedBuildInputs = [];
    });

  overrides = self: super: {
    acoustics = super.callPackage ./default.nix {
      development = true;
    };
  };

  overlay = self: super: {
    python36 = super.python36.override{packageOverrides=overrides;};
    python37 = super.python37.override{packageOverrides=overrides;};
  };

in import nixpkgs {
  overlays = [ overlay ];
}

Build against nixos-19.03 by default

{ nixpkgs ? (fetchTarball "channel:nixos-19.03")
}:

with nixpkgs;

let

  # Create an sdist given a derivation.
  # Should add an sdist and wheel output to buildPythonPackage
  create-sdist = drv:
    drv.overridePythonAttrs(oldAttrs: with oldAttrs; rec {
      name = "${pname}-${version}-sdist";

      postBuild = ''
        rm -rf dist
        ${drv.pythonModule.interpreter} nix_run_setup sdist

      '';

      installPhase = ''
        mkdir -p $out
        mv dist/*.tar.gz $out/
      '';

      fixupPhase = "true";
      doCheck = false;
      propagatedBuildInputs = [];
    });

  overrides = self: super: {
    acoustics = super.callPackage ./default.nix {
      development = true;
    };
  };

  overlay = self: super: {
    python36 = super.python36.override{packageOverrides=overrides;};
    python37 = super.python37.override{packageOverrides=overrides;};
  };

in import nixpkgs {
  overlays = [ overlay ];
}


{ config, pkgs, ... }:
{
  services.openssh.enable = true;
  virtualisation.docker.enable = true;

  environment.systemPackages = with pkgs; [
    iputils
    openssl bind
    curl wget
    git
    neovim
    tree
    jq
  ];
}

Add `direnv` package and `nixFlakes` to the base system

{ config, pkgs, ... }:
{
  services.openssh.enable = true;
  virtualisation.docker.enable = true;

  nix = {
   package = pkgs.nixFlakes;
   extraOptions = ''
     experimental-features = nix-command flakes
   '';
  };

  environment.systemPackages = with pkgs; [
    iputils
    openssl bind
    curl wget
    git
    neovim
    tree
    jq
    direnv
  ];
}


{ stdenv, fetchFromGitHub }:

stdenv.mkDerivation rec {
  version = "2c11fbfcee";

  package-name = "numix-icon-theme";

  name = "${package-name}-20150302";

  src = fetchFromGitHub {
    owner = "numixproject";
    repo = package-name;
    rev = version;
    sha256 = "1bjh2j4vqk9s31syv7ig3hwpp5z0n6sx74iz332y0wdz6ngj5x08";
  };

  dontBuild = true;

  installPhase = ''
    install -dm 755 $out/share/icons
    cp -dr --no-preserve='ownership' Numix{,-Light} $out/share/icons/
  '';

  meta = {
    description = "Numix icon theme";
    homepage = https://numixproject.org;
    license = stdenv.lib.licenses.gpl3;
    platforms = stdenv.lib.platforms.all;
  };
}

Add myself as a maintainer

{ stdenv, fetchFromGitHub }:

stdenv.mkDerivation rec {
  version = "2c11fbfcee";

  package-name = "numix-icon-theme";

  name = "${package-name}-20150302";

  src = fetchFromGitHub {
    owner = "numixproject";
    repo = package-name;
    rev = version;
    sha256 = "1bjh2j4vqk9s31syv7ig3hwpp5z0n6sx74iz332y0wdz6ngj5x08";
  };

  dontBuild = true;

  installPhase = ''
    install -dm 755 $out/share/icons
    cp -dr --no-preserve='ownership' Numix{,-Light} $out/share/icons/
  '';

  meta = with stdenv.lib; {
    description = "Numix icon theme";
    homepage = https://numixproject.org;
    license = licenses.gpl3;
    platforms = platforms.all;
    maintainers = with maintainers; [ romildo jgeerds ];
  };
}


{ stdenv, fetchurl }:

let version = "1.6.0"; in

stdenv.mkDerivation {
  name = "geoip-${version}";

  src = fetchurl {
    url = "http://geolite.maxmind.com/download/geoip/api/c/GeoIP-${version}.tar.gz";
    sha256 = "0dd6si4cvip73kxdn43apg6yygvaf7dnk5awqfg9w2fd2ll0qnh7";
  };

  meta = {
    description = "Geolocation API";
    maintainers = [ stdenv.lib.maintainers.raskin ];
    license = stdenv.lib.licenses.lgpl21;
    platforms = stdenv.lib.platforms.linux;
  };
}

Make geoip buildable on any Unix

{ stdenv, fetchurl }:

let version = "1.6.0"; in

stdenv.mkDerivation {
  name = "geoip-${version}";

  src = fetchurl {
    url = "http://geolite.maxmind.com/download/geoip/api/c/GeoIP-${version}.tar.gz";
    sha256 = "0dd6si4cvip73kxdn43apg6yygvaf7dnk5awqfg9w2fd2ll0qnh7";
  };

  meta = {
    description = "Geolocation API";
    maintainers = [ stdenv.lib.maintainers.raskin ];
    license = stdenv.lib.licenses.lgpl21;
    platforms = stdenv.lib.platforms.unix;
  };
}


{ stdenv, fetchurl, jdk, gtk2, xulrunner, zip, pkgconfig, perl, npapi_sdk }:

stdenv.mkDerivation rec {
  name = "icedtea-web-${version}";

  version = "1.4.2";

  src = fetchurl {
    url = "http://icedtea.wildebeest.org/download/source/${name}.tar.gz";

    sha256 = "0bfw4icxjfkdxqmiqgp9lfs1ca9rydl57g3yhlxrif0fpzyyb3fl";
  };

  buildInputs = [ gtk2 xulrunner zip pkgconfig npapi_sdk ];

  preConfigure = ''
    substituteInPlace javac.in --replace '#!/usr/bin/perl' '#!${perl}/bin/perl'
  '';

  configureFlags = [
    "--with-jdk-home=${jdk}"
  ];

  mozillaPlugin = "/lib";

  meta = {
    description = "Java web browser plugin and an implementation of Java Web Start";
    longDescription = ''
      A Free Software web browser plugin running applets written in the Java
      programming language and an implementation of Java Web Start, originally
      based on the NetX project.
    '';
    homepage = http://icedtea.classpath.org/wiki/IcedTea-Web;
    maintainers = with stdenv.lib.maintainers; [ wizeman ];
    platforms = stdenv.lib.platforms.linux;
  };
}

Update from 1.4.2 -> 1.5

{ stdenv, fetchurl, jdk, gtk2, xulrunner, zip, pkgconfig, perl, npapi_sdk }:

stdenv.mkDerivation rec {
  name = "icedtea-web-${version}";

  version = "1.5";

  src = fetchurl {
    url = "http://icedtea.wildebeest.org/download/source/${name}.tar.gz";

    sha256 = "0bbwa944kaam0r8ldlqrrj9z9zj54v6zdc3q663ck59shw5z828w";
  };

  buildInputs = [ gtk2 xulrunner zip pkgconfig npapi_sdk ];

  preConfigure = ''
    substituteInPlace javac.in --replace '#!/usr/bin/perl' '#!${perl}/bin/perl'
  '';

  configureFlags = [
    "--with-jdk-home=${jdk}"
  ];

  mozillaPlugin = "/lib";

  meta = {
    description = "Java web browser plugin and an implementation of Java Web Start";
    longDescription = ''
      A Free Software web browser plugin running applets written in the Java
      programming language and an implementation of Java Web Start, originally
      based on the NetX project.
    '';
    homepage = http://icedtea.classpath.org/wiki/IcedTea-Web;
    maintainers = with stdenv.lib.maintainers; [ wizeman ];
    platforms = stdenv.lib.platforms.linux;
  };
}


{ fetchFromGitHub, stdenv, pythonPackages, gtk3, gobjectIntrospection, libnotify, gst_all_1 }:

pythonPackages.buildPythonPackage rec {
  name = "pithos-${version}";
  version = "1.1.1";

  src = fetchFromGitHub {
    owner = "pithos";
    repo  = "pithos";
    rev = version;
    sha256 = "0373z7g1wd3g1xl8m4ipx5n2ka67a2wcn387nyk8yvgdikm14jm3";
  };

  postPatch = ''
    substituteInPlace setup.py --replace "/usr/share" "$out/share"
  '';

  propagatedBuildInputs =
    [ gtk3 gobjectIntrospection libnotify ] ++
    (with gst_all_1; [ gstreamer gst-plugins-base gst-plugins-good gst-plugins-ugly gst-plugins-bad ]) ++
    (with pythonPackages; [ pygobject3 pylast ]);

  postInstall = ''
    wrapProgram "$out/bin/pithos" \
      --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0" \
      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH"
  '';

  meta = with stdenv.lib; {
    description = "Pandora Internet Radio player for GNOME";
    homepage = http://pithos.github.io/;
    license = licenses.gpl3;
    maintainers = with maintainers; [ obadz jgeerds ];
  };
}

Use https url in meta.homepage

{ fetchFromGitHub, stdenv, pythonPackages, gtk3, gobjectIntrospection, libnotify, gst_all_1 }:

pythonPackages.buildPythonPackage rec {
  name = "pithos-${version}";
  version = "1.1.1";

  src = fetchFromGitHub {
    owner = "pithos";
    repo  = "pithos";
    rev = version;
    sha256 = "0373z7g1wd3g1xl8m4ipx5n2ka67a2wcn387nyk8yvgdikm14jm3";
  };

  postPatch = ''
    substituteInPlace setup.py --replace "/usr/share" "$out/share"
  '';

  propagatedBuildInputs =
    [ gtk3 gobjectIntrospection libnotify ] ++
    (with gst_all_1; [ gstreamer gst-plugins-base gst-plugins-good gst-plugins-ugly gst-plugins-bad ]) ++
    (with pythonPackages; [ pygobject3 pylast ]);

  postInstall = ''
    wrapProgram "$out/bin/pithos" \
      --prefix GST_PLUGIN_SYSTEM_PATH_1_0 : "$GST_PLUGIN_SYSTEM_PATH_1_0" \
      --prefix GI_TYPELIB_PATH : "$GI_TYPELIB_PATH"
  '';

  meta = with stdenv.lib; {
    description = "Pandora Internet Radio player for GNOME";
    homepage = https://pithos.github.io/;
    license = licenses.gpl3;
    maintainers = with maintainers; [ obadz jgeerds ];
  };
}


let

  # In order to get the hash of another tarball, run: `nix-prefetch-url --unpack <url>`
  pkgs =
    builtins.fetchTarball {
      name = "nixpkgs-2018-10-07";
      url = https://github.com/nixos/nixpkgs/archive/865cbd380d2568806c6e46c9a4bc746af7ec13c9.tar.gz;
      sha256 = "0r3gj1rci2ag6k8g5wcz1m4l6brvzgbfz92kpl74mrh7kjdy1m3p";
    };

in

  with (import pkgs {});

let

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

  deps = [ cmark curl gcc gmp libsigsegv meson ncurses ninja pkgconfig zlib
           re2c openssl ];

  isGitDir = (path: type: type != "directory" || baseNameOf path != ".git");

in

  stdenv.mkDerivation {
    name = "urbit";

    src = builtins.filterSource isGitDir ./.;

    buildInputs = osxdeps ++ deps;

    mesonFlags = "-Dnix=true";

    NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-framework CoreServices";
  }

Use fetchGit instead of fetchTarball to get nixpkgs.

let

  pkgs =
    builtins.fetchGit {
      name = "nixpkgs-2018-11-13";
      url = https://github.com/nixos/nixpkgs/;
      rev = "695a3d4254545968fc3015142c5299c0da5ca0a9";
    };

in

  with (import pkgs {});

let

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

  deps = [ cmark curl gcc gmp libsigsegv meson ncurses ninja pkgconfig zlib
           re2c openssl ];

  isGitDir = (path: type: type != "directory" || baseNameOf path != ".git");

in

  stdenv.mkDerivation {
    name = "urbit";

    src = builtins.filterSource isGitDir ./.;

    buildInputs = osxdeps ++ deps;

    mesonFlags = "-Dnix=true";

    NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-framework CoreServices";
  }


# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:

{
  imports =
    [ <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "usbhid" "sd_mod" "rtsx_pci_sdmmc" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/b7475512-9aab-4040-9d1c-43cef00330ac";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/60A9-69C8";
      fsType = "vfat";
    };

  swapDevices =
    [ { device = "/dev/disk/by-uuid/13f26b63-cf59-49c8-bc44-44bd5fc4c9b2"; }
    ];

  nix.maxJobs = lib.mkDefault 4;
}

Change kernel modules and cpuFreqGovernor

# Do not modify this file!  It was generated by ‘nixos-generate-config’
# and may be overwritten by future invocations.  Please make changes
# to /etc/nixos/configuration.nix instead.
{ config, lib, pkgs, ... }:

{
  imports =
    [ <nixpkgs/nixos/modules/installer/scan/not-detected.nix>
    ];

  boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "sd_mod" "rtsx_pci_sdmmc" ];
  boot.initrd.kernelModules = [ "dm-snapshot" ];
  boot.kernelModules = [ "kvm-intel" ];
  boot.extraModulePackages = [ ];

  fileSystems."/" =
    { device = "/dev/disk/by-uuid/b7475512-9aab-4040-9d1c-43cef00330ac";
      fsType = "ext4";
    };

  fileSystems."/boot" =
    { device = "/dev/disk/by-uuid/60A9-69C8";
      fsType = "vfat";
    };

  swapDevices =
    [ { device = "/dev/disk/by-uuid/13f26b63-cf59-49c8-bc44-44bd5fc4c9b2"; }
    ];

  nix.maxJobs = lib.mkDefault 4;
  powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
}


{ stdenv, fetchurl, attr, acl, zlib, libuuid, e2fsprogs, lzo
, asciidoc, xmlto, docbook_xml_dtd_45, docbook_xsl, libxslt }:

let version = "3.17"; in

stdenv.mkDerivation rec {
  name = "btrfs-progs-${version}";

  src = fetchurl {
    url = "mirror://kernel/linux/kernel/people/kdave/btrfs-progs/btrfs-progs-v${version}.tar.xz";
    sha256 = "187hdfh10hrabvldqmhg88wdv0s9r7hc5264v83ykir9wxqvzbzc";
  };

  buildInputs = [
    attr acl zlib libuuid e2fsprogs lzo
    asciidoc xmlto docbook_xml_dtd_45 docbook_xsl libxslt
  ];

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

  makeFlags = "prefix=$(out)";

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

Revert update to version 3.17.

{ stdenv, fetchurl, attr, acl, zlib, libuuid, e2fsprogs, lzo
, asciidoc, xmlto, docbook_xml_dtd_45, docbook_xsl, libxslt }:

let version = "3.16.2"; in

stdenv.mkDerivation rec {
  name = "btrfs-progs-${version}";

  src = fetchurl {
    url = "mirror://kernel/linux/kernel/people/kdave/btrfs-progs/btrfs-progs-v${version}.tar.xz";
    sha256 = "0avk8x0k91zrqvlbk8r067aw49byr8hvvr4niy48d3ib1jz2mmnl";
  };

  buildInputs = [
    attr acl zlib libuuid e2fsprogs lzo
    asciidoc xmlto docbook_xml_dtd_45 docbook_xsl libxslt
  ];

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

  makeFlags = "prefix=$(out)";

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


{ stdenv, fetchurl, alsaLib, boost, glib, jackaudio, ladspaPlugins
, libarchive, liblrdf , libsndfile, pkgconfig, qt4, scons, subversion }:

stdenv.mkDerivation rec {
  version = "0.9.5";
  name = "hydrogen-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/hydrogen/hydrogen-${version}.tar.gz";
    sha256 = "1hyri49va2ss26skd6p9swkx0kbr7ggifbahkrcfgj8yj7pp6g4n";
  };

  buildInputs = [
    alsaLib boost glib jackaudio ladspaPlugins libarchive liblrdf
    libsndfile pkgconfig qt4 scons subversion
  ];

  patches = [ ./scons-env.patch ];

  postPatch = ''
    sed -e 's#/usr/lib/ladspa#${ladspaPlugins}/lib/ladspa#' -i libs/hydrogen/src/preferences.cpp
    sed '/\/usr/d' -i libs/hydrogen/src/preferences.cpp
    '';

  # why doesn't scons find librdf?
  buildPhase = ''
    scons prefix=$out libarchive=1 lrdf=0 install
  '';

  installPhase = ":";

  meta = with stdenv.lib; {
    description = "Advanced drum machine";
    homepage = http://www.hydrogen-music.org;
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = [ maintainers.goibhniu ];
  };
}

Fix Hydrogen to build with JACK 1.9.9.5

{ stdenv, fetchurl, alsaLib, boost, glib, jackaudio, ladspaPlugins
, libarchive, liblrdf , libsndfile, pkgconfig, qt4, scons, subversion }:

stdenv.mkDerivation rec {
  version = "0.9.5";
  name = "hydrogen-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/hydrogen/hydrogen-${version}.tar.gz";
    sha256 = "1hyri49va2ss26skd6p9swkx0kbr7ggifbahkrcfgj8yj7pp6g4n";
  };

  buildInputs = [
    alsaLib boost glib jackaudio ladspaPlugins libarchive liblrdf
    libsndfile pkgconfig qt4 scons subversion
  ];

  patches = [ ./scons-env.patch ];

  postPatch = ''
    sed -e 's#/usr/lib/ladspa#${ladspaPlugins}/lib/ladspa#' -i libs/hydrogen/src/preferences.cpp
    sed '/\/usr/d' -i libs/hydrogen/src/preferences.cpp
    sed "s#pkg_ver.rstrip().split('.')#pkg_ver.rstrip().split('.')[:3]#" -i Sconstruct
  '';

  # why doesn't scons find librdf?
  buildPhase = ''
    scons prefix=$out libarchive=1 lrdf=0 install
  '';

  installPhase = ":";

  meta = with stdenv.lib; {
    description = "Advanced drum machine";
    homepage = http://www.hydrogen-music.org;
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = [ maintainers.goibhniu ];
  };
}


{ lib, fetchFromGitHub, buildPythonPackage, python, flake8, six }:

buildPythonPackage rec {
  pname = "flake8-future-import";
  name = "${pname}-${version}";
  version = "0.4.3";
  # PyPI tarball doesn't include the test suite
  src = fetchFromGitHub {
    owner = "xZise";
    repo = "flake8-future-import";
    rev = version;
    sha256 = "0622bdcfa588m7g8igag6hf4rhjdwh74yfnrjwlxw4vlqhg344k4";
  };
  propagatedBuildInputs = [ flake8 six ];
  meta = {
    homepage = https://github.com/xZise/flake8-future-import;
    description = "A flake8 extension to check for the imported __future__ modules to make it easier to have a consistent code base";
    license = lib.licenses.mit;
  };
}

Add patch to fix tests.

{ lib, fetchFromGitHub, buildPythonPackage, python, flake8, six,
  fetchurl }:

buildPythonPackage rec {
  pname = "flake8-future-import";
  name = "${pname}-${version}";
  version = "0.4.3";
  # PyPI tarball doesn't include the test suite
  src = fetchFromGitHub {
    owner = "xZise";
    repo = "flake8-future-import";
    rev = version;
    sha256 = "0622bdcfa588m7g8igag6hf4rhjdwh74yfnrjwlxw4vlqhg344k4";
  };

  patches = [
    # Tests in 0.4.3 are broken. We can remove this patch after
    # the next release.
    (fetchurl {
      url = "https://github.com/xZise/flake8-future-import/commit/b4f5a06b22c574fb5270574d1420715667768d5c.patch";
      sha256 = "06n9ggz9p9kiwjb3vmaj44pm5vi4nhgzjfn7i730m85xn67xzmyn";
    })
  ];

  propagatedBuildInputs = [ flake8 six ];
  meta = {
    homepage = https://github.com/xZise/flake8-future-import;
    description = "A flake8 extension to check for the imported __future__ modules to make it easier to have a consistent code base";
    license = lib.licenses.mit;
  };
}


{ pkgs }:

pkgs.substituteAll {
  src = ./extlinux-conf-builder.sh;
  isExecutable = true;
  path = [pkgs.buildPackages.coreutils pkgs.buildPackages.gnused pkgs.buildPackages.gnugrep];
  inherit (pkgs.buildPackages) bash;
}

Revert "extlinux-conf: fix cross compilation"

{ pkgs }:

pkgs.substituteAll {
  src = ./extlinux-conf-builder.sh;
  isExecutable = true;
  path = [pkgs.coreutils pkgs.gnused pkgs.gnugrep];
  inherit (pkgs) bash;
}


set background=dark
colorscheme gruvbox

Add explicit nerd tree toggle things

set background=dark
colorscheme gruvbox
let g:airline_powerline_fonts = 1

let g:NERDTreeDirArrowExpandable="+"
let g:NERDTreeDirArrowCollapsible="~"


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

with lib;

let
  cfg = config.hardware;
in {

  ###### interface

  options = {

    hardware.enableAllFirmware = mkOption {
      default = false;
      type = types.bool;
      description = ''
        Turn on this option if you want to enable all the firmware.
      '';
    };

    hardware.enableRedistributableFirmware = mkOption {
      default = false;
      type = types.bool;
      description = ''
        Turn on this option if you want to enable all the firmware with a license allowing redistribution.
        (i.e. free firmware and <literal>firmware-linux-nonfree</literal>)
      '';
    };

  };

  ###### implementation

  config = mkMerge [
    (mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) {
      hardware.firmware = with pkgs; [
        firmwareLinuxNonfree
      firmwareLinuxNvidia
        intel2200BGFirmware
        rtl8723bs-firmware
        rtl8192su-firmware
      ];
    })
    (mkIf cfg.enableAllFirmware {
      assertions = [{
        assertion = !cfg.enableAllFirmware || (config.nixpkgs.config.allowUnfree or false);
        message = ''
          the list of hardware.enableAllFirmware contains non-redistributable licensed firmware files.
            This requires nixpkgs.config.allowUnfree to be true.
            An alternative is to use the hardware.enableRedistributableFirmware option.
        '';
      }];
      hardware.firmware = with pkgs; [
        broadcom-bt-firmware
      ];
    })
  ];
}

Revert "include firmware with enableAllFirmware"

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

with lib;

let
  cfg = config.hardware;
in {

  ###### interface

  options = {

    hardware.enableAllFirmware = mkOption {
      default = false;
      type = types.bool;
      description = ''
        Turn on this option if you want to enable all the firmware.
      '';
    };

    hardware.enableRedistributableFirmware = mkOption {
      default = false;
      type = types.bool;
      description = ''
        Turn on this option if you want to enable all the firmware with a license allowing redistribution.
        (i.e. free firmware and <literal>firmware-linux-nonfree</literal>)
      '';
    };

  };

  ###### implementation

  config = mkMerge [
    (mkIf (cfg.enableAllFirmware || cfg.enableRedistributableFirmware) {
      hardware.firmware = with pkgs; [
        firmwareLinuxNonfree
        intel2200BGFirmware
        rtl8723bs-firmware
        rtl8192su-firmware
      ];
    })
    (mkIf cfg.enableAllFirmware {
      assertions = [{
        assertion = !cfg.enableAllFirmware || (config.nixpkgs.config.allowUnfree or false);
        message = ''
          the list of hardware.enableAllFirmware contains non-redistributable licensed firmware files.
            This requires nixpkgs.config.allowUnfree to be true.
            An alternative is to use the hardware.enableRedistributableFirmware option.
        '';
      }];
      hardware.firmware = with pkgs; [
        broadcom-bt-firmware
      ];
    })
  ];
}


{ stdenv
, fetchurl
, python3
, pkg-config
, readline
, gettext
, libxslt
, docbook-xsl-nons
, docbook_xml_dtd_42
, wafHook
}:

stdenv.mkDerivation rec {
  pname = "ntdb";
  version = "1.0";

  src = fetchurl {
    url = "mirror://samba/tdb/${pname}-${version}.tar.gz";
    sha256 = "0jdzgrz5sr25k83yrw7wqb3r0yj1v04z4s3lhsmnr5z6n5ifhyl1";
  };

  nativeBuildInputs = [
    pkg-config
    gettext
    libxslt
    docbook-xsl-nons
    docbook_xml_dtd_42
    wafHook
  ];

  buildInputs = [
    python3
    readline # required to build python
  ];

  wafPath = "buildtools/bin/waf";

  wafConfigureFlags = [
    "--bundled-libraries=NONE"
    "--builtin-libraries=replace,ccan"
  ];

  meta = with stdenv.lib; {
    description = "The not-so trivial database";
    homepage = "https://tdb.samba.org/";
    license = licenses.lgpl3Plus;
    platforms = platforms.all;
  };
}

Add Python 2 for wafHook

{ stdenv
, fetchurl
, python2
, python3
, pkg-config
, readline
, gettext
, libxslt
, docbook-xsl-nons
, docbook_xml_dtd_42
, wafHook
}:

stdenv.mkDerivation rec {
  pname = "ntdb";
  version = "1.0";

  src = fetchurl {
    url = "mirror://samba/tdb/${pname}-${version}.tar.gz";
    sha256 = "0jdzgrz5sr25k83yrw7wqb3r0yj1v04z4s3lhsmnr5z6n5ifhyl1";
  };

  nativeBuildInputs = [
    pkg-config
    gettext
    libxslt
    docbook-xsl-nons
    docbook_xml_dtd_42
    wafHook
    python2 # For wafHook
  ];

  buildInputs = [
    python3
    readline # required to build python
  ];

  wafPath = "buildtools/bin/waf";

  wafConfigureFlags = [
    "--bundled-libraries=NONE"
    "--builtin-libraries=replace,ccan"
  ];

  meta = with stdenv.lib; {
    description = "The not-so trivial database";
    homepage = "https://tdb.samba.org/";
    license = licenses.lgpl3Plus;
    platforms = platforms.all;
  };
}


{ config, pkgs, ... }:
{
  nixpkgs.config.allowUnfree = true;
  imports = [
    <home-manager/nix-darwin>
    ./home.nix
  ];

  environment.systemPackages = with pkgs;
    [
      ( python38.withPackages (ps: with ps; [ pip flake8 black pynvim ipython python-language-server.override { pylint = null; } ]) )
      httpie
      ffmpeg
      gnupg
      openssl
      yarn
      coreutils
      htop
      httpie
      ripgrep
      fzf
      irssi
      tig
      tree
      wget
      fswatch
      sqlite
      nodejs
      docker
      reattach-to-user-namespace
      alacritty
      ghc
      cabal-install
    ];

  fonts = {
    enableFontDir = true;
    fonts = with pkgs; [ fira-code iosevka];
  };

  programs.zsh.enable = true;

  system.stateVersion = 4;
}

Use local repository for nix-darwin instead of channel

{ config, pkgs, ... }:
{
  nixpkgs.config.allowUnfree = true;
  nix.nixPath = [ "darwin=/Users/sebastian/.nix-defexpr/darwin" ];
  imports = [
    <home-manager/nix-darwin>
    ./home.nix
  ];

  environment.systemPackages = with pkgs;
    [
      ( python38.withPackages (ps: with ps; [ pip flake8 black pynvim ipython python-language-server.override { pylint = null; } ]) )
      httpie
      ffmpeg
      gnupg
      openssl
      yarn
      coreutils
      htop
      httpie
      ripgrep
      fzf
      irssi
      tig
      tree
      wget
      fswatch
      sqlite
      nodejs
      docker
      reattach-to-user-namespace
      alacritty
      ghc
      cabal-install
    ];

  fonts = {
    enableFontDir = true;
    fonts = with pkgs; [ fira-code iosevka];
  };

  programs.zsh.enable = true;

  system.stateVersion = 4;
}


{ stdenv, fetchurl, gnutls, pkgconfig, readline, zlib }:

stdenv.mkDerivation rec {
  name = "lftp-4.5.5";

  src = fetchurl {
    url = "http://lftp.yar.ru/ftp/${name}.tar.bz2";
    sha256 = "11885mj0xk5b1mnvf63s33874x7fcg87bszsyalxwsab4yfplam3";
  };

  patches = [ ./no-gets.patch ];

  buildInputs = [ gnutls pkgconfig readline zlib ];

  meta = with stdenv.lib; {
    description = "A file transfer program supporting a number of network protocols";
    homepage = http://lftp.yar.ru/;
    license = licenses.gpl3;
    platforms = platforms.linux;
    maintainers = [ maintainers.bjornfor ];
  };
}

Add a fallback URL for lftp

{ stdenv, fetchurl, gnutls, pkgconfig, readline, zlib }:

stdenv.mkDerivation rec {
  name = "lftp-4.5.5";

  src = fetchurl {
    urls = [
      "http://lftp.yar.ru/ftp/${name}.tar.bz2"
      "http://lftp.yar.ru/ftp/old/${name}.tar.bz2"
      ];
    sha256 = "11885mj0xk5b1mnvf63s33874x7fcg87bszsyalxwsab4yfplam3";
  };

  patches = [ ./no-gets.patch ];

  buildInputs = [ gnutls pkgconfig readline zlib ];

  meta = with stdenv.lib; {
    description = "A file transfer program supporting a number of network protocols";
    homepage = http://lftp.yar.ru/;
    license = licenses.gpl3;
    platforms = platforms.linux;
    maintainers = [ maintainers.bjornfor ];
  };
}


{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "fdupes-1.40";
  src = fetchurl {
    url = http://premium.caribe.net/~adrian2/programs/fdupes-1.40.tar.gz;
    sha256 = "1ryxpckgrmqa4y7nx9a9xpg4z1r00k11kc1cm7lqv87l9g293vg1";
  };

  installPhase =  ''
    mkdir -p $out/{bin,man/man1}
    make INSTALLDIR=$out/bin MANPAGEDIR=$out/man install
  '';

  meta = {
    description = "identifies duplicate files residing within specified directories.";
    longDescription = ''
      FDUPES uses md5sums and then a byte by byte comparison to finde duplicate
      files within a set of directories.
    '';
    homepage = http://premium.caribe.net/~adrian2/fdupes.html;
    license = "MIT";
  };
}

Update fdupes to version 1.50-RC2

{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "fdupes-1.50-PR2";
  src = fetchurl {
    url = http://fdupes.googlecode.com/files/fdupes-1.50-PR2.tar.gz;
    sha256 = "068nxcn3xilaphq53sywli9ndydy4gijfi2mz7h45kpy0q9cgwjs";
  };

  # workaround: otherwise make install fails (should be fixed in trunk)
  preInstall = "ensureDir $out/bin $out/man/man1";

  makeFlags = "PREFIX=\${out}";

  preBuild = "type -p make";

  meta = {
    description = "identifies duplicate files residing within specified directories.";
    longDescription = ''
      FDUPES uses md5sums and then a byte by byte comparison to finde duplicate
      files within a set of directories.
    '';
    homepage = http://code.google.com/p/fdupes/;
    license = "MIT";
    platforms = stdenv.lib.platforms.all;
    maintainers = [
      stdenv.lib.maintainers.z77z
    ];
  };
}


{stdenv, fetchurl, lame, libvorbis, libmad, pkgconfig, libao}:

stdenv.mkDerivation {
  name = "cdrdao-1.2.3";

  src = fetchurl {
    url = mirror://sourceforge/cdrdao/cdrdao-1.2.3.tar.bz2;
    sha256 = "0pmpgx91j984snrsxbq1dgf3ximks2dfh1sqqmic72lrls7wp4w1";
  };

  makeFlags = "RM=rm LN=ln MV=mv";

  buildInputs = [ lame libvorbis libmad pkgconfig libao ];

  hardeningDisable = [ "format" ];

  # Adjust some headers to match glibc 2.12 ... patch is a diff between
  # the cdrdao CVS head and the 1.2.3 release.
  patches = [ ./adjust-includes-for-glibc-212.patch ];

  # we have glibc/include/linux as a symlink to the kernel headers,
  # and the magic '..' points to kernelheaders, and not back to the glibc/include
  postPatch = ''
    sed -i 's,linux/../,,g' dao/sg_err.h
  '';

  meta = {
    description = "A tool for recording audio or data CD-Rs in disk-at-once (DAO) mode";
    homepage = http://cdrdao.sourceforge.net/;
    platforms = stdenv.lib.platforms.linux;
  };
}

Fix build on gcc 6

{stdenv, fetchurl, lame, libvorbis, libmad, pkgconfig, libao}:

stdenv.mkDerivation {
  name = "cdrdao-1.2.3";

  src = fetchurl {
    url = mirror://sourceforge/cdrdao/cdrdao-1.2.3.tar.bz2;
    sha256 = "0pmpgx91j984snrsxbq1dgf3ximks2dfh1sqqmic72lrls7wp4w1";
  };

  makeFlags = "RM=rm LN=ln MV=mv";

  buildInputs = [ lame libvorbis libmad pkgconfig libao ];

  hardeningDisable = [ "format" ];

  # Adjust some headers to match glibc 2.12 ... patch is a diff between
  # the cdrdao CVS head and the 1.2.3 release.
  patches = [ ./adjust-includes-for-glibc-212.patch ];

  # we have glibc/include/linux as a symlink to the kernel headers,
  # and the magic '..' points to kernelheaders, and not back to the glibc/include
  postPatch = ''
    sed -i 's,linux/../,,g' dao/sg_err.h
  '';

  # Needed on gcc >= 6.
  NIX_CFLAGS_COMPILE = "-Wno-narrowing";

  meta = {
    description = "A tool for recording audio or data CD-Rs in disk-at-once (DAO) mode";
    homepage = http://cdrdao.sourceforge.net/;
    platforms = stdenv.lib.platforms.linux;
  };
}


{ stdenv, fetchurl, python3, autoreconfHook }:

stdenv.mkDerivation rec {
  pname = "jbig2dec";
  version = "0.18";

  src = fetchurl {
    url = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/${pname}-${version}.tar.gz";
    sha256 = "0pigfw2v0ppvr0lbysm69gx0zsa5q2q92yrb8af2j3im6x97f6cy";
  };

  postPatch = ''
    patchShebangs test_jbig2dec.py
  '';

  buildInputs = [ autoreconfHook ];

  checkInputs = [ python3 ];
  doCheck = true;

  meta = {
    homepage = "https://www.jbig2dec.com/";
    description = "Decoder implementation of the JBIG2 image compression format";
    license = stdenv.lib.licenses.gpl2Plus;
    platforms = stdenv.lib.platforms.unix;
  };
}

Move autoreconfHook from buildInputs to nativeBuildInputs

{ stdenv, fetchurl, python3, autoreconfHook }:

stdenv.mkDerivation rec {
  pname = "jbig2dec";
  version = "0.18";

  src = fetchurl {
    url = "https://github.com/ArtifexSoftware/ghostpdl-downloads/releases/download/gs952/${pname}-${version}.tar.gz";
    sha256 = "0pigfw2v0ppvr0lbysm69gx0zsa5q2q92yrb8af2j3im6x97f6cy";
  };

  postPatch = ''
    patchShebangs test_jbig2dec.py
  '';

  nativeBuildInputs = [ autoreconfHook ];

  checkInputs = [ python3 ];
  doCheck = true;

  meta = {
    homepage = "https://www.jbig2dec.com/";
    description = "Decoder implementation of the JBIG2 image compression format";
    license = stdenv.lib.licenses.gpl2Plus;
    platforms = stdenv.lib.platforms.unix;
  };
}


{ stdenv, fetchurl, pkgconfig, xlibs, alsaLib, mesa, aalib
, libvorbis, libtheora, speex, zlib, libdvdcss, perl, ffmpeg
}:

stdenv.mkDerivation rec {
  name = "xine-lib-1.1.19";

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

  buildInputs =
    [ xlibs.xlibs pkgconfig xlibs.libXv xlibs.libXinerama alsaLib mesa aalib
      libvorbis libtheora speex perl ffmpeg
      # removed SDL dependency; it's a big dependency and doesn't seem
      # particularly useful here.
    ];

  NIX_LDFLAGS = "-rpath ${libdvdcss}/lib -L${libdvdcss}/lib -ldvdcss";

  propagatedBuildInputs = [zlib];

  meta = {
    homepage = http://www.xine-project.org/;
    description = "A high-performance, portable and reusable multimedia playback engine";
  };
}

Add flac, pulseaudio, libmng, libxcb

{ stdenv, fetchurl, pkgconfig, xorg, alsaLib, mesa, aalib
, libvorbis, libtheora, speex, zlib, libdvdcss, perl, ffmpeg
, flac, libcaca, pulseaudio, libmng
}:

stdenv.mkDerivation rec {
  name = "xine-lib-1.1.19";

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

  buildNativeInputs = [ pkgconfig perl ];

  buildInputs = [
    xorg.libX11 xorg.libXv xorg.libXinerama xorg.libxcb xorg.libXext
    alsaLib mesa aalib libvorbis libtheora speex perl ffmpeg flac
    libcaca pulseaudio libmng
  ];

  NIX_LDFLAGS = "-rpath ${libdvdcss}/lib -L${libdvdcss}/lib -ldvdcss";

  propagatedBuildInputs = [zlib];

  meta = {
    homepage = http://www.xine-project.org/;
    description = "A high-performance, portable and reusable multimedia playback engine";
  };
}


{ stdenv, fetchurl, gtk, glib, pkgconfig, openssl, boost }:

stdenv.mkDerivation {
  name = "d4x-2.5.7.1";

  inherit boost;

  src = fetchurl {
    url =  http://d4x.krasu.ru/files/d4x-2.5.7.1.tar.bz2;
    sha256 = "1i1jj02bxynisqapv31481sz9jpfp3f023ky47spz1v1wlwbs13m";
  };

  buildInputs = [ gtk glib pkgconfig openssl boost ];

  meta = {
    description = "Graphical download manager";
    homepage = http://www.krasu.ru/soft/chuchelo/;
    license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ];
  };
}

Update download URL to fedora, d4k.krasu.ru no longer exists

{ stdenv, fetchurl, gtk, glib, pkgconfig, openssl, boost }:

stdenv.mkDerivation {
  name = "d4x-2.5.7.1";

  inherit boost;

  src = fetchurl {
    url = http://pkgs.fedoraproject.org/repo/pkgs/d4x/d4x-2.5.7.1.tar.bz2/68d6336c3749a7caabb0f5a5f84f4102/d4x-2.5.7.1.tar.bz2;
    sha256 = "1i1jj02bxynisqapv31481sz9jpfp3f023ky47spz1v1wlwbs13m";
  };

  buildInputs = [ gtk glib pkgconfig openssl boost ];

  meta = {
    description = "Graphical download manager";
    homepage = http://www.krasu.ru/soft/chuchelo/;
    license = with stdenv.lib.licenses; [ artistic1 gpl1Plus ];
  };
}


{ fetchurl, stdenv, pkgconfig, libtirpc
, useSystemd ? true, systemd }:

let version = "1.0.7";
in stdenv.mkDerivation rec {
  name = "rpcbind-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/rpcbind/${version}/${name}.tar.bz2";
    sha256 = "14vl0kmavc1fay630f4w8l1hjfzhmcqm8d0akzahhgymh5fw1f7r";
  };

  patches = [ ./sunrpc.patch ];
  postPatch = ''
    sed -e 's|/usr/include/tirpc|${libtirpc}/include/tirpc|' -i src/Makefile.am -i src/Makefile.in
  '';

  buildInputs = [ libtirpc ]
             ++ stdenv.lib.optional useSystemd systemd;

  configureFlags = stdenv.lib.optional (!useSystemd) "--with-systemdsystemunitdir=no";

  nativeBuildInputs = [ pkgconfig ];

  meta = with stdenv.lib; {
    description = "ONC RPC portmapper";
    license = licenses.bsd3;
    platforms = platforms.unix;
    homepage = http://sourceforge.net/projects/rpcbind/;
    maintainers = with maintainers; [ abbradar ];
    longDescription = ''
      Universal addresses to RPC program number mapper.
    '';
  };
}

Revert "rpcbind: 0.2.3 -> 1.0.7"

{ fetchurl, stdenv, pkgconfig, libtirpc
, useSystemd ? true, systemd }:

let version = "0.2.3";
in stdenv.mkDerivation rec {
  name = "rpcbind-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/rpcbind/${version}/${name}.tar.bz2";
    sha256 = "0yyjzv4161rqxrgjcijkrawnk55rb96ha0pav48s03l2klx855wq";
  };

  patches = [ ./sunrpc.patch ];

  buildInputs = [ libtirpc ]
             ++ stdenv.lib.optional useSystemd systemd;

  configureFlags = stdenv.lib.optional (!useSystemd) "--with-systemdsystemunitdir=no";

  nativeBuildInputs = [ pkgconfig ];

  meta = with stdenv.lib; {
    description = "ONC RPC portmapper";
    license = licenses.bsd3;
    platforms = platforms.unix;
    homepage = http://sourceforge.net/projects/rpcbind/;
    maintainers = with maintainers; [ abbradar ];
    longDescription = ''
      Universal addresses to RPC program number mapper.
    '';
  };
}


{stdenv, fetchurl, libpng, libjpeg}:

stdenv.mkDerivation rec {
  name = "libwebp-0.1.3";

  src = fetchurl {
    url = "http://webp.googlecode.com/files/${name}.tar.gz";
    sha256 = "1fkssvg99s9ypswh4ywkirgcy1wmy3b6388f3cqj4a4vwdb89ca0";
  };

  buildInputs = [ libpng libjpeg ];

  meta = {
    homepage = http://code.google.com/p/webp/;
    description = "Tools and library for the WebP image format";

    /* It has its own licence, google-related, but that looks like BSD */
    license = "free";
  };
}

Update to new upstream version 0.4.0.

{stdenv, fetchurl, libpng, libjpeg}:

stdenv.mkDerivation rec {
  name = "libwebp-0.4.0";

  src = fetchurl {
    url = "http://webp.googlecode.com/files/${name}.tar.gz";
    sha256 = "0sadjkx8m6sf064r5gngjvz4b5246q3j27dlaml5b1k3x5vkb49i";
  };

  buildInputs = [ libpng libjpeg ];

  meta = {
    homepage = http://code.google.com/p/webp/;
    description = "Tools and library for the WebP image format";

    /* It has its own licence, google-related, but that looks like BSD */
    license = "free";
  };
}


{
  pkgs ? import (fetchGit {
    url = https://github.com/NixOS/nixpkgs-channels;
    ref = "nixos-20.03";
  }) {},
  ruby ? pkgs.ruby_2_5,
  bundler ? pkgs.bundler.override { inherit ruby; }
}:

pkgs.mkShell {
  buildInputs = with pkgs; [
    ruby
    bundler
    git
    sqlite
    zlib
    phantomjs
    rubyPackages_2_5.nokogiri
  ];

  shellHook = ''
    mkdir -p .local-data/gems
    export GEM_HOME=$PWD/.local-data/gems
    export GEM_PATH=$GEM_HOME
  '';
}

Add another dependency needed for releasing

{
  pkgs ? import (fetchGit {
    url = https://github.com/NixOS/nixpkgs-channels;
    ref = "nixos-20.03";
  }) {},
  ruby ? pkgs.ruby_2_5,
  bundler ? pkgs.bundler.override { inherit ruby; }
}:

pkgs.mkShell {
  buildInputs = with pkgs; [
    ruby
    bundler
    git
    sqlite
    zlib
    phantomjs
    rubyPackages_2_5.nokogiri
    libiconv
  ];

  shellHook = ''
    mkdir -p .local-data/gems
    export GEM_HOME=$PWD/.local-data/gems
    export GEM_PATH=$GEM_HOME
  '';
}


with import <nix/config.nix>;

{ system ? builtins.currentSystem
, url
, outputHash ? ""
, outputHashAlgo ? ""
, md5 ? "", sha1 ? "", sha256 ? ""
, executable ? false
, unpack ? false
, name ? baseNameOf (toString url)
}:

assert (outputHash != "" && outputHashAlgo != "")
    || md5 != "" || sha1 != "" || sha256 != "";

derivation {
  builder = "builtin:fetchurl";

  # New-style output content requirements.
  outputHashAlgo = if outputHashAlgo != "" then outputHashAlgo else
      if sha256 != "" then "sha256" else if sha1 != "" then "sha1" else "md5";
  outputHash = if outputHash != "" then outputHash else
      if sha256 != "" then sha256 else if sha1 != "" then sha1 else md5;
  outputHashMode = if unpack || executable then "recursive" else "flat";

  inherit name system url executable unpack;

  # No need to double the amount of network traffic
  preferLocalBuild = true;

  impureEnvVars = [
    # We borrow these environment variables from the caller to allow
    # easy proxy configuration.  This is impure, but a fixed-output
    # derivation like fetchurl is allowed to do so since its result is
    # by definition pure.
    "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy"
  ];
}

Drop an unnecessary use of <nix/config.nix>


{ stdenv, fetchFromGitHub, coq }:

let rev_and_sha = {
  "8.6" = {
    rev = "v8.6.0";
    sha256 = "0553pcsy21cyhmns6k9qggzb67az8kl31d0lwlnz08bsqswigzrj";
  };
  "8.7" = {
    rev = "V8.7.0";
    sha256 = "11c4sdmpd3l6jjl4v6k213z9fhrmmm1xnly3zmzam1wrrdif4ghl";
  };
};
in

if ! (rev_and_sha ? "${coq.coq-version}") then
  throw "bignums is not available for Coq ${coq.coq-version}"
else with rev_and_sha."${coq.coq-version}";

stdenv.mkDerivation rec {

  name = "coq${coq.coq-version}-bignums";

  src = fetchFromGitHub {
    owner = "coq";
    repo = "bignums";
    inherit rev sha256;
  };

  buildInputs = [ coq.ocaml coq.camlp5 coq.findlib coq ];

  installFlags = "COQLIB=$(out)/lib/coq/${coq.coq-version}/";

  meta = with stdenv.lib; {
    license = licenses.lgpl2;
    platforms = coq.meta.platforms;
  };

}

Change expression to match other Coq packages

{ stdenv, fetchFromGitHub, coq }:

let param =
  {
    "8.6" = {
      rev = "v8.6.0";
      sha256 = "0553pcsy21cyhmns6k9qggzb67az8kl31d0lwlnz08bsqswigzrj";
    };
    "8.7" = {
      rev = "V8.7.0";
      sha256 = "11c4sdmpd3l6jjl4v6k213z9fhrmmm1xnly3zmzam1wrrdif4ghl";
    };
  }."${coq.coq-version}"
; in

stdenv.mkDerivation rec {

  name = "coq${coq.coq-version}-bignums";

  src = fetchFromGitHub {
    owner = "coq";
    repo = "bignums";
    inherit (param) rev sha256;
  };

  buildInputs = [ coq.ocaml coq.camlp5 coq.findlib coq ];

  installFlags = "COQLIB=$(out)/lib/coq/${coq.coq-version}/";

  meta = with stdenv.lib; {
    license = licenses.lgpl2;
    platforms = coq.meta.platforms;
  };

  passthru = {
    compatibleCoqVersions = v: builtins.elem v [ "8.6" "8.7" ];
  };
}


{ lib, buildPecl, php, valgrind, pcre2 }:

buildPecl {
  pname = "swoole";

  version = "4.6.7";
  sha256 = "107wp403z8skkqrcm240vyyy6wqx5a4v2bqhlshlknyi14r2v165";

  buildInputs = [ valgrind pcre2 ];
  internalDeps = lib.optionals (lib.versionOlder php.version "7.4") [ php.extensions.hash ];

  doCheck = true;
  checkTarget = "tests";

  meta = with lib; {
    description = "Coroutine-based concurrency library for PHP";
    license = licenses.asl20;
    homepage = "https://www.swoole.co.uk/";
    maintainers = teams.php.members;
  };
}

Fix Swoole PHP extension on Darwin by marking Valgrind as an optional dependency

{ lib, stdenv, buildPecl, php, valgrind, pcre2 }:

buildPecl {
  pname = "swoole";

  version = "4.6.7";
  sha256 = "107wp403z8skkqrcm240vyyy6wqx5a4v2bqhlshlknyi14r2v165";

  buildInputs = [ pcre2 ] ++ lib.optionals (!stdenv.isDarwin) [ valgrind ];
  internalDeps = lib.optionals (lib.versionOlder php.version "7.4") [ php.extensions.hash ];

  doCheck = true;
  checkTarget = "tests";

  meta = with lib; {
    description = "Coroutine-based concurrency library for PHP";
    license = licenses.asl20;
    homepage = "https://www.swoole.co.uk/";
    maintainers = teams.php.members;
  };
}


{ lib, buildGoModule, fetchFromGitHub }:

buildGoModule rec {
  pname = "gitbatch";
  version = "0.6.1";

  src = fetchFromGitHub {
    owner = "isacikgoz";
    repo = "gitbatch";
    rev = "v${version}";
    sha256 = "sha256-ovmdbyPRSebwmW6AW55jBgBKaNdY6w5/wrpUF2cMKw8=";
  };

  vendorSha256 = "sha256-wwpaJO5cXMsvqFXj+qGiIm4zg/SL4YCm2mNnG/qdilw=";

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

  checkFlags = [ "-short" ];

  meta = with lib; {
    description = "Running git UI commands";
    homepage = "https://github.com/isacikgoz/gitbatch";
    license = licenses.mit;
    maintainers = with maintainers; [ teto ];
    platforms = with platforms; linux;
  };
}

Fix tests requiring .git & writable HOME

{ lib, buildGoModule, fetchFromGitHub, git }:

buildGoModule rec {
  pname = "gitbatch";
  version = "0.6.1";

  src = fetchFromGitHub {
    owner = "isacikgoz";
    repo = "gitbatch";
    rev = "v${version}";
    sha256 = "sha256-ovmdbyPRSebwmW6AW55jBgBKaNdY6w5/wrpUF2cMKw8=";
  };

  vendorSha256 = "sha256-wwpaJO5cXMsvqFXj+qGiIm4zg/SL4YCm2mNnG/qdilw=";

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

  nativeBuildInputs = [
    git # required by unit tests
  ];

  preCheck = ''
    HOME=$(mktemp -d)
    # Disable tests requiring network access to gitlab.com
    buildFlagsArray+=("-run" "[^(Test(Run|Start|(Fetch|Pull)With(Go|)Git))]")
  '';

  meta = with lib; {
    description = "Running git UI commands";
    homepage = "https://github.com/isacikgoz/gitbatch";
    license = licenses.mit;
    maintainers = with maintainers; [ teto ];
    platforms = with platforms; linux;
  };
}


{ stdenv, fetchurl, makeWrapper, jre }:

stdenv.mkDerivation {
  name = "jruby-1.6.5.1";

  src = fetchurl {
    url = http://jruby.org.s3.amazonaws.com/downloads/1.6.5.1/jruby-bin-1.6.5.1.tar.gz;
    sha256 = "1j0iv1q950lyir9vqfgg2533f1q28jaz7vnxqswsaix1mjhm29qd";
  };

  buildInputs = [ makeWrapper ];

  installPhase = ''
     mkdir -pv $out
     mv * $out
     rm $out/bin/*.{bat,dll,exe,sh}
     mv $out/README $out/docs

     for i in $out/bin/*; do
       wrapProgram $i \
         --set JAVA_HOME ${jre}
     done
  '';

  meta = {
    description = "Ruby interpreter written in Java";
    homepage = http://jruby.org/;
    license = "CPL-1.0 GPL-2 LGPL-2.1"; # one of those
  };
}

Update from 1.6.5.1 to 1.7.12

{ stdenv, fetchurl, makeWrapper, jre }:

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

  version = "1.7.12";

  src = fetchurl {
    url = "http://jruby.org.s3.amazonaws.com/downloads/${version}/jruby-bin-${version}.tar.gz";
    sha1 = "056cee1138e49da40a77f179b771372692479002";
  };

  buildInputs = [ makeWrapper ];

  installPhase = ''
     mkdir -pv $out
     mv * $out
     rm $out/bin/*.{bat,dll,exe,sh}
     mv $out/COPYING $out/LICENSE* $out/docs

     for i in $out/bin/*; do
       wrapProgram $i \
         --set JAVA_HOME ${jre}
     done
  '';

  meta = {
    description = "Ruby interpreter written in Java";
    homepage = http://jruby.org/;
    license = "CPL-1.0 GPL-2 LGPL-2.1"; # one of those
  };
}


{ stdenv
, fetchurl
}:
stdenv.mkDerivation {
  name = "hdf5-1.8.10-patch1";
  src = fetchurl {
    url = http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.10-patch1.tar.gz;
    sha256 = "08ad32fhnci6rdfn6mn3w9v1wcaxdcd326n3ljwkcq4dzhkh28qz";
  };
  buildInputs = [] ;

  patches = [./bin-mv.patch];

  meta = {
    description = "Data model, library, and file format for storing and managing data";
    longDescription = ''
      HDF5 supports an unlimited variety of datatypes, and is designed for flexible and efficient
      I/O and for high volume and complex data. HDF5 is portable and is extensible, allowing
      applications to evolve in their use of HDF5. The HDF5 Technology suite includes tools and
      applications for managing, manipulating, viewing, and analyzing data in the HDF5 format.
    '';
    homepage = http://www.hdfgroup.org/HDF5/;
  };
}

Add zlib as optional dependency

{ stdenv
, fetchurl
, zlib ? null
}:
stdenv.mkDerivation {
  name = "hdf5-1.8.10-patch1";
  src = fetchurl {
    url = http://www.hdfgroup.org/ftp/HDF5/current/src/hdf5-1.8.10-patch1.tar.gz;
    sha256 = "08ad32fhnci6rdfn6mn3w9v1wcaxdcd326n3ljwkcq4dzhkh28qz";
  };

  buildInputs = []
    ++ stdenv.lib.optional (zlib != null) zlib;

  patches = [./bin-mv.patch];

  meta = {
    description = "Data model, library, and file format for storing and managing data";
    longDescription = ''
      HDF5 supports an unlimited variety of datatypes, and is designed for flexible and efficient
      I/O and for high volume and complex data. HDF5 is portable and is extensible, allowing
      applications to evolve in their use of HDF5. The HDF5 Technology suite includes tools and
      applications for managing, manipulating, viewing, and analyzing data in the HDF5 format.
    '';
    homepage = http://www.hdfgroup.org/HDF5/;
  };
}


{ mkDerivation, aeson, attoparsec, base, base16-bytestring
, base64-bytestring, byteable, bytestring, bytestring-tree-builder
, containers, cryptonite, digest, directory, filepath, hspec
, memory, mmap, pipes, pipes-attoparsec, pipes-bytestring
, pipes-zlib, process, QuickCheck, stdenv, text, transformers
, utf8-string, zlib
}:
mkDerivation {
  pname = "duffer";
  version = "0.1.0.0";
  src = ./.;
  libraryHaskellDepends = [
    aeson attoparsec base base16-bytestring base64-bytestring byteable
    bytestring bytestring-tree-builder containers cryptonite digest
    directory filepath memory mmap pipes pipes-attoparsec
    pipes-bytestring pipes-zlib text transformers utf8-string zlib
  ];
  testHaskellDepends = [
    aeson attoparsec base byteable bytestring containers digest
    directory filepath hspec process QuickCheck transformers
    utf8-string
  ];
  doCheck = false;
  doHaddock = false;
  homepage = "http://github.com/vaibhavsagar/duffer#readme";
  description = "Initial project template from stack";
  license = stdenv.lib.licenses.bsd3;
}

Work around pipes-zlib's cabal version bounds

{ mkDerivation, aeson, attoparsec, base, base16-bytestring
, base64-bytestring, byteable, bytestring, bytestring-tree-builder
, containers, cryptonite, digest, directory, filepath, hspec
, memory, mmap, pipes, pipes-attoparsec, pipes-bytestring
, pipes-zlib, process, QuickCheck, stdenv, text, transformers
, utf8-string, zlib, pkgs
}: let patched-pipes-zlib = pkgs.haskell.lib.doJailbreak pipes-zlib; in
mkDerivation {
  pname = "duffer";
  version = "0.1.0.0";
  src = ./.;
  libraryHaskellDepends = [
    aeson attoparsec base base16-bytestring base64-bytestring byteable
    bytestring bytestring-tree-builder containers cryptonite digest
    directory filepath memory mmap pipes pipes-attoparsec
    pipes-bytestring patched-pipes-zlib text transformers utf8-string zlib
  ];
  testHaskellDepends = [
    aeson attoparsec base byteable bytestring containers digest
    directory filepath hspec process QuickCheck transformers
    utf8-string
  ];
  doCheck = false;
  doHaddock = false;
  homepage = "http://github.com/vaibhavsagar/duffer#readme";
  description = "Initial project template from stack";
  license = stdenv.lib.licenses.bsd3;
}


{ stdenv, fetchurl, openldap
, enablePython ? false, python ? null
}:

assert enablePython -> python != null;

stdenv.mkDerivation rec {
  name = "audit-2.6.6";

  src = fetchurl {
    url = "http://people.redhat.com/sgrubb/audit/${name}.tar.gz";
    sha256 = "0jwrww1vn7yqxmb84n6y4p58z34gga0ic4rs2msvpzc2x1hxrn31";
  };

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

  buildInputs = [ openldap ]
            ++ stdenv.lib.optional enablePython python;

  configureFlags = ''
    ${if enablePython then "--with-python" else "--without-python"}
  '';

  meta = {
    description = "Audit Library";
    homepage = "http://people.redhat.com/sgrubb/audit/";
    license = stdenv.lib.licenses.gpl2;
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [ fuuzetsu ];
  };
}

Move z/OS plugin to a separate output

{ stdenv, fetchurl, openldap
, enablePython ? false, python ? null
}:

assert enablePython -> python != null;

stdenv.mkDerivation rec {
  name = "audit-2.6.6";

  src = fetchurl {
    url = "http://people.redhat.com/sgrubb/audit/${name}.tar.gz";
    sha256 = "0jwrww1vn7yqxmb84n6y4p58z34gga0ic4rs2msvpzc2x1hxrn31";
  };

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

  buildInputs = [ openldap ]
            ++ stdenv.lib.optional enablePython python;

  configureFlags = ''
    ${if enablePython then "--with-python" else "--without-python"}
  '';

  enableParallelBuilding = true;

  postInstall =
    ''
      # Move the z/OS plugin to a separate output to prevent an
      # openldap runtime dependency in audit.bin.
      mkdir -p $plugins/bin
      mv $bin/sbin/audispd-zos-remote $plugins/bin/
    '';

  meta = {
    description = "Audit Library";
    homepage = "http://people.redhat.com/sgrubb/audit/";
    license = stdenv.lib.licenses.gpl2;
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [ fuuzetsu ];
  };
}


{ lib, buildPythonPackage, fetchPypi, isPy27
, libX11, libXext
, attrs, docopt, pillow, psutil, xlib }:

buildPythonPackage rec {
  pname = "ueberzug";
  version = "18.1.7";

  disabled = isPy27;

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

  buildInputs = [ libX11 libXext ];
  propagatedBuildInputs = [ attrs docopt pillow psutil xlib ];

  meta = with lib; {
    homepage = "https://github.com/seebye/ueberzug";
    description = "An alternative for w3mimgdisplay";
    license = licenses.gpl3;
    maintainers = with maintainers; [ Br1ght0ne ];
  };
}

Disable tests cause none are included

{ lib, buildPythonPackage, fetchPypi, isPy27
, libX11, libXext
, attrs, docopt, pillow, psutil, xlib }:

buildPythonPackage rec {
  pname = "ueberzug";
  version = "18.1.7";

  disabled = isPy27;

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

  buildInputs = [ libX11 libXext ];

  propagatedBuildInputs = [ attrs docopt pillow psutil xlib ];

  doCheck = false;

  pythonImportsCheck = [ "ueberzug" ];

  meta = with lib; {
    homepage = "https://github.com/seebye/ueberzug";
    description = "An alternative for w3mimgdisplay";
    license = licenses.gpl3;
    maintainers = with maintainers; [ Br1ght0ne ];
  };
}


{ pkgs ? import (fetchGit {
  url = https://github.com/NixOS/nixpkgs-channels;
  ref = "nixos-unstable";
}) {} }:
with pkgs;
buildEnv {
  name = "cava-tools";
  paths = [
    coq_8_10
    coqPackages_8_10.coq-ext-lib
    (haskell.packages.ghc881.ghcWithPackages (pkgs: with pkgs; [Cabal]))
    verilog
    gnumake
    stdenv
    coreutils
    bash
    binutils.bintools
  ];
}

Add verilator to nix config dependencies

{ pkgs ? import (fetchGit {
  url = https://github.com/NixOS/nixpkgs-channels;
  ref = "nixos-unstable";
}) {} }:
with pkgs;
buildEnv {
  name = "cava-tools";
  paths = [
    coq_8_10
    coqPackages_8_10.coq-ext-lib
    (haskell.packages.ghc881.ghcWithPackages (pkgs: with pkgs; [Cabal]))
    verilog
    gnumake
    stdenv
    coreutils
    bash
    binutils.bintools
    verilator
  ];
}


args: with args;
stdenv.mkDerivation rec {
  name = "libiec61883-1.1.0";

  src = fetchurl {
    url = "${meta.homepage}/dl/${name}.tar.gz";
    sha256 = "09f0ca7bp6lqlz6601gnyl04mfabv0azg49n1cmjyqpzh35cgxkq";
  };

  buildInputs = [pkgconfig];
  propagatedBuildInputs = [libraw1394];

  meta = {
      description = "TODO";
      homepage = http://www.linux1394.org;
      license = "LGPL";
    };
}

Update to a version possible to download

args: with args;
stdenv.mkDerivation rec {
  version = "1.2.0";
  name = "libiec61883-${version}";

  src = fetchurl {
    url = "mirror://debian/pool/main/libi/libiec61883/libiec61883_${version}.orig.tar.gz";
    name = "libiec61883-${version}.tar.gz";
    sha256 = "7c7879c6b9add3148baea697dfbfdcefffbc8ac74e8e6bcf46125ec1d21b373a";
  };

  buildInputs = [pkgconfig];
  propagatedBuildInputs = [libraw1394];

  meta = {
      description = "TODO";
      homepage = http://www.linux1394.org;
      license = "LGPL";
    };
}


{ stdenv, buildPythonPackage, fetchurl, isPy3k }:
buildPythonPackage rec {
  name = "xmpp.py-${version}";
  version = "0.5.0rc1";

  patches = [ ./ssl.patch ];

  src = fetchurl {
    url = "mirror://sourceforge/xmpppy/xmpppy-${version}.tar.gz";
    sha256 = "16hbh8kwc5n4qw2rz1mrs8q17rh1zq9cdl05b1nc404n7idh56si";
  };

  preInstall = ''
    mkdir -p $out/bin $out/lib $out/share $(toPythonPath $out)
    export PYTHONPATH=$PYTHONPATH:$(toPythonPath $out)
  '';

  disabled = isPy3k;

  meta = with stdenv.lib; {
    description = "XMPP python library";
    homepage = "http://xmpppy.sourceforge.net/";
    license = license.gpl3;
    maintainers = [ maintainers.mic92 ];
  };
}

Fix evaluation (xmpppy: use correct 'licenses' attr)

{ stdenv, buildPythonPackage, fetchurl, isPy3k }:
buildPythonPackage rec {
  name = "xmpp.py-${version}";
  version = "0.5.0rc1";

  patches = [ ./ssl.patch ];

  src = fetchurl {
    url = "mirror://sourceforge/xmpppy/xmpppy-${version}.tar.gz";
    sha256 = "16hbh8kwc5n4qw2rz1mrs8q17rh1zq9cdl05b1nc404n7idh56si";
  };

  preInstall = ''
    mkdir -p $out/bin $out/lib $out/share $(toPythonPath $out)
    export PYTHONPATH=$PYTHONPATH:$(toPythonPath $out)
  '';

  disabled = isPy3k;

  meta = with stdenv.lib; {
    description = "XMPP python library";
    homepage = "http://xmpppy.sourceforge.net/";
    license = licenses.gpl3;
    maintainers = [ maintainers.mic92 ];
  };
}


{ stdenv, fetchurl, pkgconfig, efl, libcap, automake, autoconf, libdrm, gdbm }:
stdenv.mkDerivation rec {
  name = "elementary-${version}";
  version = "1.17.0";
  src = fetchurl {
    url = "http://download.enlightenment.org/rel/libs/elementary/${name}.tar.xz";
    sha256 = "0avb0d6nk4d88l81c2j6py13vdfnvg080ycw2y3qvawyjf1mhska";
  };
  buildInputs = [ pkgconfig efl libdrm gdbm automake autoconf ] ++ stdenv.lib.optionals stdenv.isLinux [ libcap ];
  NIX_CFLAGS_COMPILE = [ "-I${libdrm}/include/libdrm" ];
  patches = [ ./elementary.patch ];
  enableParallelBuilding = true;
  meta = {
    description = "Widget set/toolkit";
    homepage = http://enlightenment.org/;
    maintainers = with stdenv.lib.maintainers; [ matejc tstrobel ftrvxmtrx ];
    platforms = stdenv.lib.platforms.linux;
    license = stdenv.lib.licenses.lgpl2;
  };
}

Make explicit that 'dev' output of libdrm is used

{ stdenv, fetchurl, pkgconfig, efl, libcap, automake, autoconf, libdrm, gdbm }:
stdenv.mkDerivation rec {
  name = "elementary-${version}";
  version = "1.17.0";
  src = fetchurl {
    url = "http://download.enlightenment.org/rel/libs/elementary/${name}.tar.xz";
    sha256 = "0avb0d6nk4d88l81c2j6py13vdfnvg080ycw2y3qvawyjf1mhska";
  };
  buildInputs = [ pkgconfig efl libdrm gdbm automake autoconf ] ++ stdenv.lib.optionals stdenv.isLinux [ libcap ];
  NIX_CFLAGS_COMPILE = [ "-I${libdrm.dev}/include/libdrm" ];
  patches = [ ./elementary.patch ];
  enableParallelBuilding = true;
  meta = {
    description = "Widget set/toolkit";
    homepage = http://enlightenment.org/;
    maintainers = with stdenv.lib.maintainers; [ matejc tstrobel ftrvxmtrx ];
    platforms = stdenv.lib.platforms.linux;
    license = stdenv.lib.licenses.lgpl2;
  };
}


{stdenv, fetchurl, tcl, tk, autoconf, xproto, libX11}:

stdenv.mkDerivation {
  name = "expect-5.44.1";

  src = fetchurl {
    url = http://expect.nist.gov/old/expect-5.44.1.tar.gz;
    sha256 = "13zxqiclzk1paxc0mr2vwp9nhfyr2mkwk9gs73fg0l3iss16n6p4";
  };

  buildInputs = [tcl tk autoconf xproto libX11];

  #NIX_CFLAGS_COMPILE = "-DHAVE_UNISTD_H";

  # http://wiki.linuxfromscratch.org/lfs/ticket/2126
  #preBuild = ''
  #  substituteInPlace exp_inter.c --replace tcl.h tclInt.h
  #'';

  patchPhase = ''
    substituteInPlace configure --replace /bin/stty "$(type -tP stty)"
    sed -e '1i\#include <tclInt.h>' -i exp_inter.c
    export NIX_LDFLAGS="-rpath $out/lib $NIX_LDFLAGS"
  '';

  configureFlags = ["--with-tcl=${tcl}/lib"
    "--with-tclinclude=${tcl}/include"
    "--with-tk=${tk}/lib"
    "--exec-prefix=$out"];

  meta = {
    description = "A tool for automating interactive applications";
    homepage = http://expect.nist.gov/;
  };
  postInstall="cp expect{,k} $out/bin; ensureDir $out/lib; cp *.so $out/lib";
}

Remove unneeded dependency on Autoconf.

{stdenv, fetchurl, tcl, tk, xproto, libX11}:

stdenv.mkDerivation {
  name = "expect-5.44.1";

  src = fetchurl {
    url = http://expect.nist.gov/old/expect-5.44.1.tar.gz;
    sha256 = "13zxqiclzk1paxc0mr2vwp9nhfyr2mkwk9gs73fg0l3iss16n6p4";
  };

  buildInputs = [tcl tk xproto libX11];

  #NIX_CFLAGS_COMPILE = "-DHAVE_UNISTD_H";

  # http://wiki.linuxfromscratch.org/lfs/ticket/2126
  #preBuild = ''
  #  substituteInPlace exp_inter.c --replace tcl.h tclInt.h
  #'';

  patchPhase = ''
    substituteInPlace configure --replace /bin/stty "$(type -tP stty)"
    sed -e '1i\#include <tclInt.h>' -i exp_inter.c
    export NIX_LDFLAGS="-rpath $out/lib $NIX_LDFLAGS"
  '';

  configureFlags = ["--with-tcl=${tcl}/lib"
    "--with-tclinclude=${tcl}/include"
    "--with-tk=${tk}/lib"
    "--exec-prefix=$out"];

  meta = {
    description = "A tool for automating interactive applications";
    homepage = http://expect.nist.gov/;
  };
  postInstall="cp expect{,k} $out/bin; ensureDir $out/lib; cp *.so $out/lib";
}


import ./generic.nix {
  version = "3.79";
  hash = "sha256-698tapZhO2/nCtV56fmD4OlOARAXHPspmdtjPTOUpRQ=";
}

Revert "nss: 3.68.4 -> 3.79"

import ./generic.nix {
  version = "3.68.4";
  hash = "sha256-K5/T9aG0nzs7KdEgAmdPcEgRViV1b7R3KELsfDm+Fgs=";
}


{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "povray-3.6";

  src = fetchurl {
    url = http://www.povray.org/redirect/www.povray.org/ftp/pub/povray/Official/Unix/povray-3.6.tar.bz2;
    sha256 = "0wvsfgkybx28mj2p76nnsq9rdq50192g5qb7d0xk81s8skn7z2jf";
  };

  # the installPhase wants to put files into $HOME. I let it put the files
  # to $TMPDIR, so they don't get into the $out
  patchPhase = ''
    sed -i -e 's/^povconfuser.*/povconfuser=$(TMPDIR)\/povray/' Makefile.{am,in};
  '';
  # I didn't use configureFlags because I couldn't pass the quotes properly
  # for the COMPILED_BY.
  configurePhase = "./configure --prefix=$out COMPILED_BY=\"nix\"";

  meta = {
    homepage = http://www.povray.org/;
    description = "Persistence of Vision Raytracer";
    license = "free";
  };
}

Update povray. Current master version has 404 on tar.gz.

{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "povray-3.6";

  src = fetchurl {
    url = http://www.povray.org/ftp/pub/povray/Old-Versions/Official-3.62/Unix/povray-3.6.tar.bz2;
    sha256 = "4e8a7fecd44807343b6867e1f2440aa0e09613d6d69a7385ac48f4e5e7737a73";
  };

  # the installPhase wants to put files into $HOME. I let it put the files
  # to $TMPDIR, so they don't get into the $out
  patchPhase = ''
    sed -i -e 's/^povconfuser.*/povconfuser=$(TMPDIR)\/povray/' Makefile.{am,in};
  '';
  # I didn't use configureFlags because I couldn't pass the quotes properly
  # for the COMPILED_BY.
  configurePhase = "./configure --prefix=$out COMPILED_BY=\"nix\"";

  meta = {
    homepage = http://www.povray.org/;
    description = "Persistence of Vision Raytracer";
    license = "free";
  };
}


{ lib
, buildPythonPackage
, fetchPypi
, coverage
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "xmltodict";
  version = "0.12.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "50d8c638ed7ecb88d90561beedbf720c9b4e851a9fa6c47ebd64e99d166d8a21";
  };

  checkInputs = [ coverage pytestCheckHook ];

  disabledTests = [
    # incompatibilities with security fixes: https://github.com/martinblech/xmltodict/issues/289
    "test_namespace_collapse"
    "test_namespace_support"
  ];

  meta = {
    description = "Makes working with XML feel like you are working with JSON";
    homepage = "https://github.com/martinblech/xmltodict";
    license = lib.licenses.mit;
  };
}

Revert "python3Packages.xmltodict: disable incompatible expat tests"

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

buildPythonPackage rec {
  pname = "xmltodict";
  version = "0.12.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "50d8c638ed7ecb88d90561beedbf720c9b4e851a9fa6c47ebd64e99d166d8a21";
  };

  checkInputs = [ coverage nose ];

  checkPhase = ''
    nosetests
  '';

  meta = {
    description = "Makes working with XML feel like you are working with JSON";
    homepage = "https://github.com/martinblech/xmltodict";
    license = lib.licenses.mit;
  };
}


{ ... }:

{
  imports = [
    ../../user
    ../../user/work.nix
  ];

}

Install tig on ssh-accounts without graphics

{ pkgs, ... }:

{
  imports = [
    ../../user
    ../../user/work.nix
  ];

  home.packages = with pkgs; [
    tig
  ];
}


{ stdenv, lib, bower2nix }:
let
  bowerVersion = version:
    let
      components = lib.splitString "#" version;
      hash = lib.last components;
      ver = if builtins.length components == 1 then version else hash;
    in ver;

  fetchbower = name: version: target: outputHash: stdenv.mkDerivation {
    name = "${name}-${bowerVersion version}";
    buildCommand = ''
      fetch-bower --quiet --out=$PWD/out "${name}" "${target}" "${version}"
      # In some cases, the result of fetchBower is different depending
      # on the output directory (e.g. if the bower package contains
      # symlinks). So use a local output directory before copying to
      # $out.
      cp -R out $out
    '';
    outputHashMode = "recursive";
    outputHashAlgo = "sha256";
    inherit outputHash;
    buildInputs = [ bower2nix ];
  };

in fetchbower

Fix fetchbower to handle SSL origins

{ stdenv, lib, bower2nix, cacert }:
let
  bowerVersion = version:
    let
      components = lib.splitString "#" version;
      hash = lib.last components;
      ver = if builtins.length components == 1 then version else hash;
    in ver;

  fetchbower = name: version: target: outputHash: stdenv.mkDerivation {
    name = "${name}-${bowerVersion version}";
    SSL_CERT_FILE = "${cacert}/etc/ssl/certs/ca-bundle.crt";
    buildCommand = ''
      fetch-bower --quiet --out=$PWD/out "${name}" "${target}" "${version}"
      # In some cases, the result of fetchBower is different depending
      # on the output directory (e.g. if the bower package contains
      # symlinks). So use a local output directory before copying to
      # $out.
      cp -R out $out
    '';
    outputHashMode = "recursive";
    outputHashAlgo = "sha256";
    inherit outputHash;
    buildInputs = [ bower2nix ];
  };

in fetchbower


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

{
  imports = [
    ../.
    ../../../common/cpu/intel
    ../../../common/pc/laptop/acpi_call.nix
  ];

  boot = {
    kernelModules = [
      "tpm-rng"
    ];
  };

  services.xserver.deviceSection = lib.mkDefault ''
    Option "TearFree" "true"
  '';

  services.tlp.extraConfig = lib.mkDefault ''
    START_CHARGE_THRESH_BAT0=67
    STOP_CHARGE_THRESH_BAT0=100
  '';

}

Revert "Change TLP charge thresholds"

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

{
  imports = [
    ../.
    ../../../common/cpu/intel
    ../../../common/pc/laptop/acpi_call.nix
  ];

  boot = {
    kernelModules = [
      "tpm-rng"
    ];
  };

  services.xserver.deviceSection = lib.mkDefault ''
    Option "TearFree" "true"
  '';
}


# ALSA sound support.
{ config, pkgs, ... }:

with pkgs.lib;

let

  inherit (pkgs) alsaUtils;

  soundState = "/var/lib/alsa/asound.state";

in

{

  ###### interface

  options = {

    sound = {

      enable = mkOption {
        default = true;
        description = ''
          Whether to enable ALSA sound.
        '';
        merge = mergeEnableOption;
      };

      enableOSSEmulation = mkOption {
        default = true;
        description = ''
          Whether to enable ALSA OSS emulation (with certain cards sound mixing may not work!).
        '';
      };

    };

  };

  ###### implementation

  config = mkIf config.sound.enable {

    environment.systemPackages = [ alsaUtils ];

    boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss";

    jobs.alsa =
      { description = "ALSA Volume Settings";

        startOn = "stopped udevtrigger";

        preStart =
          ''
            mkdir -m 0755 -p $(dirname ${soundState})

            # Try to restore the sound state.
            ${alsaUtils}/sbin/alsactl --ignore init || true
            ${alsaUtils}/sbin/alsactl --ignore -f ${soundState} restore || true
          '';

        postStop =
          ''
            # Save the sound state.
            ${alsaUtils}/sbin/alsactl --ignore -f ${soundState} store
          '';
      };

  };

}

Use udev to restore ALSA volume settings

# ALSA sound support.
{ config, pkgs, ... }:

with pkgs.lib;

let

  inherit (pkgs) alsaUtils;

  soundState = "/var/lib/alsa/asound.state";

in

{

  ###### interface

  options = {

    sound = {

      enable = mkOption {
        default = true;
        description = ''
          Whether to enable ALSA sound.
        '';
        merge = mergeEnableOption;
      };

      enableOSSEmulation = mkOption {
        default = true;
        description = ''
          Whether to enable ALSA OSS emulation (with certain cards sound mixing may not work!).
        '';
      };

    };

  };

  ###### implementation

  config = mkIf config.sound.enable {

    environment.systemPackages = [ alsaUtils ];

    # ALSA provides a udev rule for restoring volume settings.
    services.udev.packages = [ alsaUtils ];

    boot.kernelModules = optional config.sound.enableOSSEmulation "snd_pcm_oss";

    boot.systemd.services."alsa-store" =
      { description = "Store Sound Card State";
        wantedBy = [ "shutdown.target" ];
        before = [ "shutdown.target" ];
        unitConfig.DefaultDependencies = "no";
        serviceConfig.Type = "oneshot";
        serviceConfig.ExecStart = "${alsaUtils}/sbin/alsactl store --ignore";
      };
  };

}


fetchTarball {
  url = "https://github.com/NixOS/nixpkgs/archive/b0bbacb52134a7e731e549f4c0a7a2a39ca6b481.tar.gz";
  sha256 = "15ix4spjpdm6wni28camzjsmhz0gzk3cxhpsk035952plwdxhb67";
}

Upgrade to latest commit in nixos-unstable channel

fetchTarball {
  url = "https://github.com/NixOS/nixpkgs/archive/9beb0d1ac2ebd6063efbdc4d3631f8ce137bbf90.tar.gz";
  sha256 = "1v95779di35qhrz70p2v27kmwm09h8pgh74i1wc72v0zp3bdrf50";
}


if builtins.compareVersions "1.11.7" builtins.nixVersion == 1 then
  abort ''
    This project requires Nix >= 1.11.7, please upgrade:

       curl https://nixos.org/nix/install | sh
  ''
else

with (import (fetchTarball https://github.com/NixOS/nixpkgs/archive/722b12965290a55a758cbf7aee587682edd5e5af.tar.gz) {});

# https://github.com/paf31/purescript-derive-lenses/issues/12
# cabal2nix https://github.com/paf31/purescript-derive-lenses.git > purescript-derive-lenses.nix

let
  hspkgs = pkgs.haskell.packages.ghc802.override {
    overrides = self: super: {
      purescript-derive-lenses = hspkgs.callPackage ./purescript-derive-lenses.nix {};
    };
  };
in stdenv.mkDerivation {
  name = "explorer-bridge";

  buildInputs = with hspkgs; [ nodejs nodePackages.bower purescript purescript-derive-lenses ];

  src = null;
}

Add `yarn` as a dependency

if builtins.compareVersions "1.11.7" builtins.nixVersion == 1 then
  abort ''
    This project requires Nix >= 1.11.7, please upgrade:

       curl https://nixos.org/nix/install | sh
  ''
else

with (import (fetchTarball https://github.com/NixOS/nixpkgs/archive/722b12965290a55a758cbf7aee587682edd5e5af.tar.gz) {});

# https://github.com/paf31/purescript-derive-lenses/issues/12
# cabal2nix https://github.com/paf31/purescript-derive-lenses.git > purescript-derive-lenses.nix

let
  hspkgs = pkgs.haskell.packages.ghc802.override {
    overrides = self: super: {
      purescript-derive-lenses = hspkgs.callPackage ./purescript-derive-lenses.nix {};
    };
  };
in stdenv.mkDerivation {
  name = "explorer-bridge";

  buildInputs = with hspkgs; [ nodejs yarn nodePackages.bower purescript purescript-derive-lenses ];

  src = null;
}


{ stdenv, fetchurl, pythonPackages, pygobject, gst_python
, gst_plugins_good, gst_plugins_base
}:

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

  version = "0.19.0";

  src = fetchurl {
    url = "https://github.com/mopidy/mopidy/archive/v${version}.tar.gz";
    sha256 = "10cnc1bipr0brk7478201cgm71lp5bci3qiaadyxv9hhcn0nmn9b";
  };

  propagatedBuildInputs = with pythonPackages; [
    gst_python pygobject pykka tornado gst_plugins_base gst_plugins_good
  ];

  # There are no tests
  doCheck = false;

  postInstall = ''
    wrapProgram $out/bin/mopidy \
      --prefix GST_PLUGIN_SYSTEM_PATH : "$GST_PLUGIN_SYSTEM_PATH"
  '';

  meta = with stdenv.lib; {
    homepage = http://www.mopidy.com/;
    description = ''
      An extensible music server that plays music from local disk, Spotify,
      SoundCloud, Google Play Music, and more.
    '';
    license = licenses.asl20;
    maintainers = [ maintainers.rickynils ];
    hydraPlatforms = [];
  };
}

Update from 0.19.0 to 0.19.3

{ stdenv, fetchurl, pythonPackages, pygobject, gst_python
, gst_plugins_good, gst_plugins_base
}:

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

  version = "0.19.3";

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

  propagatedBuildInputs = with pythonPackages; [
    gst_python pygobject pykka tornado gst_plugins_base gst_plugins_good
  ];

  # There are no tests
  doCheck = false;

  postInstall = ''
    wrapProgram $out/bin/mopidy \
      --prefix GST_PLUGIN_SYSTEM_PATH : "$GST_PLUGIN_SYSTEM_PATH"
  '';

  meta = with stdenv.lib; {
    homepage = http://www.mopidy.com/;
    description = ''
      An extensible music server that plays music from local disk, Spotify,
      SoundCloud, Google Play Music, and more.
    '';
    license = licenses.asl20;
    maintainers = [ maintainers.rickynils ];
    hydraPlatforms = [];
  };
}


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

let
  pkgs-unstable = import <nixpkgs-unstable> { config = { allowUnfree = true; }; };
in
{
  options = {
    roles.java.haveIntelliJUltimateLicense = lib.mkOption {
      type = lib.types.bool;
      default = false;
    };
  };

  config = {
    # add symlinks /etc/openjdk{8,12} to /nix/store
    environment.etc = {
      "openjdk8".source = "${pkgs.openjdk8}/lib/openjdk";
      "openjdk12".source = "${pkgs-unstable.openjdk12}/lib/openjdk";
    };

    environment.systemPackages = with pkgs; [
      openjdk

      # Build tools
      maven
      gradle

      # IDEs
      eclipses.eclipse-java
      (if config.roles.java.haveIntelliJUltimateLicense then pkgs-unstable.idea.idea-ultimate else pkgs-unstable.idea.idea-community)
    ];

    my-config.vscodeExtensions = with (import ../vscode-extensions.nix); [
      vscode-java-pack
    ];
  };
}

Use OpenJDK from stable packages

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

let
  pkgs-unstable = import <nixpkgs-unstable> { config = { allowUnfree = true; }; };
in
{
  options = {
    roles.java.haveIntelliJUltimateLicense = lib.mkOption {
      type = lib.types.bool;
      default = false;
    };
  };

  config = {
    # add symlinks /etc/openjdk{8,12} to /nix/store
    environment.etc = {
      "openjdk8".source = "${pkgs.openjdk8}/lib/openjdk";
      "openjdk12".source = "${pkgs.openjdk12}/lib/openjdk";
    };

    environment.systemPackages = with pkgs; [
      openjdk8

      # Build tools
      maven
      gradle

      # IDEs
      eclipses.eclipse-java
      (if config.roles.java.haveIntelliJUltimateLicense then pkgs-unstable.idea.idea-ultimate else pkgs-unstable.idea.idea-community)
    ];

    my-config.vscodeExtensions = with (import ../vscode-extensions.nix); [
      vscode-java-pack
    ];
  };
}


{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "replace-2.24";

  src = fetchurl {
    url = ftp://hpux.connect.org.uk/hpux/Users/replace-2.24/replace-2.24-src-11.11.tar.gz;
    sha256 = "1c2nkxx83vmlh1v3ib6r2xqh121gdb1rharwsimcb2h0xwc558dm";
  };

  makeFlags = "TREE=\$(out) MANTREE=\$(TREE)/share/man";

  crossAttrs = {
    makeFlags = "TREE=\$(out) MANTREE=\$(TREE)/share/man CC=${stdenv.cross.config}-gcc";
  };

  preInstall = "mkdir -p \$out/share/man";
  postInstall = "mv \$out/bin/replace \$out/bin/replace-literal";

  patches = [./malloc.patch];

  meta = {
    homepage = http://replace.richardlloyd.org.uk/;
    description = "A tool to replace verbatim strings";
  };
}

Fix /bin/mv reference in replace-literal

{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "replace-2.24";

  src = fetchurl {
    url = ftp://hpux.connect.org.uk/hpux/Users/replace-2.24/replace-2.24-src-11.11.tar.gz;
    sha256 = "1c2nkxx83vmlh1v3ib6r2xqh121gdb1rharwsimcb2h0xwc558dm";
  };

  makeFlags = "TREE=\$(out) MANTREE=\$(TREE)/share/man";

  crossAttrs = {
    makeFlags = "TREE=\$(out) MANTREE=\$(TREE)/share/man CC=${stdenv.cross.config}-gcc";
  };

  preBuild = ''
    sed -e "s@/bin/mv@$(type -P mv)@" -i replace.h
  '';

  preInstall = "mkdir -p \$out/share/man";
  postInstall = "mv \$out/bin/replace \$out/bin/replace-literal";

  patches = [./malloc.patch];

  meta = {
    homepage = http://replace.richardlloyd.org.uk/;
    description = "A tool to replace verbatim strings";
  };
}


{stdenv, fetchurl, bison, flex}:

stdenv.mkDerivation rec {
  name = "libnl-3.2.13";

  src = fetchurl {
    url = "${meta.homepage}files/${name}.tar.gz";
    sha256 = "1ydw42lsd572qwrfgws97n76hyvjdpanwrxm03lysnhfxkna1ssd";
  };

  buildInputs = [ bison flex ];

  meta = {
    homepage = "http://www.infradead.org/~tgr/libnl/";
    description = "Linux NetLink interface library";
    maintainers = [ stdenv.lib.maintainers.urkud ];
    platforms = stdenv.lib.platforms.linux;
  };
}

Upgrade libnl from 3.2.13 -> 3.2.23

{stdenv, fetchurl, bison, flex}:

stdenv.mkDerivation rec {
  name = "libnl-3.2.23";

  src = fetchurl {
    url = "${meta.homepage}files/${name}.tar.gz";
    sha256 = "1czj2bpb799bih6ighqwbvv9pvbpcw7vmccv9cwavfwcmalwvhlc";
  };

  buildInputs = [ bison flex ];

  meta = {
    homepage = "http://www.infradead.org/~tgr/libnl/";
    description = "Linux NetLink interface library";
    maintainers = [ stdenv.lib.maintainers.urkud ];
    platforms = stdenv.lib.platforms.linux;
  };
}