{ stdenv
, fetchurl
, perl
}:

let
  version = "1.9.0";
in
stdenv.mkDerivation rec {
  name = "libbson-${version}";

  src = fetchurl {
    url = "https://github.com/mongodb/libbson/releases/download"
      + "/${version}/${name}.tar.gz";
    sha256 = "ac35850ea90fb0de36aa80196eeba484aadaa234d76fe2daae3d8ef3df3c6e61";
  };

  nativeBuildInputs = [
    perl
  ];

  configureFlags = [
    "--disable-examples"
    "--disable-tests"
  ];

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

Move includes to the root

{ stdenv
, fetchurl
, perl
}:

let
  version = "1.9.0";
in
stdenv.mkDerivation rec {
  name = "libbson-${version}";

  src = fetchurl {
    url = "https://github.com/mongodb/libbson/releases/download"
      + "/${version}/${name}.tar.gz";
    sha256 = "ac35850ea90fb0de36aa80196eeba484aadaa234d76fe2daae3d8ef3df3c6e61";
  };

  nativeBuildInputs = [
    perl
  ];

  configureFlags = [
    "--disable-examples"
    "--disable-tests"
  ];

  # Builders don't respect the nested include dir
  postInstall = ''
    incdir="$(echo "$out"/include/*)"
    mv "$incdir"/* "$out/include"
    rmdir "$incdir"
    ln -sv . "$incdir"
  '';

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


{ lib, runCommandCC, libxkbcommon }:

runCommandCC "xkbvalidate" {
  buildInputs = [ libxkbcommon ];
  meta = {
    description = "NixOS tool to validate X keyboard configuration";
    license = lib.licenses.mit;
    platforms = lib.platforms.linux;
    maintainers = [ lib.maintainers.aszlig ];
  };
} ''
  mkdir -p "$out/bin"
  gcc -std=gnu11 -Wall -pedantic -lxkbcommon ${./xkbvalidate.c} \
    -o "$out/bin/validate"
''

Use $CC instead of hardcoded gcc

{ lib, runCommandCC, libxkbcommon }:

runCommandCC "xkbvalidate" {
  buildInputs = [ libxkbcommon ];
  meta = {
    description = "NixOS tool to validate X keyboard configuration";
    license = lib.licenses.mit;
    platforms = lib.platforms.linux;
    maintainers = [ lib.maintainers.aszlig ];
  };
} ''
  mkdir -p "$out/bin"
  $CC -std=gnu11 -Wall -pedantic -lxkbcommon ${./xkbvalidate.c} \
    -o "$out/bin/validate"
''


{ pkgs, ... }:

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

  # Packages for a full user experience on a laptop or workstation.
  packages = with pkgs; [
    # Terminals and core software:
    rxvt_unicode_with-plugins wmctrl gnome.gnome_keyring

    # Internet Utilities:
    uzbl chromium bitlbee ssvnc

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

    # Media Ripping:
    handbrake makemkv

    # Media Editors:
    audacity gimp inkscape darktable

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

    # Games:
    mednafen

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

Mark a package for removal after upgrading to NixOS 14.12

{ pkgs, ... }:

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

  # Packages for a full user experience on a laptop or workstation.
  packages = with pkgs; [
    # Terminals and core software:
    rxvt_unicode_with-plugins # FIXME: Remove this after upgrading to 14.12.
    wmctrl gnome.gnome_keyring

    # Internet Utilities:
    uzbl chromium bitlbee ssvnc

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

    # Media Ripping:
    handbrake makemkv

    # Media Editors:
    audacity gimp inkscape darktable

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

    # Games:
    mednafen

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


{ stdenv, appleDerivation }:

appleDerivation {
  dontBuild = true;

  postPatch = ''
    substituteInPlace Makefile \
        --replace '/bin/mkdir' 'mkdir' \
        --replace '/usr/bin/install' 'install'
  '';

  installFlags = [ "EXPORT_DSTDIR=/include/architecture" ];

  DSTROOT = "$(out)";

  meta = with stdenv.lib; {
    maintainers = with maintainers; [ copumpkin ];
    platforms   = platforms.darwin;
    license     = licenses.apsl20;
  };
}

Revert "darwin.architecture: fix sandbox build"

{ stdenv, appleDerivation }:

appleDerivation {
  dontBuild = true;

  installFlags = [ "EXPORT_DSTDIR=/include/architecture" ];

  DSTROOT = "$(out)";

  meta = with stdenv.lib; {
    maintainers = with maintainers; [ copumpkin ];
    platforms   = platforms.darwin;
    license     = licenses.apsl20;
  };
}


{ stdenv, fetchurl, pkgconfig, udev }:

stdenv.mkDerivation rec {
  name = "dhcpcd-6.8.1";

  src = fetchurl {
    url = "mirror://roy/dhcpcd/${name}.tar.bz2";
    sha256 = "10mg68yxvl4kn1ya8ziifg2dm71c10r12sg7y7k1k0vafazhrdi7";
  };

  buildInputs = [ pkgconfig udev ];

  configureFlags = [
    "--sysconfdir=/etc"
    "--localstatedir=/var"
  ];

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

  # Hack to make installation succeed.  dhcpcd will still use /var/db
  # at runtime.
  installFlags = "DBDIR=\${TMPDIR}/db SYSCONFDIR=$(out)/etc";

  # Check that the udev plugin got built.
  postInstall = stdenv.lib.optional (udev != null) "[ -e $out/lib/dhcpcd/dev/udev.so ]";

  meta = {
    description = "A client for the Dynamic Host Configuration Protocol (DHCP)";
    homepage = http://roy.marples.name/projects/dhcpcd;
    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.eelco ];
  };
}

Upgrade dhcpcd to 6.9.0. Version 6.8.1 caused issues on GCE, making the instances unavailable.

{ stdenv, fetchurl, pkgconfig, udev }:

stdenv.mkDerivation rec {
  name = "dhcpcd-6.9.0";

  src = fetchurl {
    url = "mirror://roy/dhcpcd/${name}.tar.bz2";
    sha256 = "0s0a29ml9x108lxv5yz55f3l5kvlx4hcbxigfq3hr245yy7aarhm";
  };

  buildInputs = [ pkgconfig udev ];

  configureFlags = [
    "--sysconfdir=/etc"
    "--localstatedir=/var"
  ];

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

  # Hack to make installation succeed.  dhcpcd will still use /var/db
  # at runtime.
  installFlags = "DBDIR=\${TMPDIR}/db SYSCONFDIR=$(out)/etc";

  # Check that the udev plugin got built.
  postInstall = stdenv.lib.optional (udev != null) "[ -e $out/lib/dhcpcd/dev/udev.so ]";

  meta = {
    description = "A client for the Dynamic Host Configuration Protocol (DHCP)";
    homepage = http://roy.marples.name/projects/dhcpcd;
    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.eelco ];
  };
}


let
  pkgs = import ./.;
  poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
    projectDir = ./.;
    editablePackageSources = {
      slumba = ./slumba;
    };
  };
in pkgs.mkShell {
  buildInputs = with pkgs; [
    niv
    poetry
    poetryEnv
    sqlite
  ];
}

Add rlwrap to make sqlite3 cli usable

let
  pkgs = import ./.;
  poetryEnv = pkgs.poetry2nix.mkPoetryEnv {
    projectDir = ./.;
    editablePackageSources = {
      slumba = ./slumba;
    };
  };
in pkgs.mkShell {
  buildInputs = with pkgs; [
    niv
    poetry
    poetryEnv
    sqlite
    rlwrap
  ];
}


{ stdenv, fetchurl, pcsclite, pkgconfig, libusb1, perl }:
stdenv.mkDerivation rec {
  version = "1.4.15";
  name = "ccid-${version}";

  src = fetchurl {
    url = "https://alioth.debian.org/frs/download.php/file/3989/${name}.tar.bz2";
    sha256 = "5436182246f15b3e78b1ad6707022b02dc400e3f50c4cb5e5d340a4e716d990a";
  };

  patchPhase = ''
    sed -i 's,/usr/bin/env perl,${perl}/bin/perl,' src/*.pl
    substituteInPlace src/Makefile.in --replace /bin/echo echo
  '';
  preConfigure = ''
    configureFlags="$configureFlags --enable-usbdropdir=$out/pcsc/drivers"
  '';

  buildInputs = [ pcsclite pkgconfig libusb1 ];

  meta = with stdenv.lib; {
    description = "ccid drivers for pcsclite";
    homepage = http://pcsclite.alioth.debian.org/;
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [viric];
    platforms = with platforms; linux;
  };
}

Revert "ccid: Update from 1.4.14 -> 1.4.15"

{ stdenv, fetchurl, pcsclite, pkgconfig, libusb1, perl }:
stdenv.mkDerivation rec {
  version = "1.4.14";
  name = "ccid-${version}";

  src = fetchurl {
    url = "http://ftp.de.debian.org/debian/pool/main/c/ccid/ccid_${version}.orig.tar.bz2";
    sha256 = "0inibkhzk4ghg85jkysscjrzshmxfdzz6b54dqj182l0isn082y5";
  };

  patchPhase = ''
    sed -i 's,/usr/bin/env perl,${perl}/bin/perl,' src/*.pl
    substituteInPlace src/Makefile.in --replace /bin/echo echo
  '';
  preConfigure = ''
    configureFlags="$configureFlags --enable-usbdropdir=$out/pcsc/drivers"
  '';

  buildInputs = [ pcsclite pkgconfig libusb1 ];

  meta = {
    description = "ccid drivers for pcsclite";
    homepage = http://pcsclite.alioth.debian.org/;
    license = "GPLv2+";
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}


{ lib, fetchurl, libarchive }:

let
  version = "0.34.7";
in fetchurl {
  name = "sarasa-gothic-${version}";

  url = "https://github.com/be5invis/Sarasa-Gothic/releases/download/v${version}/sarasa-gothic-ttf-${version}.7z";
  sha256 = "094sl6gklrdv9pk4r6451dvz0fjyjmwys7i81qrz4ik1km5dfq9b";

  recursiveHash = true;
  downloadToTemp = true;

  postFetch = ''
    mkdir -p $out/share/fonts/truetype
    ${libarchive}/bin/bsdtar -xf $downloadedFile -C $out/share/fonts/truetype
  '';

  meta = with lib; {
    description = "A CJK programming font based on Iosevka and Source Han Sans";
    homepage = "https://github.com/be5invis/Sarasa-Gothic";
    license = licenses.ofl;
    maintainers = [ maintainers.ChengCat ];
    hydraPlatforms = [ ]; # disabled from hydra because it's so big
    platforms = platforms.all;
  };
}

Use TTC format instead of TTF

{ lib, fetchurl, libarchive }:

let
  version = "0.34.7";
in fetchurl {
  name = "sarasa-gothic-${version}";

  # Use the 'ttc' files here for a smaller closure size.
  # (Using 'ttf' files gives a closure size about 15x larger, as of November 2021.)
  url = "https://github.com/be5invis/Sarasa-Gothic/releases/download/v${version}/sarasa-gothic-ttc-${version}.7z";
  sha256 = "0fzbqj32jiffqsr4s0i8fignk01v5d1rik6ldg2q7dgl1298sgk8";

  recursiveHash = true;
  downloadToTemp = true;

  postFetch = ''
    mkdir -p $out/share/fonts/truetype
    ${libarchive}/bin/bsdtar -xf $downloadedFile -C $out/share/fonts/truetype
  '';

  meta = with lib; {
    description = "A CJK programming font based on Iosevka and Source Han Sans";
    homepage = "https://github.com/be5invis/Sarasa-Gothic";
    license = licenses.ofl;
    maintainers = [ maintainers.ChengCat ];
    platforms = platforms.all;
  };
}


{ lib, buildPythonPackage, fetchPypi
, setuptools_scm
, sphinx
, hypothesis
, py
, pytest
, pytest-benchmark
, sortedcollections
, sortedcontainers
, isPy3k
}:

buildPythonPackage rec {
  pname = "bidict";
  version = "0.21.2";
  disabled = !isPy3k;

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

  nativeBuildInputs = [ setuptools_scm ];
  propagatedBuildInputs = [ sphinx ];

  # this can be removed >0.19.0
  postPatch = ''
    substituteInPlace setup.py \
      --replace "setuptools_scm < 4" "setuptools_scm"
  '';

  checkInputs = [
    hypothesis
    py
    pytest
    pytest-benchmark
    sortedcollections
    sortedcontainers
  ];
  checkPhase = ''
    pytest tests
  '';

  meta = with lib; {
    homepage = "https://github.com/jab/bidict";
    description = "Efficient, Pythonic bidirectional map data structures and related functionality";
    license = licenses.mpl20;
    maintainers = with maintainers; [ jakewaksbaum ];
  };
}

Remove stale patch, use pytestCheckHook

{ lib, buildPythonPackage, fetchPypi
, setuptools_scm
, sphinx
, hypothesis
, py
, pytestCheckHook
, pytest-benchmark
, sortedcollections
, sortedcontainers
, isPy3k
}:

buildPythonPackage rec {
  pname = "bidict";
  version = "0.21.2";
  disabled = !isPy3k;

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

  nativeBuildInputs = [ setuptools_scm ];
  propagatedBuildInputs = [ sphinx ];

  checkInputs = [
    hypothesis
    py
    pytestCheckHook
    pytest-benchmark
    sortedcollections
    sortedcontainers
  ];

  meta = with lib; {
    homepage = "https://github.com/jab/bidict";
    description = "Efficient, Pythonic bidirectional map data structures and related functionality";
    license = licenses.mpl20;
    maintainers = with maintainers; [ jakewaksbaum ];
  };
}


{ autoreconfHook
, curl
, dbus
, fetchFromGitHub
, glib
, json-glib
, lib
, nix-update-script
, openssl
, pkg-config
, stdenv
}:

stdenv.mkDerivation rec {
  pname = "rauc";
  version = "1.5.1";

  src = fetchFromGitHub {
    owner = pname;
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-AIizbD2jaZ5SY0K/hwpHdGE20KEhWC53LWUiVYs9Oiw=";
  };

  passthru = {
    updateScript = nix-update-script {
      attrPath = pname;
    };
  };

  enableParallelBuilding = true;

  nativeBuildInputs = [ pkg-config autoreconfHook ];

  buildInputs = [ curl dbus glib json-glib openssl ];

  configureFlags = [
    "--with-systemdunitdir=${placeholder "out"}/lib/systemd/system"
    "--with-dbusinterfacesdir=${placeholder "out"}/share/dbus-1/interfaces"
    "--with-dbuspolicydir=${placeholder "out"}/share/dbus-1/systemd.d"
    "--with-dbussystemservicedir=${placeholder "out"}/share/dbus-1/system-services"
  ];

  meta = with lib; {
    description = "Safe and secure software updates for embedded Linux";
    homepage = "https://rauc.io";
    license = licenses.lgpl21;
    maintainers = with maintainers; [ emantor ];
    platforms = with platforms; linux;
  };
}

Fix directory for dbus policy file

{ autoreconfHook
, curl
, dbus
, fetchFromGitHub
, glib
, json-glib
, lib
, nix-update-script
, openssl
, pkg-config
, stdenv
}:

stdenv.mkDerivation rec {
  pname = "rauc";
  version = "1.5.1";

  src = fetchFromGitHub {
    owner = pname;
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-AIizbD2jaZ5SY0K/hwpHdGE20KEhWC53LWUiVYs9Oiw=";
  };

  passthru = {
    updateScript = nix-update-script {
      attrPath = pname;
    };
  };

  enableParallelBuilding = true;

  nativeBuildInputs = [ pkg-config autoreconfHook ];

  buildInputs = [ curl dbus glib json-glib openssl ];

  configureFlags = [
    "--with-systemdunitdir=${placeholder "out"}/lib/systemd/system"
    "--with-dbusinterfacesdir=${placeholder "out"}/share/dbus-1/interfaces"
    "--with-dbuspolicydir=${placeholder "out"}/share/dbus-1/system.d"
    "--with-dbussystemservicedir=${placeholder "out"}/share/dbus-1/system-services"
  ];

  meta = with lib; {
    description = "Safe and secure software updates for embedded Linux";
    homepage = "https://rauc.io";
    license = licenses.lgpl21;
    maintainers = with maintainers; [ emantor ];
    platforms = with platforms; linux;
  };
}


{ lib, pythonPackages, fetchurl, kmod, systemd }:

let version = "0.7.9";

in pythonPackages.buildPythonApplication rec {
  name = "cloud-init-${version}";
  namePrefix = "";

  src = fetchurl {
    url = "https://launchpad.net/cloud-init/trunk/${version}/+download/cloud-init-${version}.tar.gz";
    sha256 = "0wnl76pdcj754pl99wxx76hkir1s61x0bg0lh27sdgdxy45vivbn";
  };

  patches = [ ./add-nixos-support.patch ];
  patchPhase = ''
    patchShebangs ./tools

    substituteInPlace setup.py \
      --replace /usr $out \
      --replace /etc $out/etc \
      --replace /lib/systemd $out/lib/systemd \
      --replace 'self.init_system = ""' 'self.init_system = "systemd"'
    '';

  propagatedBuildInputs = with pythonPackages; [ cheetah jinja2 prettytable
    oauthlib pyserial configobj pyyaml argparse requests jsonpatch ];

  meta = {
    homepage = http://cloudinit.readthedocs.org;
    description = "Provides configuration and customization of cloud instance";
    maintainers = [ lib.maintainers.madjar lib.maintainers.phile314 ];
    platforms = lib.platforms.all;
  };
}

Revert "Remove spurious call to patchPhase."

{ lib, pythonPackages, fetchurl, kmod, systemd }:

let version = "0.7.9";

in pythonPackages.buildPythonApplication rec {
  name = "cloud-init-${version}";
  namePrefix = "";

  src = fetchurl {
    url = "https://launchpad.net/cloud-init/trunk/${version}/+download/cloud-init-${version}.tar.gz";
    sha256 = "0wnl76pdcj754pl99wxx76hkir1s61x0bg0lh27sdgdxy45vivbn";
  };

  patches = [ ./add-nixos-support.patch ];
  patchPhase = ''
    patchShebangs ./tools

    substituteInPlace setup.py \
      --replace /usr $out \
      --replace /etc $out/etc \
      --replace /lib/systemd $out/lib/systemd \
      --replace 'self.init_system = ""' 'self.init_system = "systemd"'

    patchPhase
    '';

  propagatedBuildInputs = with pythonPackages; [ cheetah jinja2 prettytable
    oauthlib pyserial configobj pyyaml argparse requests jsonpatch ];

  meta = {
    homepage = http://cloudinit.readthedocs.org;
    description = "Provides configuration and customization of cloud instance";
    maintainers = [ lib.maintainers.madjar lib.maintainers.phile314 ];
    platforms = lib.platforms.all;
  };
}


{ stdenv, fetchurl, zlib }:

assert zlib != null;

stdenv.mkDerivation rec {
  version = "1.4.4";
  name = "libpng-apng-${version}";

  patch_src = fetchurl {
    url = "mirror://sourceforge/project/libpng-apng/libpng-master/${version}/libpng-${version}-apng.patch.gz";
    sha256 = "d729a2feacfd80547e06c30343d598302f4417cf2e6f649e4ee617690987bd24";
  };

  src = fetchurl {
    url = "mirror://sourceforge/libpng/libpng-${version}.tar.gz";
    sha256 = "d07616ba1e9c161017384feb3b576d70c160b970abfd9549ad39a622284b574a";
  };

  preConfigure = ''
    gunzip < ${patch_src} | patch -Np1
  '';

  propagatedBuildInputs = [ zlib ];

  passthru = { inherit zlib; };

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

Update description to mention APNG patch

{ stdenv, fetchurl, zlib }:

assert zlib != null;

stdenv.mkDerivation rec {
  version = "1.4.4";
  name = "libpng-apng-${version}";

  patch_src = fetchurl {
    url = "mirror://sourceforge/project/libpng-apng/libpng-master/${version}/libpng-${version}-apng.patch.gz";
    sha256 = "d729a2feacfd80547e06c30343d598302f4417cf2e6f649e4ee617690987bd24";
  };

  src = fetchurl {
    url = "mirror://sourceforge/libpng/libpng-${version}.tar.gz";
    sha256 = "d07616ba1e9c161017384feb3b576d70c160b970abfd9549ad39a622284b574a";
  };

  preConfigure = ''
    gunzip < ${patch_src} | patch -Np1
  '';

  propagatedBuildInputs = [ zlib ];

  passthru = { inherit zlib; };

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


{ pkgs, stdenv, nodejs, fetchurl, neededNatives, self }:

{
  nativeDeps = {
    "node-expat"."*" = [ pkgs.expat ];
    "rbytes"."0.0.2" = [ pkgs.openssl ];
    "phantomjs"."~1.9" = [ pkgs.phantomjs ];
  };

  buildNodePackage = import ../development/web/nodejs/build-node-package.nix {
    inherit stdenv nodejs neededNatives;
    inherit (pkgs) runCommand;
  };

  patchLatest = srcAttrs:
    let src = fetchurl srcAttrs; in pkgs.runCommand src.name {} ''
      mkdir unpack
      cd unpack
      tar xf ${src}
      mv */ package 2>/dev/null || true
      sed -i -e "s/: \"latest\"/: \"*\"/" package/package.json
      tar cf $out *
    '';

  /* Put manual packages below here (ideally eventually managed by npm2nix */
} // import ./node-packages-generated.nix { inherit self fetchurl; inherit (pkgs) lib; }

Make generated node expression overridable in nodePackages.

{ pkgs, stdenv, nodejs, fetchurl, neededNatives, self, generated ? ./node-packages-generated.nix }:

{
  nativeDeps = {
    "node-expat"."*" = [ pkgs.expat ];
    "rbytes"."0.0.2" = [ pkgs.openssl ];
    "phantomjs"."~1.9" = [ pkgs.phantomjs ];
  };

  buildNodePackage = import ../development/web/nodejs/build-node-package.nix {
    inherit stdenv nodejs neededNatives;
    inherit (pkgs) runCommand;
  };

  patchLatest = srcAttrs:
    let src = fetchurl srcAttrs; in pkgs.runCommand src.name {} ''
      mkdir unpack
      cd unpack
      tar xf ${src}
      mv */ package 2>/dev/null || true
      sed -i -e "s/: \"latest\"/: \"*\"/" package/package.json
      tar cf $out *
    '';

  /* Put manual packages below here (ideally eventually managed by npm2nix */
} // import generated { inherit self fetchurl; inherit (pkgs) lib; }


# This is a nix-shell for use with the nix package manager.
# If you have nix installed, you may simply run `nix-shell`
# in this repo, and have all dependencies ready in the new shell.

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = with pkgs;
    [
      stdenv

      antlr4
      cacert
      cmake
      diffutils
      git
      gperftools
      jdk11
      lcov
      libunwind
      libuuid
      pkg-config
      python310
      python310Packages.orderedmultidict
      python310Packages.psutil
      swig
      tcl
      time
      zlib

      # Ease development
      ccache
    ];
  shellHook =
  ''
    export CMAKE_CXX_COMPILER_LAUNCHER=ccache
  '';
}

Add more convenience tool dependencies for developers.

# This is a nix-shell for use with the nix package manager.
# If you have nix installed, you may simply run `nix-shell`
# in this repo, and have all dependencies ready in the new shell.

{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = with pkgs;
    [
      stdenv

      antlr4
      cacert
      cmake
      diffutils
      git
      gperftools
      jdk11
      lcov
      libunwind
      libuuid
      pkg-config
      python310
      python310Packages.orderedmultidict
      python310Packages.psutil
      swig
      tcl
      time
      zlib

      # Libraries for USE_HOST_* use
      flatbuffers
      capnproto

      # Ease development
      ccache
      ninja
      clang-tools
    ];
  shellHook =
  ''
    export CMAKE_CXX_COMPILER_LAUNCHER=ccache
  '';
}


{ lib, buildGoModule, fetchFromGitLab }:

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

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

  vendorSha256 = "189qs6vmx63vwsjmc4qgf1y8xjsi7x6l1f5c3kd8j8jnagl26z4h";

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

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

Add homepage URL instead of variable

{ lib, buildGoModule, fetchFromGitLab }:

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

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

  vendorSha256 = "189qs6vmx63vwsjmc4qgf1y8xjsi7x6l1f5c3kd8j8jnagl26z4h";

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

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


# This file is autogenerated from update.sh in the same directory.
{
  dev = {
    version = "30.0.1568.0";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-30.0.1568.0.tar.xz";
    sha256 = "0c30mbaj98ibyvg855zsqggy3mzhpwkaiw3x37na5hw6qabqizbf";
  };
  beta = {
    version = "29.0.1547.22";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-29.0.1547.22.tar.xz";
    sha256 = "1vaz1abhs0x5frkx3xcgcdpi1n0mmrijfh57kqz54mw7xjlh71vm";
  };
  stable = {
    version = "28.0.1500.71";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-28.0.1500.71.tar.xz";
    sha256 = "1w8hkbb17bwq9myhj7fig27pn50qlwdfrqs04xjvam4ah3w6qb0r";
  };
}

Update beta and dev release channels.

# This file is autogenerated from update.sh in the same directory.
{
  dev = {
    version = "30.0.1573.2";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-30.0.1573.2.tar.xz";
    sha256 = "1pbph4jz0svaawk06zajq73x0xm73f9kdiflhad2709f4y23gzjz";
  };
  beta = {
    version = "29.0.1547.32";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-29.0.1547.32.tar.xz";
    sha256 = "14p5s1xn15mdrlf87hv4y9kczw5r8s461a56kkdzb5xzyq25ph8w";
  };
  stable = {
    version = "28.0.1500.71";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-28.0.1500.71.tar.xz";
    sha256 = "1w8hkbb17bwq9myhj7fig27pn50qlwdfrqs04xjvam4ah3w6qb0r";
  };
}


{ stdenv, fetchgit, python2Packages }:

python2Packages.buildPythonApplication rec {
  name = "grin-1.2.1";
  namePrefix = "";

  src = fetchgit {
    url = "git://github.com/rkern/grin";
    rev = "8dd4b5309b3bc04fe9d3e71836420f7d8d4a293f";
    sha256 = "0vz2aahwdcy1296g4w3i79dkvmzk9jc2n2zmlcvlg5m3s6h7b6jd";
  };

  buildInputs = with python2Packages; [ nose ];

  meta = {
    homepage = https://pypi.python.org/pypi/grin;
    description = "A grep program configured the way I like it";
    platforms = stdenv.lib.platforms.all;
    maintainers = [ stdenv.lib.maintainers.sjagoe ];
  };
}

Use fetchFromGitHub instead of fetchgit

{ stdenv, fetchFromGitHub, python2Packages }:

python2Packages.buildPythonApplication rec {
  program = "grin";
  version = "1.2.1";
  name = "${program}-${version}";
  namePrefix = "";

  src = fetchFromGitHub {
    owner = "rkern";
    repo = program;
    rev = "8dd4b5309b3bc04fe9d3e71836420f7d8d4a293f";
    sha256 = "0vz2aahwdcy1296g4w3i79dkvmzk9jc2n2zmlcvlg5m3s6h7b6jd";
  };

  buildInputs = with python2Packages; [ nose ];

  meta = {
    homepage = https://github.com/rkern/grin;
    description = "A grep program configured the way I like it";
    platforms = stdenv.lib.platforms.all;
    maintainers = [ stdenv.lib.maintainers.sjagoe ];
  };
}


{stdenv, fetchurl, libao, libmad, libid3tag, zlib}:

stdenv.mkDerivation rec {
  name = "mpg321-0.2.13-2";

  src = fetchurl {
    url = "mirror://sourceforge/mpg321/0.2.13/${name}.tar.gz";
    sha256 = "0zx9xyr97frlyrwyk2msm9h1sn2b84vqaxcy5drbzcd2n585lwlx";
  };

  buildInputs = [libao libid3tag libmad zlib];

  meta = {
    description = "Command-line MP3 player";
    homepage = http://mpg321.sourceforge.net/;
    license = stdenv.lib.licenses.gpl2;
    maintainers = [ ];
    platforms = stdenv.lib.platforms.gnu;
  };
}

Update mpg321 from 0.2.13-2 to 0.3.2.

{stdenv, fetchurl, libao, libmad, libid3tag, zlib, alsaLib}:

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

  src = fetchurl {
    url = "mirror://sourceforge/mpg321/${version}/mpg321_${version}.orig.tar.gz";
    sha256 = "0ki8mh76bbmdh77qsiw682dvi8y468yhbdabqwg05igmwc1wqvq5";
  };

  configureFlags = [
    ("--enable-alsa=" + (if stdenv.isLinux then "yes" else "no"))
  ];

  buildInputs = [libao libid3tag libmad zlib]
    ++ stdenv.lib.optional stdenv.isLinux alsaLib;

  installTargets = "install install-man";

  meta = with stdenv.lib; {
    description = "Command-line MP3 player";
    homepage = http://mpg321.sourceforge.net/;
    license = licenses.gpl2;
    maintainers = [ maintainers.rycee ];
    platforms = platforms.gnu;
  };
}


{ stdenv, fetchFromGitHub }:

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

  src = fetchFromGitHub {
    sha256 = "08pmjhqkwldhmcwjhi2l27slf1fk6nxxfaihnk2637pqkycy8z0c";
    rev = "v${version}";
    repo = "libcli";
    owner = "dparrish";
  };

  enableParallelBuilding = true;

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

  meta = with stdenv.lib; {
    description = "Emulate a Cisco-style telnet command-line interface";
    homepage = http://sites.dparrish.com/libcli;
    license = licenses.lgpl21Plus;
    platforms = platforms.linux;
    maintainers = with maintainers; [ nckx ];
  };
}

Fix build on gcc 5

{ stdenv, fetchFromGitHub, fetchurl }:

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

  src = fetchFromGitHub {
    sha256 = "08pmjhqkwldhmcwjhi2l27slf1fk6nxxfaihnk2637pqkycy8z0c";
    rev = "v${version}";
    repo = "libcli";
    owner = "dparrish";
  };

  patches =
    [ (fetchurl {
        url = "https://github.com/dparrish/libcli/commit/ebc5a09db457ee1be9996711463cbbafe5ea72d5.patch";
        sha256 = "0szjiw3gd7by1sv924shnngfxvc98xvaqvx228b575xq93xxjcwl";
      })
    ];

  enableParallelBuilding = true;

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

  meta = with stdenv.lib; {
    description = "Emulate a Cisco-style telnet command-line interface";
    homepage = http://sites.dparrish.com/libcli;
    license = licenses.lgpl21Plus;
    platforms = platforms.linux;
    maintainers = with maintainers; [ nckx ];
  };
}


{ stdenv, python, buildEnv, makeWrapper, recursivePthLoader, extraLibs ? [] }:

# Create a python executable that knows about additional packages.

(buildEnv {
  name = "python-${python.version}-wrapper";
  paths = extraLibs ++ [ python makeWrapper recursivePthLoader ];
  ignoreCollisions = false;

  postBuild = ''
    . "${makeWrapper}/nix-support/setup-hook"
    mkdir -p "$out/bin"
    cd "${python}/bin"
    for prg in *; do
      echo "$prg --> $out/bin/$prg"
      rm -f "$out/bin/$prg"
      makeWrapper "${python}/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out"
    done
  '';
}) // {
  inherit python;
  inherit (python) meta;
}

Fix pythonWrapper when all of the binaries come from python

{ stdenv, python, buildEnv, makeWrapper, recursivePthLoader, extraLibs ? [] }:

# Create a python executable that knows about additional packages.

(buildEnv {
  name = "python-${python.version}-wrapper";
  paths = extraLibs ++ [ python makeWrapper recursivePthLoader ];
  ignoreCollisions = false;

  postBuild = ''
    . "${makeWrapper}/nix-support/setup-hook"
    if [ -L "$out/bin" ]; then
        unlink "$out/bin"
    fi
    mkdir -p "$out/bin"
    cd "${python}/bin"
    for prg in *; do
      echo "$prg --> $out/bin/$prg"
      rm -f "$out/bin/$prg"
      makeWrapper "${python}/bin/$prg" "$out/bin/$prg" --set PYTHONHOME "$out"
    done
  '';
}) // {
  inherit python;
  inherit (python) meta;
}


{ stdenv, fetchurl, openssl, libidn, glib, pkgconfig, zlib }:

stdenv.mkDerivation rec {
  name = "loudmouth-1.4.3";

  src = fetchurl {
    url = "mirror://gnome/sources/loudmouth/1.4/${name}.tar.bz2";
    sha256 = "1qr9z73i33y49pbpq6zy7q537g0iyc8sm56rjf0ylwcv01fkzacm";
  };

  patches = [ ./glib-2.32.patch ];

  configureFlags = "--with-ssl=openssl";

  propagatedBuildInputs = [ openssl libidn glib zlib ];

  buildInputs = [ pkgconfig ];

  meta = {
    description = "A lightweight C library for the Jabber protocol";
  };
}

Apply digest auth fix from Arch Linux.

{ stdenv, fetchurl, openssl, libidn, glib, pkgconfig, zlib }:

stdenv.mkDerivation rec {
  name = "loudmouth-1.4.3";

  src = fetchurl {
    url = "mirror://gnome/sources/loudmouth/1.4/${name}.tar.bz2";
    sha256 = "1qr9z73i33y49pbpq6zy7q537g0iyc8sm56rjf0ylwcv01fkzacm";
  };

  patches = [
    ./glib-2.32.patch
    (fetchurl rec {
      name = "01-fix-sasl-md5-digest-uri.patch";
      url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/"
          + "${name}?h=packages/loudmouth";
      sha256 = "0y79vbklscgp8248iirllwmgk4q0wwyl3gmxz7l9frc2384xvanm";
    })
  ];

  configureFlags = "--with-ssl=openssl";

  propagatedBuildInputs = [ openssl libidn glib zlib ];

  buildInputs = [ pkgconfig ];

  meta = {
    description = "A lightweight C library for the Jabber protocol";
  };
}


{stdenv, fetchurl, cmake, ruby}:

stdenv.mkDerivation {
  name = "yajl-2.0.1";

  src = fetchurl {
    url = http://github.com/lloyd/yajl/tarball/2.0.1;
    name = "yajl-2.0.1.tar.gz";
    sha256 = "08a7bgmdpvi6w9f9bxx5f42njwmwzdf6jz3w6ila7jgbl5mhknf2";
  };

  buildInputs = [ cmake ruby ];

  meta = {
    description = "Yet Another JSON Library";
    longDescription = ''
      YAJL is a small event-driven (SAX-style) JSON parser written in ANSI
      C, and a small validating JSON generator.
    '';
    homepage = http://lloyd.github.com/yajl/;
    license = stdenv.lib.license.isc;
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [
      z77z
    ];
  };
}

Make yajl build on Darwin.

{stdenv, fetchurl, cmake, ruby, darwinInstallNameToolUtility}:

stdenv.mkDerivation {
  name = "yajl-2.0.1";

  src = fetchurl {
    url = http://github.com/lloyd/yajl/tarball/2.0.1;
    name = "yajl-2.0.1.tar.gz";
    sha256 = "08a7bgmdpvi6w9f9bxx5f42njwmwzdf6jz3w6ila7jgbl5mhknf2";
  };

  buildInputs = [ cmake ruby ]
    ++ stdenv.lib.optional stdenv.isDarwin darwinInstallNameToolUtility;

  meta = {
    description = "Yet Another JSON Library";
    longDescription = ''
      YAJL is a small event-driven (SAX-style) JSON parser written in ANSI
      C, and a small validating JSON generator.
    '';
    homepage = http://lloyd.github.com/yajl/;
    license = stdenv.lib.license.isc;
    platforms = with stdenv.lib.platforms; [ linux darwin ];
    maintainers = with stdenv.lib.maintainers; [
      z77z
    ];
  };
}


{ fetchurl, stdenv, perl, python, zip, xmlto, zlib }:

stdenv.mkDerivation rec {
  name = "zziplib-0.13.56";

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

  buildInputs = [ perl python zip xmlto zlib ];

  doCheck = true;

  meta = {
    description = "Zziplib, a library to extract data from files archived in a zip file";

    longDescription = ''
      The zziplib library is intentionally lightweight, it offers the ability
      to easily extract data from files archived in a single zip
      file.  Applications can bundle files into a single zip archive and
      access them.  The implementation is based only on the (free) subset of
      compression with the zlib algorithm which is actually used by the
      zip/unzip tools.
    '';

    licenses = [ "LGPLv2+" "MPLv1.1" ];

    homepage = http://zziplib.sourceforge.net/;

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

Build only where Python is supported.

{ fetchurl, stdenv, perl, python, zip, xmlto, zlib }:

stdenv.mkDerivation rec {
  name = "zziplib-0.13.56";

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

  buildInputs = [ perl python zip xmlto zlib ];

  doCheck = true;

  meta = {
    description = "Zziplib, a library to extract data from files archived in a zip file";

    longDescription = ''
      The zziplib library is intentionally lightweight, it offers the ability
      to easily extract data from files archived in a single zip
      file.  Applications can bundle files into a single zip archive and
      access them.  The implementation is based only on the (free) subset of
      compression with the zlib algorithm which is actually used by the
      zip/unzip tools.
    '';

    licenses = [ "LGPLv2+" "MPLv1.1" ];

    homepage = http://zziplib.sourceforge.net/;

    maintainers = [ stdenv.lib.maintainers.ludo ];
    platforms = python.passthru.platforms;
  };
}


{fetchurl, ...}:
fetchurl {
  url = http://www.bootsplash.de/files/themes/Theme-GNU.tar.bz2;
  md5 = "61969309d23c631e57b0a311102ef034";
}

Update Theme-GNU location to something more reliable

{fetchurl, ...}:
fetchurl {
  url = http://mirrors.kernel.org/gentoo/distfiles/Theme-GNU.tar.bz2;
  md5 = "61969309d23c631e57b0a311102ef034";
}


{stdenv, fetchurl}:

stdenv.mkDerivation rec {
  name = "acpid-2.0.17";

  src = fetchurl {
    url = "http://tedfelix.com/linux/${name}.tar.xz";
    sha256 = "0gksl6z3sb6yyk7bdmldxsrncvprd3rny0i8ggl4m95nvv3x5drn";
  };

  preBuild = ''
    makeFlagsArray=(BINDIR=$out/bin SBINDIR=$out/sbin MAN8DIR=$out/share/man/man8)
  '';

  meta = {
    homepage = http://tedfelix.com/linux/acpid-netlink.html;
    description = "A daemon for delivering ACPI events to userspace programs";
    license = stdenv.lib.licenses.gpl2Plus;
    platforms = stdenv.lib.platforms.linux;
  };
}

Update acpid from 2.0.17 -> 2.0.20

{stdenv, fetchurl}:

stdenv.mkDerivation rec {
  name = "acpid-2.0.20";

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

  preBuild = ''
    makeFlagsArray=(BINDIR=$out/bin SBINDIR=$out/sbin MAN8DIR=$out/share/man/man8)
  '';

  meta = {
    homepage = http://tedfelix.com/linux/acpid-netlink.html;
    description = "A daemon for delivering ACPI events to userspace programs";
    license = stdenv.lib.licenses.gpl2Plus;
    platforms = stdenv.lib.platforms.linux;
  };
}


{ lib, kdeIntegration, ... }:
attrs:
{
  postConfigure = attrs.postConfigure + ''
    sed -e '/CPPUNIT_TEST(Import_Export_Import);/d' -i './sw/qa/inc/swmodeltestbase.hxx'
  '';
  configureFlags = attrs.configureFlags ++ [
    (lib.enableFeature kdeIntegration "kf5")
  ];
  patches = attrs.patches ++ [ ./xdg-open-brief.patch ];
  postPatch = attrs.postPatch + ''
    substituteInPlace shell/source/unix/exec/shellexec.cxx \
      --replace /usr/bin/xdg-open ${if kdeIntegration then "kde-open5" else "xdg-open"}
  '';
}

Define patches, don't add to it

{ lib, kdeIntegration, ... }:
attrs:
{
  postConfigure = attrs.postConfigure + ''
    sed -e '/CPPUNIT_TEST(Import_Export_Import);/d' -i './sw/qa/inc/swmodeltestbase.hxx'
  '';
  configureFlags = attrs.configureFlags ++ [
    (lib.enableFeature kdeIntegration "kf5")
  ];
  patches = [ ./xdg-open-brief.patch ];
  postPatch = attrs.postPatch + ''
    substituteInPlace shell/source/unix/exec/shellexec.cxx \
      --replace /usr/bin/xdg-open ${if kdeIntegration then "kde-open5" else "xdg-open"}
  '';
}


{ stdenv, lib, go, fetchFromGitHub }:

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

  src = fetchFromGitHub {
    owner = "coreos";
    repo = "fleet";
    rev = "v${version}";
    sha256 = "0dc95dpqqc2rclbvgdqjcilrkji7lrpigdrzpwm3nbgz58vkfnz3";
  };

  buildInputs = [ go ];

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

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

  meta = with stdenv.lib; {
    description = "A distributed init system";
    homepage = http://coreos.com/using-coreos/clustering/;
    license = licenses.asl20;
    maintainers = with maintainers; [ cstrahan offline ];
    platforms = platforms.unix;
  };
}

Add myself as a maintainer

{ stdenv, lib, go, fetchFromGitHub }:

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

  src = fetchFromGitHub {
    owner = "coreos";
    repo = "fleet";
    rev = "v${version}";
    sha256 = "0dc95dpqqc2rclbvgdqjcilrkji7lrpigdrzpwm3nbgz58vkfnz3";
  };

  buildInputs = [ go ];

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

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

  meta = with stdenv.lib; {
    description = "A distributed init system";
    homepage = http://coreos.com/using-coreos/clustering/;
    license = licenses.asl20;
    maintainers = with maintainers; [
      cstrahan
      jgeerds
      offline
    ];
    platforms = platforms.unix;
  };
}


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

with lib;

let
  cfg = config.nix.gc;
in

{
  options = {
    nix.gc.automatic = mkOption {
      type = types.bool;
      default = false;
      description = "Automatically run the garbage collector at a specific time.";
    };

    nix.gc.user = mkOption {
      type = types.nullOr types.str;
      default = null;
      description = "User that runs the garbage collector.";
    };

    nix.gc.interval = mkOption {
      type = types.attrs;
      default = { Hour = 3; Minute = 15; };
      description = "The time interval at which the garbage collector will run.";
    };

    nix.gc.options = mkOption {
      type = types.str;
      default = "";
      example = "--max-freed $((64 * 1024**3))";
      description = ''
        Options given to <filename>nix-collect-garbage</filename> when the
        garbage collector is run automatically.
      '';
    };
  };

  config = mkIf cfg.automatic {

    launchd.daemons.nix-gc = {
      command = "${config.nix.package}/bin/nix-collect-garbage ${cfg.options}";
      environment.NIX_REMOTE = optionalString config.nix.useDaemon "daemon";
      serviceConfig.RunAtLoad = false;
      serviceConfig.StartCalendarInterval = [ cfg.interval ];
      serviceConfig.UserName = cfg.user;
    };

  };
}

Update `nix.gc` module with same indenting/formatting as NixOS module

# Based off: https://github.com/NixOS/nixpkgs/blob/master/nixos/modules/services/misc/nix-gc.nix
# When making changes please try to keep it in sync.
{ config, lib, ... }:

with lib;

let
  cfg = config.nix.gc;
in

{

  ###### interface

  options = {

    nix.gc = {

      automatic = mkOption {
        type = types.bool;
        default = false;
        description = "Automatically run the garbage collector at a specific time.";
      };

      user = mkOption {
        type = types.nullOr types.str;
        default = null;
        description = "User that runs the garbage collector.";
      };

      interval = mkOption {
        type = types.attrs;
        default = { Hour = 3; Minute = 15; };
        description = "The time interval at which the garbage collector will run.";
      };

      options = mkOption {
        type = types.str;
        default = "";
        example = "--max-freed $((64 * 1024**3))";
        description = ''
          Options given to <filename>nix-collect-garbage</filename> when the
          garbage collector is run automatically.
        '';
      };

    };

  };

  ###### implementation

  config = mkIf cfg.automatic {

    launchd.daemons.nix-gc = {
      command = "${config.nix.package}/bin/nix-collect-garbage ${cfg.options}";
      environment.NIX_REMOTE = optionalString config.nix.useDaemon "daemon";
      serviceConfig.RunAtLoad = false;
      serviceConfig.StartCalendarInterval = [ cfg.interval ];
      serviceConfig.UserName = cfg.user;
    };

  };
}


{ stdenv
, fetchurl
, lib

, libatomic_ops
}:

let
  version = "7.6.8";
in
stdenv.mkDerivation rec {
  name = "boehm-gc-${version}";

  src = fetchurl {
    url = "https://github.com/ivmai/bdwgc/releases/download/v${version}/gc-${version}.tar.gz";
    sha256 = "040ac5cdbf1bebc7c8cd4928996bbae0c54497c151ea5639838fa0128102e258";
  };

  buildInputs = [
    libatomic_ops
  ];

  configureFlags = [
    "--enable-cplusplus"
    "--enable-large-config"
  ];

  meta = with lib; {
    description = "The Boehm-Demers-Weiser conservative garbage collector for C and C++";
    homepage = http://hboehm.info/gc/;
    license = licenses.free;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}

Revert "boehm-gc: 7.6.6 -> 7.6.8"

{ stdenv
, fetchurl
, lib

, libatomic_ops
}:

let
  version = "7.6.6";
in
stdenv.mkDerivation rec {
  name = "boehm-gc-${version}";

  src = fetchurl {
    url = "https://github.com/ivmai/bdwgc/releases/download/v${version}/gc-${version}.tar.gz";
    # We need the multihash because they delete old releases
    multihash = "QmZCCEGDkqYPG3TJU9M5YcmiMgJAeCBYLtqGjrszHSQvXs";
    sha256 = "e968edf8f80d83284dd473e00a5e3377addc2df261ffb7e6dc77c9a34a0039dc";
  };

  buildInputs = [
    libatomic_ops
  ];

  configureFlags = [
    "--enable-cplusplus"
    "--enable-large-config"
  ];

  meta = with lib; {
    description = "The Boehm-Demers-Weiser conservative garbage collector for C and C++";
    homepage = http://hboehm.info/gc/;
    license = licenses.free;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}


# vim: et:sw=2:sts=2

{ nixpkgs ? import <nixpkgs> {} }:

with nixpkgs;
with pkgs;
with haskellPackages;

let
  tcd = pkgs.callPackage ./libtcd.nix {};
in
  mkDerivation {
    pname = "Tides";
    version = "0.1.0.0";
    src = ./.;
    isLibrary = true;
    isExecutable = true;
    libraryHaskellDepends = [ base ];
    executableHaskellDepends = [ base HSH old-locale random time tz ];
    executableSystemDepends = [ tcd ];
    testHaskellDepends = [ base process ];
    description = "A program for exploring tidal prediction data";
    license = stdenv.lib.licenses.mit;
  }

Use harmonics package in Tides package

# vim: et:sw=2:sts=2

{ nixpkgs ? import <nixpkgs> {}, harmonicsType ? "free" }:

with nixpkgs;
with pkgs;
with haskellPackages;

let
  tcd       = pkgs.callPackage ./libtcd.nix    {};
  harmonics = pkgs.callPackage ./harmonics.nix { type = harmonicsType; };
in
  mkDerivation {
    pname = "Tides";
    version = "0.1.0.0";
    src = ./.;
    isLibrary = true;
    isExecutable = true;
    libraryHaskellDepends = [ base ];
    executableHaskellDepends = [ base HSH old-locale random time tz ];
    executableSystemDepends = [ tcd ];
    testHaskellDepends = [ base process ];
    configureFlags = [ "--ghc-option=-DDEFAULT_TIDE_DB_PATH=\"${harmonics}/share/xtide\"" ];
    description = "A program for exploring tidal prediction data";
    license = stdenv.lib.licenses.mit;
  }


{ pkgs }:

{
  allowBroken = false;
  allowUnfree = true;

  # Verify new pkgs with this on before submitting a pull request to nixpkgs
  #build-use-sandbox = true;

  packageOverrides = pkgs : rec {

    st = with pkgs; (pkgs.st.override {
      conf = builtins.readFile ../st/config.def.h;
    });

    # Bundle collections of packages.
    # https://nixos.org/wiki/Howto_keep_multiple_packages_up_to_date_at_once
    # Gilligan's nixpks configuration: https://github.com/gilligan/nixconfig

    toolsEnv = with pkgs; buildEnv {
      name = "toolsEnv";
      paths = [
        (gnupg20.override { # gnupg21 will not import my keys
          pinentry = pinentry_ncurses;
          x11Support = false;
        })
        bind            # Provides nslookup, dig
        dos2unix        # Convert between dos and unix line endings
        git             # Source control
        htop            # An interactive process viewer for Linux
        lsof            # Tool to list open files
        mosh            # The mobile shell
        neovim          # Neovim, my editor of choice
        pandoc          # Universal document converter
        pngnq           # Lossy PNG compressor
        psmisc          # includes killall
        pwgen           # Password generator
        keybase         # Keybase.io client
        python
        silver-searcher # A code-searching tool similar to ack, but faster
        tmux            # Terminal multiplexer
        unzip
        wget
      ];
    };
  };
}

Set gnupg overrides outside of toolsEnv

{ pkgs }:

{
  allowBroken = false;
  allowUnfree = true;

  # Verify new pkgs with this on before submitting a pull request to nixpkgs
  #build-use-sandbox = true;

  packageOverrides = pkgs : rec {

    st = with pkgs; (pkgs.st.override {
      conf = builtins.readFile ../st/config.def.h;
    });

    # Use gnupg without gui
    # Pin to gnupg20 since gnupg21 has a bug where it won't import my keys
    gnupg = with pkgs; gnupg20.override {
      pinentry = pkgs.pinentry_ncurses;
      x11Support = false;
    };

    # Bundle collections of packages.
    # https://nixos.org/wiki/Howto_keep_multiple_packages_up_to_date_at_once
    # Gilligan's nixpks configuration: https://github.com/gilligan/nixconfig

    toolsEnv = with pkgs; buildEnv {
      name = "toolsEnv";
      paths = [
        bind            # Provides nslookup, dig
        dos2unix        # Convert between dos and unix line endings
        git             # Source control
        gnupg           # GnuPG for encrypting and signing
        htop            # An interactive process viewer for Linux
        lsof            # Tool to list open files
        mosh            # The mobile shell
        neovim          # Neovim, my editor of choice
        pandoc          # Universal document converter
        pngnq           # Lossy PNG compressor
        psmisc          # includes killall
        pwgen           # Password generator
        keybase         # Keybase.io client
        python
        silver-searcher # A code-searching tool similar to ack, but faster
        tmux            # Terminal multiplexer
        unzip
        wget
      ];
    };
  };
}


{ haskellLib, nixpkgs, thunkSet, runCommand }:

self: super: {
  _dep = super._dep or {} // thunkSet ./dep // {
    stage2Script = runCommand "stage2.nix" {
      GEN_STAGE2 = builtins.readFile (nixpkgs.path + "/pkgs/development/compilers/ghcjs/gen-stage2.rb");
      buildCommand = ''
        echo "$GEN_STAGE2" > gen-stage2.rb && chmod +x gen-stage2.rb
        patchShebangs .
        ./gen-stage2.rb "${self._dep."ghcjs-boot"}" >"$out"
      '';
      nativeBuildInputs = with nixpkgs; [
        ruby cabal2nix
      ];
    } "";
  };

  # Setup: Unknown build tool hspec-discover
  megaparsec = haskellLib.dontCheck super.megaparsec;
  # Setup: Unknown build tool hspec-discover
  modern-uri = haskellLib.dontCheck super.modern-uri;
  # Version compatible with ghc-mod 0.5.8.0
  cabal-helper = haskellLib.doJailbreak (self.callHackage "cabal-helper" "0.7.3.0" {});
  # missing semigroups pkg
  ListLike = haskellLib.addBuildDepend super.ListLike self.semigroups;
  #
  ghc-mod = haskellLib.doJailbreak super.ghc-mod;
}

Fix stage2script to not look like setup hook

{ haskellLib, nixpkgs, thunkSet, runCommand }:

self: super: {
  _dep = super._dep or {} // thunkSet ./dep // {
    stage2Script = runCommand "stage2" {
      GEN_STAGE2 = builtins.readFile (nixpkgs.path + "/pkgs/development/compilers/ghcjs/gen-stage2.rb");
      buildCommand = ''
        echo "$GEN_STAGE2" > gen-stage2.rb && chmod +x gen-stage2.rb
        patchShebangs .
        mkdir -p "$out"
        ./gen-stage2.rb "${self._dep."ghcjs-boot"}" > "$out/default.nix"
      '';
      nativeBuildInputs = with nixpkgs; [
        ruby cabal2nix
      ];
    } "";
  };

  # Setup: Unknown build tool hspec-discover
  megaparsec = haskellLib.dontCheck super.megaparsec;
  # Setup: Unknown build tool hspec-discover
  modern-uri = haskellLib.dontCheck super.modern-uri;
  # Version compatible with ghc-mod 0.5.8.0
  cabal-helper = haskellLib.doJailbreak (self.callHackage "cabal-helper" "0.7.3.0" {});
  # missing semigroups pkg
  ListLike = haskellLib.addBuildDepend super.ListLike self.semigroups;
  #
  ghc-mod = haskellLib.doJailbreak super.ghc-mod;
}


{stdenv, fetchurl, coreutils ? null}:

stdenv.mkDerivation {
  name = "diffutils-2.8.1";

  src = fetchurl {
    url = mirror://gnu/diffutils/diffutils-2.8.1.tar.gz;
    md5 = "71f9c5ae19b60608f6c7f162da86a428";
  };

  preConfigure = ''
    configureFlags="--infodir=$out/share/info --mandir=$out/share/man"
  '';

  /* If no explicit coreutils is given, use the one from stdenv. */
  buildInputs = [coreutils];

  meta = {
    homepage = http://www.gnu.org/software/diffutils/diffutils.html;
    description = "Commands for showing the differences between files (diff, cmp, etc.)";

    platforms = stdenv.lib.platforms.all;
    maintainers = [ stdenv.lib.maintainers.simons ];
  };
}

Revert revision 24602. diffutils is part of stdenv and shouldn't have been modified in trunk.

{stdenv, fetchurl, coreutils ? null}:

stdenv.mkDerivation {
  name = "diffutils-2.8.1";

  src = fetchurl {
    url = mirror://gnu/diffutils/diffutils-2.8.1.tar.gz;
    md5 = "71f9c5ae19b60608f6c7f162da86a428";
  };

  /* If no explicit coreutils is given, use the one from stdenv. */
  buildInputs = [coreutils];

  meta = {
    homepage = http://www.gnu.org/software/diffutils/diffutils.html;
    description = "Commands for showing the differences between files (diff, cmp, etc.)";
  };
}


{ stdenv, fetchFromGitHub, pkgconfig, gettext, glib, gtk3, libnotify }:

stdenv.mkDerivation rec {

  name = "cbatticon-${version}";
  version = "1.6.8";

  src = fetchFromGitHub {
    owner = "valr";
    repo = "cbatticon";
    rev = version;
    sha256 = "16g26vin1693dbdr9qsnw36fdchx394lp79gvp7gcbw0w1ny9av6";
  };

  makeFlags = "PREFIX=$(out)";

  nativeBuildInputs = [ pkgconfig gettext ];

  buildInputs =  [ glib gtk3 libnotify ];

  meta = with stdenv.lib; {
    description = "Lightweight and fast battery icon that sits in the system tray";
    homepage = https://github.com/valr/cbatticon;
    license = licenses.gpl2;
    maintainers = [ maintainers.domenkozar ];
    platforms = platforms.linux;
  };
}

Fix build by removing -Wno-format

{ stdenv, fetchFromGitHub, pkgconfig, gettext, glib, gtk3, libnotify }:

stdenv.mkDerivation rec {

  name = "cbatticon-${version}";
  version = "1.6.8";

  src = fetchFromGitHub {
    owner = "valr";
    repo = "cbatticon";
    rev = version;
    sha256 = "16g26vin1693dbdr9qsnw36fdchx394lp79gvp7gcbw0w1ny9av6";
  };

  patchPhase = ''
    sed -i -e 's/ -Wno-format//g' Makefile
  '';

  makeFlags = "PREFIX=$(out)";

  nativeBuildInputs = [ pkgconfig gettext ];

  buildInputs =  [ glib gtk3 libnotify ];

  meta = with stdenv.lib; {
    description = "Lightweight and fast battery icon that sits in the system tray";
    homepage = https://github.com/valr/cbatticon;
    license = licenses.gpl2;
    maintainers = [ maintainers.domenkozar ];
    platforms = platforms.linux;
  };
}


# Common configuration for virtual machines running under QEMU (using
# virtio).

{ config, pkgs, ... }:

{
  boot.initrd.availableKernelModules = [ "virtio_net" "virtio_pci" "virtio_blk" "virtio_scsi" "9p" "9pnet_virtio" ];
  boot.initrd.kernelModules = [ "virtio_balloon" "virtio_console" "virtio_rng" ];

  boot.initrd.postDeviceCommands =
    ''
      # Set the system time from the hardware clock to work around a
      # bug in qemu-kvm > 1.5.2 (where the VM clock is initialised
      # to the *boot time* of the host).
      hwclock -s
    '';
}

Revert "Make it possible to boot NixOS from a SCSI Disk on KVM"

# Common configuration for virtual machines running under QEMU (using
# virtio).

{ config, pkgs, ... }:

{
  boot.initrd.availableKernelModules = [ "virtio_net" "virtio_pci" "virtio_blk" "9p" "9pnet_virtio" ];
  boot.initrd.kernelModules = [ "virtio_balloon" "virtio_console" "virtio_rng" ];

  boot.initrd.postDeviceCommands =
    ''
      # Set the system time from the hardware clock to work around a
      # bug in qemu-kvm > 1.5.2 (where the VM clock is initialised
      # to the *boot time* of the host).
      hwclock -s
    '';
}


{ lib
, fetchPypi
, pythonOlder
, buildPythonPackage
, pip
, pytestCheckHook
, pytest-xdist
, click
, setuptools-scm
, pep517
}:

buildPythonPackage rec {
  pname = "pip-tools";
  version = "6.3.1";

  disabled = pythonOlder "3.6";

  src = fetchPypi {
    inherit pname version;
    sha256 = "992d968df6f1a19d4d37c53b68b3d4b601b894fb3ee0926d1fa762ebc7c7e9e9";
  };

  checkInputs = [
    pytestCheckHook
    pytest-xdist
  ];

  nativeBuildInputs = [
    setuptools-scm
  ];

  propagatedBuildInputs = [
    click
    pep517
    pip
  ];

  disabledTests = [
    # these want internet access
    "network"
    "test_direct_reference_with_extras"
  ];

  meta = with lib; {
    description = "Keeps your pinned dependencies fresh";
    homepage = "https://github.com/jazzband/pip-tools/";
    license = licenses.bsd3;
    maintainers = with maintainers; [ zimbatm ];
  };
}

Revert "Revert "python3Packages.pip-tools: 6.3.1 -> 6.4.0""

{ lib
, fetchPypi
, pythonOlder
, buildPythonPackage
, pip
, pytestCheckHook
, pytest-xdist
, click
, setuptools-scm
, pep517
}:

buildPythonPackage rec {
  pname = "pip-tools";
  version = "6.4.0";

  disabled = pythonOlder "3.6";

  src = fetchPypi {
    inherit pname version;
    sha256 = "65553a15b1ba34be5e43889345062e38fb9b219ffa23b084ca0d4c4039b6f53b";
  };

  checkInputs = [
    pytestCheckHook
    pytest-xdist
  ];

  nativeBuildInputs = [
    setuptools-scm
  ];

  propagatedBuildInputs = [
    click
    pep517
    pip
  ];

  disabledTests = [
    # these want internet access
    "network"
    "test_direct_reference_with_extras"
  ];

  meta = with lib; {
    description = "Keeps your pinned dependencies fresh";
    homepage = "https://github.com/jazzband/pip-tools/";
    license = licenses.bsd3;
    maintainers = with maintainers; [ zimbatm ];
  };
}


{system, pkgs}:

rec {
### Databases

  rooms = import ../pkgs/databases/rooms {
    inherit (pkgs) stdenv;
  };

  staff = import ../pkgs/databases/staff {
    inherit (pkgs) stdenv;
  };

  zipcodes = import ../pkgs/databases/zipcodes {
    inherit (pkgs) stdenv;
  };

### Web applications

  stafftracker = import ../pkgs/webapplications/stafftracker {
    inherit (pkgs) stdenv;
  };
}

Use callPackage for the top-level composition expression

{system, pkgs}:

let
  callPackage = pkgs.lib.callPackageWith (pkgs // self);

  self = {
  ### Databases

    rooms = callPackage ../pkgs/databases/rooms { };

    staff = callPackage ../pkgs/databases/staff { };

    zipcodes = callPackage ../pkgs/databases/zipcodes { };

  ### Web applications

    stafftracker = callPackage ../pkgs/webapplications/stafftracker { };
  };
in
self


{ stdenv, fetchurl, cmake, qt4, perl, shared_mime_info, libvorbis, taglib
, flac, libsamplerate, libdvdread, lame, libsndfile, libmad, gettext
, kdelibs, kdemultimedia, automoc4, phonon, libkcddb ? null
}:

stdenv.mkDerivation rec {
  name = "k3b-2.0.2";

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

  buildInputs =
    [ cmake qt4 perl shared_mime_info libvorbis taglib
      flac libsamplerate libdvdread lame libsndfile
      libmad gettext stdenv.gcc.libc
      kdelibs kdemultimedia automoc4 phonon
      libkcddb
    ];

  enableParallelBuilding = true;

  meta = with stdenv.lib; {
    description = "CD/DVD Burning Application for KDE";
    license = licenses.gpl2Plus;
    maintainers = [ maintainers.sander maintainers.urkud maintainers.phreedom ];
    platforms = with stdenv.lib.platforms; linux;
  };
}

Install runtime executables for k3b.

{ stdenv, fetchurl, cmake, qt4, perl, shared_mime_info, libvorbis, taglib
, flac, libsamplerate, libdvdread, lame, libsndfile, libmad, gettext
, transcode, cdrdao, dvdplusrwtools, vcdimager
, kdelibs, kdemultimedia, automoc4, phonon, libkcddb ? null
}:

stdenv.mkDerivation rec {
  name = "k3b-2.0.2";

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

  buildInputs =
    [ cmake qt4 perl shared_mime_info libvorbis taglib
      flac libsamplerate libdvdread lame libsndfile
      libmad gettext stdenv.gcc.libc
      kdelibs kdemultimedia automoc4 phonon
      libkcddb
    ];

  enableParallelBuilding = true;

  # at runtime, k3b needs the executables cdrdao, cdrecord, dvd+rw-format,
  # eMovix, growisofs, mkisofs, normalize, readcd, transcode, vcdxbuild,
  # vcdxminfo, and vcdxrip
  propagatedUserEnvPkgs = [ transcode dvdplusrwtools cdrdao vcdimager ];

  meta = with stdenv.lib; {
    description = "CD/DVD Burning Application for KDE";
    license = licenses.gpl2Plus;
    maintainers = [ maintainers.sander maintainers.urkud maintainers.phreedom ];
    platforms = with stdenv.lib.platforms; linux;
  };
}


{ lib, fetchFromGitLab, rustPlatform }:

rustPlatform.buildRustPackage rec {
  pname = "tezos-rust-libs";
  version = "1.0";

  src = fetchFromGitLab {
    owner = "tezos";
    repo = "tezos-rust-libs";
    rev = "v${version}";
    sha256 = "1ffkzbvb0ls4wk9205g3xh2c26cmwnl68x43gh6dm9z4xsic94v5";
  };

  cargoSha256 = "0dgyqfr3dvvdwdi1wvpd7v9j21740jy4zwrwiwknw7csb4bq9wfx";

  preBuild = ''
    mkdir .cargo
    mv cargo-config .cargo/config
  '';

  postInstall = ''
    mkdir $out/lib/tezos-rust-libs
    cp -r rustc-bls12-381/include $out/include
    cp $out/lib/librustc_bls12_381.a $out/lib/tezos-rust-libs
    cp $out/lib/librustzcash.a $out/lib/tezos-rust-libs
  '';

  doCheck = true;

  meta = {
    homepage = "https://gitlab.com/tezos/tezos-rust-libs";
    description = "Tezos: all rust dependencies and their dependencies";
    license = lib.licenses.mit;
    maintainers = [ lib.maintainers.ulrikstrid ];
  };
}

Fix tezos-rust-libs to work with tezos-sapling

{ lib, fetchFromGitLab, rustPlatform }:

rustPlatform.buildRustPackage rec {
  pname = "tezos-rust-libs";
  version = "1.0";

  src = fetchFromGitLab {
    owner = "tezos";
    repo = "tezos-rust-libs";
    rev = "v${version}";
    sha256 = "1ffkzbvb0ls4wk9205g3xh2c26cmwnl68x43gh6dm9z4xsic94v5";
  };

  cargoSha256 = "0dgyqfr3dvvdwdi1wvpd7v9j21740jy4zwrwiwknw7csb4bq9wfx";

  preBuild = ''
    mkdir .cargo
    mv cargo-config .cargo/config
  '';

  postInstall = ''
    cp -r rustc-bls12-381/include $out/include
    cp -r librustzcash/include $out
    cp -r $out/lib $out/tmp
    mkdir $out/lib/tezos-rust-libs
    mv $out/tmp/ $out/lib/tezos-rust-libs/
  '';

  doCheck = true;

  meta = {
    homepage = "https://gitlab.com/tezos/tezos-rust-libs";
    description = "Tezos: all rust dependencies and their dependencies";
    license = lib.licenses.mit;
    maintainers = [ lib.maintainers.ulrikstrid ];
  };
}


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

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

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

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ gnutls readline zlib libidn ];

  configureFlags = [
    "--with-readline=${readline}"
  ];

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

Make explicit that 'dev' output of readline is used

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

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

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

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ gnutls readline zlib libidn ];

  configureFlags = [
    "--with-readline=${readline.dev}"
  ];

  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, openssl }:

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

  src = fetchurl {
    url = "https://www.tarsnap.com/scrypt/${name}.tgz";
    sha256 = "1m39hpfby0fdjam842773i5w7pa0qaj7f0r22jnchxsj824vqm0p";
  };

  buildInputs = [ openssl ];

  meta = {
    description = "Encryption utility";
    homepage    = https://www.tarsnap.com/scrypt.html;
    license     = stdenv.lib.licenses.bsd2;
    platforms   = stdenv.lib.platforms.all;
    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
  };
}

Revert "nixpkgs: scrypt 1.1.6 -> 1.2.0"

{ stdenv, fetchurl, openssl }:

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

  src = fetchurl {
    url = "https://www.tarsnap.com/scrypt/scrypt-1.1.6.tgz";
    sha256 = "dfd0d1a544439265bbb9b58043ad3c8ce50a3987b44a61b1d39fd7a3ed5b7fb8";
  };

  buildInputs = [ openssl ];

  meta = {
    description = "Encryption utility";
    homepage    = https://www.tarsnap.com/scrypt.html;
    license     = stdenv.lib.licenses.bsd2;
    platforms   = stdenv.lib.platforms.all;
    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
  };
}


{ stdenv, lib, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  name = "terraform-${version}";
  version = "0.7.6";
  rev = "v${version}";

  goPackagePath = "github.com/hashicorp/terraform";

  src = fetchFromGitHub {
    inherit rev;
    owner = "hashicorp";
    repo = "terraform";
    sha256 = "02k3g38jk2dm70dkfl4w6is563m4abqvip5srv8bhv7xcgj0nfkq";
  };

  postInstall = ''
    # remove all plugins, they are part of the main binary now
    for i in $bin/bin/*; do
      if [[ $(basename $i) != terraform ]]; then
        rm "$i"
      fi
    done
  '';

  meta = with stdenv.lib; {
    description = "Tool for building, changing, and versioning infrastructure";
    homepage = "https://www.terraform.io/";
    license = licenses.mpl20;
    maintainers = with maintainers; [ zimbatm ];
  };
}

Add myself as a maintainer

{ stdenv, lib, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  name = "terraform-${version}";
  version = "0.7.6";
  rev = "v${version}";

  goPackagePath = "github.com/hashicorp/terraform";

  src = fetchFromGitHub {
    inherit rev;
    owner = "hashicorp";
    repo = "terraform";
    sha256 = "02k3g38jk2dm70dkfl4w6is563m4abqvip5srv8bhv7xcgj0nfkq";
  };

  postInstall = ''
    # remove all plugins, they are part of the main binary now
    for i in $bin/bin/*; do
      if [[ $(basename $i) != terraform ]]; then
        rm "$i"
      fi
    done
  '';

  meta = with stdenv.lib; {
    description = "Tool for building, changing, and versioning infrastructure";
    homepage = "https://www.terraform.io/";
    license = licenses.mpl20;
    maintainers = with maintainers; [
      jgeerds
      zimbatm
    ];
  };
}


{ stdenv, fetchFromGitHub, valgrind }:

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

  src = fetchFromGitHub {
    sha256 = "1bhvcq8fxxsqnpg5qa6k3nsyhq0nl0iarh08sqzclww27hlpyay2";
    rev = "r${version}";
    repo = "lz4";
    owner = "Cyan4973";
  };

  patches = [ ./install-on-freebsd.patch ] ;

  buildInputs = stdenv.lib.optional doCheck valgrind;

  # An ever-changing __DATE__ isn't very reproducible, so we must override it.
  # But rather than displaying "()" or 1970, let --version show useful info:
  NIX_CFLAGS_COMPILE = [
    ''-D__DATE__="${stdenv.cc.cc.name}"''
    "-Wno-builtin-macro-redefined"
  ];

  enableParallelBuilding = true;

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

  doCheck = false; # tests take a very long time
  checkTarget = "test";

  meta = with stdenv.lib; {
    description = "Extremely fast compression algorithm";
    longDescription = ''
      Very fast lossless compression algorithm, providing compression speed
      at 400 MB/s per core, with near-linear scalability for multi-threaded
      applications. It also features an extremely fast decoder, with speed in
      multiple GB/s per core, typically reaching RAM speed limits on
      multi-core systems.
    '';
    homepage = https://code.google.com/p/lz4/;
    license = with licenses; [ bsd2 gpl2Plus ];
    platforms = platforms.unix;
    maintainers = with maintainers; [ nckx ];
  };
}

Revert "lz4: be just a bit more reproducible"

{ stdenv, fetchFromGitHub, valgrind }:

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

  src = fetchFromGitHub {
    sha256 = "1bhvcq8fxxsqnpg5qa6k3nsyhq0nl0iarh08sqzclww27hlpyay2";
    rev = "r${version}";
    repo = "lz4";
    owner = "Cyan4973";
  };

  buildInputs = stdenv.lib.optional doCheck valgrind;

  enableParallelBuilding = true;

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

  doCheck = false; # tests take a very long time
  checkTarget = "test";

  patches = [ ./install-on-freebsd.patch ] ;

  meta = with stdenv.lib; {
    description = "Extremely fast compression algorithm";
    longDescription = ''
      Very fast lossless compression algorithm, providing compression speed
      at 400 MB/s per core, with near-linear scalability for multi-threaded
      applications. It also features an extremely fast decoder, with speed in
      multiple GB/s per core, typically reaching RAM speed limits on
      multi-core systems.
    '';
    homepage = https://code.google.com/p/lz4/;
    license = with licenses; [ bsd2 gpl2Plus ];
    platforms = platforms.unix;
    maintainers = with maintainers; [ nckx ];
  };
}


{ stdenv, fetchurl, cairo, expat, fftwSinglePrec, fluidsynth, glib, gtk, jackaudio, ladspaH
, libglade, lv2, pkgconfig }:

stdenv.mkDerivation rec {
  name = "calf-${version}";
  version = "0.0.19-rc7";

  src = fetchurl {
    url = "mirror://sourceforge/calf/${name}.tar.gz";
    sha256 = "0515pzc7ishrq0j5hza83s0yp3x34r977h776lpky389whcyf45j";
  };

  buildInputs =
    [ cairo jackaudio fftwSinglePrec fluidsynth gtk glib expat libglade ladspaH lv2 pkgconfig ];

  meta = with stdenv.lib; {
    homepage = http://calf.sourceforge.net;
    description = "A set of high quality open source audio plugins for musicians";
    license = licenses.lgpl2;
    maintainers = [ maintainers.goibhniu ];
  };
}

Tidy up the expression for the Calf audio plugin pack

{ stdenv, fetchurl, cairo, expat, fftwSinglePrec, fluidsynth, glib
, gtk, jackaudio, ladspaH , libglade, lv2, pkgconfig }:

stdenv.mkDerivation rec {
  name = "calf-${version}";
  version = "0.0.19-rc7";

  src = fetchurl {
    url = "mirror://sourceforge/calf/${name}.tar.gz";
    sha256 = "0515pzc7ishrq0j5hza83s0yp3x34r977h776lpky389whcyf45j";
  };

  buildInputs = [
    cairo expat fftwSinglePrec fluidsynth glib gtk jackaudio ladspaH
    libglade lv2 pkgconfig
  ];

  meta = with stdenv.lib; {
    homepage = http://calf.sourceforge.net;
    description = "A set of high quality open source audio plugins for musicians";
    license = licenses.lgpl2;
    maintainers = [ maintainers.goibhniu ];
    platforms = platforms.linux;
  };
}


{ stdenv, fetchurl, kernel, perl, makeWrapper }:

assert stdenv.isLinux;

stdenv.mkDerivation {
  name = "blcr-0.8.3-${kernel.version}";

  src = fetchurl {
    url = https://ftg.lbl.gov/assets/projects/CheckpointRestart/downloads/blcr-0.8.3.tar.gz;
    sha256 = "c8243c9a7a215d4fc4e8f2199045711cf711a6f2e0b39a94413478ffae110eac";
  };

  buildInputs = [ perl makeWrapper ];

  preConfigure = ''
    configureFlagsArray=(
      --with-linux=${kernel}/lib/modules/${kernel.version}/build
      --with-kmod-dir=$out/lib/modules/${kernel.version}
      --with-system-map=${kernel}/System.map
    )
  '';

  postInstall = ''
    for prog in "$out/bin/"*
    do
      wrapProgram "$prog" --prefix LD_LIBRARY_PATH ":" "$out/lib"
    done
  '';

  meta = {
    description = "Berkeley Lab Checkpoint/Restart for Linux (BLCR)";
    homepage = https://ftg.lbl.gov/projects/CheckpointRestart/;
    license = "GPL2";
  };
}

Use the modDirVersion attribute to access the module dir

{ stdenv, fetchurl, kernel, perl, makeWrapper }:

assert stdenv.isLinux;

stdenv.mkDerivation {
  name = "blcr-0.8.3-${kernel.version}";

  src = fetchurl {
    url = https://ftg.lbl.gov/assets/projects/CheckpointRestart/downloads/blcr-0.8.3.tar.gz;
    sha256 = "c8243c9a7a215d4fc4e8f2199045711cf711a6f2e0b39a94413478ffae110eac";
  };

  buildInputs = [ perl makeWrapper ];

  preConfigure = ''
    configureFlagsArray=(
      --with-linux=${kernel}/lib/modules/${kernel.modDirVersion}/build
      --with-kmod-dir=$out/lib/modules/${kernel.modDirVersion}
      --with-system-map=${kernel}/System.map
    )
  '';

  postInstall = ''
    for prog in "$out/bin/"*
    do
      wrapProgram "$prog" --prefix LD_LIBRARY_PATH ":" "$out/lib"
    done
  '';

  meta = {
    description = "Berkeley Lab Checkpoint/Restart for Linux (BLCR)";
    homepage = https://ftg.lbl.gov/projects/CheckpointRestart/;
    license = "GPL2";
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "acpi-1.5";

  src = fetchurl {
    url = "http://ftp.de.debian.org/debian/pool/main/a/acpi/acpi_1.5.orig.tar.gz";
    sha256 = "1pb020j627ldjm1askqfzp6cjxrs79ail8svihanv7pgbg5r3zsp";
  };

  meta = {
    longDescription = ''
      Linux ACPI client is a small command-line
      program that attempts to replicate the functionality of
      the "old" `apm' command on ACPI systems.  It includes
      battery and thermal information.
    '';
    homepage = http://grahame.angrygoats.net/acpi.shtml;
    license = "GPLv2+";
  };
}

Update acpi, fix homepage, download from sourceforge.

{ stdenv, fetchurl }:

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

  src = fetchurl {
    url = "mirror://sf/acpiclient/${version}/${name}.tar.gz";
    sha256 = "0cawznhkzb51yxa599d1xkw05nklmjrrmd79vmjkkzf4002d4qgd";
  };

  meta = {
    longDescription = ''
      Linux ACPI client is a small command-line
      program that attempts to replicate the functionality of
      the "old" `apm' command on ACPI systems.  It includes
      battery and thermal information.
    '';
    homepage = http://sourceforge.net/projects/acpiclient/;
    license = "GPLv2+";
  };
}


{ stdenv, fetchurl, readline }:

stdenv.mkDerivation rec {
  name = "remake-${version}";
  remakeVersion = "4.1";
  dbgVersion = "1.1";
  version = "${remakeVersion}+dbg-${dbgVersion}";

  src = fetchurl {
    url = "mirror://sourceforge/project/bashdb/remake/${version}/remake-${remakeVersion}+dbg${dbgVersion}.tar.bz2";
    sha256 = "1zi16pl7sqn1aa8b7zqm9qnd9vjqyfywqm8s6iap4clf86l7kss2";
  };

  buildInputs = [ readline ];

  meta = {
    homepage = http://bashdb.sourceforge.net/remake/;
    license = stdenv.lib.licenses.gpl3;
    description = "GNU Make with comprehensible tracing and a debugger";
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [ bjornfor ];
  };
}

Allow remake to build on darwin

{ stdenv, fetchurl, readline }:

stdenv.mkDerivation rec {
  name = "remake-${version}";
  remakeVersion = "4.1";
  dbgVersion = "1.1";
  version = "${remakeVersion}+dbg-${dbgVersion}";

  src = fetchurl {
    url = "mirror://sourceforge/project/bashdb/remake/${version}/remake-${remakeVersion}+dbg${dbgVersion}.tar.bz2";
    sha256 = "1zi16pl7sqn1aa8b7zqm9qnd9vjqyfywqm8s6iap4clf86l7kss2";
  };

  buildInputs = [ readline ];

  meta = {
    homepage = http://bashdb.sourceforge.net/remake/;
    license = stdenv.lib.licenses.gpl3;
    description = "GNU Make with comprehensible tracing and a debugger";
    platforms = with stdenv.lib.platforms; linux ++ darwin;
    maintainers = with stdenv.lib.maintainers; [ bjornfor ];
  };
}


{ lib, buildPackages, fetchFromGitHub, fetchpatch, perl, buildLinux, ... } @ args:

buildLinux (args // {
  # NOTE: bcachefs-tools should be updated simultaneously to preserve compatibility
  version = "5.13.0-2021.10.01";
  modDirVersion = "5.13.0";

  src = fetchFromGitHub {
    owner = "koverstreet";
    repo = "bcachefs";
    rev = "4114ced1db465b8f4e7f4d6a78aa11416a9ab5d9";
    sha256 = "sha256-viFC3HHIcjUTDPvloSKKsz9PuSLyvxfYnrtkVUB79mQ=";
  };

  extraConfig = "BCACHEFS_FS m";

  extraMeta = {
    branch = "master";
    hydraPlatforms = []; # Should the testing kernels ever be built on Hydra?
    maintainers = with lib.maintainers; [ davidak chiiruno ];
    platforms = [ "x86_64-linux" ];
  };

} // (args.argsOverride or {}))

Revert "linux_testing_bcachefs: upstream tarballs rather patchsets"

{ lib
, fetchpatch
, kernel
, date ? "2021-07-08"
, commit ? "3693b2ca83ff9eda49660b31299d2bebe3a1075f"
, diffHash ? "1sfq3vwc2kxa761s292f2cqrm0vvqvkdx6drpyn5yaxwnapwidcw"
, kernelPatches # must always be defined in bcachefs' all-packages.nix entry because it's also a top-level attribute supplied by callPackage
, argsOverride ? {}
, ...
} @ args:

# NOTE: bcachefs-tools should be updated simultaneously to preserve compatibility
(kernel.override ( args // {
  argsOverride = {
    version = "${kernel.version}-bcachefs-unstable-${date}";
    extraMeta = {
      branch = "master";
      maintainers = with lib.maintainers; [ davidak chiiruno ];
      platforms = [ "x86_64-linux" ];
    };
  } // argsOverride;

  kernelPatches = [ {
      name = "bcachefs-${commit}";
      patch = fetchpatch {
        name = "bcachefs-${commit}.diff";
        url = "https://evilpiepirate.org/git/bcachefs.git/rawdiff/?id=${commit}&id2=v${lib.versions.majorMinor kernel.version}";
        sha256 = diffHash;
      };
      extraConfig = "BCACHEFS_FS m";
    } ] ++ kernelPatches;

})).overrideAttrs ({ meta ? {}, ... }: { meta = meta // { broken = true; }; })


{ lib, stdenv, fetchurl }:

stdenv.mkDerivation rec {
  pname = "mtools";
  version = "4.0.38";

  src = fetchurl {
    url = "mirror://gnu/mtools/${pname}-${version}.tar.bz2";
    sha256 = "sha256-e5RIX0huffCMymiwChZKE8049MY8uGhNGIdZ7nvF5yk=";
  };

  patches = lib.optional stdenv.isDarwin ./UNUSED-darwin.patch;

  # fails to find X on darwin
  configureFlags = lib.optional stdenv.isDarwin "--without-x";

  doCheck = true;

  meta = with lib; {
    homepage = "https://www.gnu.org/software/mtools/";
    description = "Utilities to access MS-DOS disks";
    platforms = platforms.unix;
    license = licenses.gpl3;
  };
}

Fix build on darwin by providing libiconv to buildInputs

{ lib, stdenv, fetchurl, libiconv }:

stdenv.mkDerivation rec {
  pname = "mtools";
  version = "4.0.38";

  src = fetchurl {
    url = "mirror://gnu/mtools/${pname}-${version}.tar.bz2";
    sha256 = "sha256-e5RIX0huffCMymiwChZKE8049MY8uGhNGIdZ7nvF5yk=";
  };

  patches = lib.optional stdenv.isDarwin ./UNUSED-darwin.patch;

  # fails to find X on darwin
  configureFlags = lib.optional stdenv.isDarwin "--without-x";

  buildInputs = lib.optional stdenv.isDarwin libiconv;

  doCheck = true;

  meta = with lib; {
    homepage = "https://www.gnu.org/software/mtools/";
    description = "Utilities to access MS-DOS disks";
    platforms = platforms.unix;
    license = licenses.gpl3;
  };
}


{ stdenv, fetchurl, pkgconfig, gst-plugins-base }:

stdenv.mkDerivation rec {
  name = "gst-rtsp-server-1.14.0";

  meta = with stdenv.lib; {
    description = "Gstreamer RTSP server";
    homepage    = "https://gstreamer.freedesktop.org";
    longDescription = ''
      a library on top of GStreamer for building an RTSP server.
    '';
    license     = licenses.lgpl2Plus;
    platforms   = platforms.linux ++ platforms.darwin;
    maintainers = with maintainers; [ bkchr ];
  };

  src = fetchurl {
    url = "${meta.homepage}/src/gst-rtsp-server/${name}.tar.xz";
    sha256 = "0mlp9ms5hfbyzyvmc9xgi7934g4zrh1sbgky2p9zc5fqprvs0rbb";
  };

  outputs = [ "out" "dev" ];

  nativeBuildInputs = [ pkgconfig ];

  buildInputs = [ gst-plugins-base ];
}

Switch to meson build system

{ stdenv, fetchurl, meson, ninja, pkgconfig
, gst-plugins-base, gettext, gobjectIntrospection
}:

stdenv.mkDerivation rec {
  name = "gst-rtsp-server-1.14.0";

  meta = with stdenv.lib; {
    description = "Gstreamer RTSP server";
    homepage    = "https://gstreamer.freedesktop.org";
    longDescription = ''
      a library on top of GStreamer for building an RTSP server.
    '';
    license     = licenses.lgpl2Plus;
    platforms   = platforms.linux ++ platforms.darwin;
    maintainers = with maintainers; [ bkchr ];
  };

  src = fetchurl {
    url = "${meta.homepage}/src/gst-rtsp-server/${name}.tar.xz";
    sha256 = "0mlp9ms5hfbyzyvmc9xgi7934g4zrh1sbgky2p9zc5fqprvs0rbb";
  };

  outputs = [ "out" "dev" ];

  nativeBuildInputs = [ meson ninja gettext gobjectIntrospection pkgconfig ];

  buildInputs = [ gst-plugins-base ];
}


{ lib, buildGoModule, fetchFromGitLab, nix, subversion }:

buildGoModule rec {
  pname = "wp4nix";
  version = "1.0.0";

  src = fetchFromGitLab {
    domain = "git.helsinki.tools";
    owner = "helsinki-systems";
    repo = "wp4nix";
    rev = "v${version}";
    sha256 = "sha256-WJteeFUMr684yZEtUP13MqRjJ1UAeo48AzOPdLEE65w=";
  };

  vendorSha256 = "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=";

  postPatch = ''
    substituteInPlace main.go --replace nix-hash ${nix}/bin/nix-hash
    substituteInPlace svn.go --replace '"svn"' '"${subversion}/bin/svn"'
  '';

  meta = with lib; {
    description = "Packaging helper for Wordpress themes and plugins";
    homepage = "https://git.helsinki.tools/helsinki-systems/wp4nix";
    license = licenses.mit;
    maintainers = with maintainers; [ onny ];
    platforms = platforms.linux;
  };
}

Use makeWrapper instead of patching

{ lib
, buildGoModule
, fetchFromGitLab
, nix
, subversion
, makeWrapper
}:

buildGoModule rec {
  pname = "wp4nix";
  version = "1.0.0";

  src = fetchFromGitLab {
    domain = "git.helsinki.tools";
    owner = "helsinki-systems";
    repo = "wp4nix";
    rev = "v${version}";
    sha256 = "sha256-WJteeFUMr684yZEtUP13MqRjJ1UAeo48AzOPdLEE65w=";
  };

  vendorSha256 = "sha256-pQpattmS9VmO3ZIQUFn66az8GSmB4IvYhTTCFn6SUmo=";

  nativeBuildInputs = [
    makeWrapper
  ];

  postInstall = ''
    wrapProgram $out/bin/wp4nix \
      --prefix PATH : ${lib.makeBinPath [ nix subversion ]}
  '';

  meta = with lib; {
    description = "Packaging helper for Wordpress themes and plugins";
    homepage = "https://git.helsinki.tools/helsinki-systems/wp4nix";
    license = licenses.mit;
    maintainers = with maintainers; [ onny ];
    platforms = platforms.linux;
  };
}


{ lib, stdenv, fetchgit, gmp }:

stdenv.mkDerivation rec {
  pname = "cln";
  version = "1.3.6";

  src = fetchgit {
    url = "git://www.ginac.de/cln.git";
    rev = "cln_${builtins.replaceStrings [ "." ] [ "-" ] version}";
    sha256 = "sha256-P32F4TIDhE2Dwzydq8iFK6ch3kICJcXeeXHs5PBQG88=";
  };

  buildInputs = [ gmp ];

  meta = with lib; {
    description = "C/C++ library for numbers, a part of GiNaC";
    homepage = "https://www.ginac.de/CLN/";
    license = licenses.gpl2;
    platforms = platforms.unix; # Once had cygwin problems
  };
}

Revert "cln: fix darwin build"

{ lib, stdenv, fetchurl, gmp }:

stdenv.mkDerivation rec {
  pname = "cln";
  version = "1.3.6";

  src = fetchurl {
    url = "${meta.homepage}${pname}-${version}.tar.bz2";
    sha256 = "0jlq9l4hphk7qqlgqj9ihjp4m3rwjbhk6q4v00lsbgbri07574pl";
  };

  buildInputs = [ gmp ];

  meta = with lib; {
    description = "C/C++ library for numbers, a part of GiNaC";
    homepage = "https://www.ginac.de/CLN/";
    license = licenses.gpl2;
    platforms = platforms.unix; # Once had cygwin problems
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "chrony-1.27";

  src = fetchurl {
    url = "http://download.tuxfamily.org/chrony/${name}.tar.gz";
    sha256 = "17dfhcm5mrkg8ids0ajwscryr7fm7664kz10ygsa1ac047p3aj6l";
  };

  meta = with stdenv.lib; {
    description = "A pair of programs which are used to maintain the accuracy of the system clock on a computer.";
    homepage = "http://chrony.tuxfamily.org/";
    license = licenses.gpl2;
    platforms = platforms.unix;

    longDescription = ''
      Chronyd is a daemon which runs in background on the system. It obtains measurements via the network of the system clock’s offset relative to time servers on other systems and adjusts the system time accordingly. For isolated systems, the user can periodically enter the correct time by hand (using Chronyc). In either case, Chronyd determines the rate at which the computer gains or loses time, and compensates for this. Chronyd implements the NTP protocol and can act as either a client or a server.

      Chronyc provides a user interface to Chronyd for monitoring its performance and configuring various settings. It can do so while running on the same computer as the Chronyd instance it is controlling or a different computer.
    '';
  };
}

Add readline and libcap (on Linux) as dependencies

{ stdenv, fetchurl, libcap, readline }:

assert stdenv.isLinux -> libcap != null;

stdenv.mkDerivation rec {
  name = "chrony-1.27";

  src = fetchurl {
    url = "http://download.tuxfamily.org/chrony/${name}.tar.gz";
    sha256 = "17dfhcm5mrkg8ids0ajwscryr7fm7664kz10ygsa1ac047p3aj6l";
  };

  buildInputs = [ readline ] ++ stdenv.lib.optional stdenv.isLinux libcap;

  meta = with stdenv.lib; {
    description = "A pair of programs which are used to maintain the accuracy of the system clock on a computer.";
    homepage = "http://chrony.tuxfamily.org/";
    license = licenses.gpl2;
    platforms = platforms.unix;

    longDescription = ''
      Chronyd is a daemon which runs in background on the system. It obtains measurements via the network of the system clock’s offset relative to time servers on other systems and adjusts the system time accordingly. For isolated systems, the user can periodically enter the correct time by hand (using Chronyc). In either case, Chronyd determines the rate at which the computer gains or loses time, and compensates for this. Chronyd implements the NTP protocol and can act as either a client or a server.

      Chronyc provides a user interface to Chronyd for monitoring its performance and configuring various settings. It can do so while running on the same computer as the Chronyd instance it is controlling or a different computer.
    '';
  };
}


# A good source of information about how to fix the issues still
# standing with kernel 4.6.11 is the following wiki page:
# https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6). The
# TrackPoint and TouchPad issues there seem to have been fixed already.

{ config, pkgs, ... }:
{
  imports = [
    ../.
    ../../cpu-throttling.nix
    ../../acpi_call.nix
  ];

  # See https://linrunner.de/en/tlp/docs/tlp-faq.html#battery
  services.tlp.extraConfig = ''
    START_CHARGE_THRESH_BAT0=75
    STOP_CHARGE_THRESH_BAT0=80
    CPU_SCALING_GOVERNOR_ON_BAT=powersave
    ENERGY_PERF_POLICY_ON_BAT=powersave
  '';

  # Enable S3 suspend state: you have to manually follow the
  # instructions shown here: https://delta-xi.net/#056 in order to
  # produce the ACPI patched table. Put the CPIO archive in /boot and
  # then enable the following lines
  # boot.kernelParams = [
  #   "mem_sleep_default=deep"
  # ];
  # boot.initrd.prepend = [
  #   "/boot/acpi_override"
  # ];
}

Fix cpu-throttling service file reference

# A good source of information about how to fix the issues still
# standing with kernel 4.6.11 is the following wiki page:
# https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6). The
# TrackPoint and TouchPad issues there seem to have been fixed already.

{ config, pkgs, ... }:
{
  imports = [
    ../.
    ../../cpu-throttling-bug.nix
    ../../acpi_call.nix
  ];

  # See https://linrunner.de/en/tlp/docs/tlp-faq.html#battery
  services.tlp.extraConfig = ''
    START_CHARGE_THRESH_BAT0=75
    STOP_CHARGE_THRESH_BAT0=80
    CPU_SCALING_GOVERNOR_ON_BAT=powersave
    ENERGY_PERF_POLICY_ON_BAT=powersave
  '';

  # Enable S3 suspend state: you have to manually follow the
  # instructions shown here: https://delta-xi.net/#056 in order to
  # produce the ACPI patched table. Put the CPIO archive in /boot and
  # then enable the following lines
  # boot.kernelParams = [
  #   "mem_sleep_default=deep"
  # ];
  # boot.initrd.prepend = [
  #   "/boot/acpi_override"
  # ];
}


{ stdenv
, fetchurl
, flex
, makeWrapper

, getopt
, libxml2
}:

stdenv.mkDerivation rec {
  name = "xmlto-0.0.28";

  src = fetchurl {
    url = "http://fedorahosted.org/releases/x/m/xmlto/${name}.tar.bz2";
    sha256 = "0xhj8b2pwp4vhl9y16v3dpxpsakkflfamr191mprzsspg4xdyc0i";
  };

  buildInputs = [
    getopt
    libxml2
  ];

  preConfigure = ''
    while read line; do
      eval $line
    done < <(./configure --help 2>&1 | awk '{ if (/[A-Z][ ]*Name/) { print "export " $1 "=\"$(type -P " tolower($1) ")\""; } }')
  '';

  meta = with stdenv.lib; {
    description = "Front-end to an XSL toolchain";
    homepage = https://fedorahosted.org/xmlto/;
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}

Move to https and add multihash

{ stdenv
, fetchurl
, flex
, makeWrapper

, getopt
, libxml2
}:

stdenv.mkDerivation rec {
  name = "xmlto-0.0.28";

  src = fetchurl {
    url = "https://fedorahosted.org/releases/x/m/xmlto/${name}.tar.bz2";
    multihash = "QmQddXXS6g9PUpw1Z5HDBHTX8gg7hcwKs3KYSWqXaUkMM2";
    sha256 = "0xhj8b2pwp4vhl9y16v3dpxpsakkflfamr191mprzsspg4xdyc0i";
  };

  buildInputs = [
    getopt
    libxml2
  ];

  preConfigure = ''
    while read line; do
      eval $line
    done < <(./configure --help 2>&1 | awk '{ if (/[A-Z][ ]*Name/) { print "export " $1 "=\"$(type -P " tolower($1) ")\""; } }')
  '';

  meta = with stdenv.lib; {
    description = "Front-end to an XSL toolchain";
    homepage = https://fedorahosted.org/xmlto/;
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}


{ stdenv, fetchurl, x11, imlib2, libjpeg, libpng, giblib
, libXinerama, curl }:

stdenv.mkDerivation {
  name = "feh-1.14.1";

  src = fetchurl {
    url = http://www.chaosdorf.de/~derf/feh/feh-1.14.1.tar.bz2;
    sha256 = "1dask2pm7y2yjvxlwiyi0v4145alixp5lk8v68dcs0qxz8v1pqk1";
  };

  buildInputs = [x11 imlib2 giblib libjpeg libpng libXinerama curl];

  preBuild = ''
    makeFlags="PREFIX=$out"
  '';

  meta = {
    description = "A light-weight image viewer";
    homepage = https://derf.homelinux.org/projects/feh/;
    license = "BSD";
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}

Update the download URL for feh, which seems to have changed.

{ stdenv, fetchurl, x11, imlib2, libjpeg, libpng, giblib
, libXinerama, curl }:

stdenv.mkDerivation {
  name = "feh-1.14.1";

  src = fetchurl {
    url = http://feh.finalrewind.org/feh-1.14.1.tar.bz2;
    sha256 = "1dask2pm7y2yjvxlwiyi0v4145alixp5lk8v68dcs0qxz8v1pqk1";
  };

  buildInputs = [x11 imlib2 giblib libjpeg libpng libXinerama curl];

  preBuild = ''
    makeFlags="PREFIX=$out"
  '';

  meta = {
    description = "A light-weight image viewer";
    homepage = https://derf.homelinux.org/projects/feh/;
    license = "BSD";
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}


{ config, pkgs, ... }:

let
  neopkgs = import (
    pkgs.fetchFromGitHub {
      owner = "NixOS";
      repo = "nixpkgs";
      rev = "8f793ce6bb050252e92a987cc3c5bd48d5423a42";
      sha256 = "0fydxirp79s4svr2gadp3hsx2vrank904n8c5kprqh3jrzid90cg";
    }
  ) {};
in
{
  environment.variables = {
    EDITOR = "nvim";
  };

  environment.systemPackages = [
    neopkgs.neovim        # Neovim, my editor of choice
    pkgs.bash
    pkgs.curl
    pkgs.dos2unix         # Convert between dos and unix line endings
    pkgs.fish
    pkgs.git              # Source control
    pkgs.htop
    pkgs.inetutils        # Common net utils
    pkgs.isync            # Email MTA that is an alternative to OfflineIMAP
    pkgs.lynx
    pkgs.mosh             # The mobile shell
    pkgs.psmisc           # includes killall
    pkgs.pwgen            # Password generator
    pkgs.python
    pkgs.silver-searcher
    pkgs.tmux
    pkgs.wget
    pkgs.which            # Some programs depend on this
  ];
}

Remove acronym in comment about isync

{ config, pkgs, ... }:

let
  neopkgs = import (
    pkgs.fetchFromGitHub {
      owner = "NixOS";
      repo = "nixpkgs";
      rev = "8f793ce6bb050252e92a987cc3c5bd48d5423a42";
      sha256 = "0fydxirp79s4svr2gadp3hsx2vrank904n8c5kprqh3jrzid90cg";
    }
  ) {};
in
{
  environment.variables = {
    EDITOR = "nvim";
  };

  environment.systemPackages = [
    neopkgs.neovim        # Neovim, my editor of choice
    pkgs.bash
    pkgs.curl
    pkgs.dos2unix         # Convert between dos and unix line endings
    pkgs.fish
    pkgs.git              # Source control
    pkgs.htop
    pkgs.inetutils        # Common net utils
    pkgs.isync            # Email sync, an alternative to OfflineIMAP
    pkgs.lynx
    pkgs.mosh             # The mobile shell
    pkgs.psmisc           # includes killall
    pkgs.pwgen            # Password generator
    pkgs.python
    pkgs.silver-searcher
    pkgs.tmux
    pkgs.wget
    pkgs.which            # Some programs depend on this
  ];
}


{ stdenv, fetchsvn, ocaml, zlib, neko }:

stdenv.mkDerivation {
  name = "haxe-2.10";

  buildInputs = [ocaml zlib neko];

  src = fetchsvn {
    url = "http://haxe.googlecode.com/svn/tags/v2-10";
    sha256 = "dbd3c655e4136eb68a165ef83b96bfc1f0f2eb9ec8729603b19bcd717a61a679";
  };

  prePatch = ''
    sed -i -e 's|com.class_path <- \[|&"'"$out/lib/haxe/std/"'";|' main.ml
  '';

  installPhase = ''
    install -vd "$out/bin" "$out/lib/haxe/std"
    install -vt "$out/bin" haxe haxelib haxedoc
    find std -mindepth 1 -maxdepth 1 -path std/tools -o \
      -exec cp -vr '{}' "$out/lib/haxe/std" \;
  '';

  dontStrip = true;

  meta = {
    description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
    homepage = http://haxe.org;
    license = ["GPLv2" "BSD2" /*?*/ ];  # -> docs/license.txt
    maintainers = [stdenv.lib.maintainers.marcweber];
    platforms = stdenv.lib.platforms.linux;
  };
}

Remove build files of haxelib/haxedoc early.

{ stdenv, fetchsvn, ocaml, zlib, neko }:

stdenv.mkDerivation {
  name = "haxe-2.10";

  buildInputs = [ocaml zlib neko];

  src = fetchsvn {
    url = "http://haxe.googlecode.com/svn/tags/v2-10";
    sha256 = "dbd3c655e4136eb68a165ef83b96bfc1f0f2eb9ec8729603b19bcd717a61a679";
  };

  prePatch = ''
    sed -i -e 's|com.class_path <- \[|&"'"$out/lib/haxe/std/"'";|' main.ml
  '';

  postBuild = ''
    find std/tools -name '*.n' -delete
    rm std/tools/haxedoc/haxedoc std/tools/haxelib/haxelib
  '';

  installPhase = ''
    install -vd "$out/bin" "$out/lib/haxe/std"
    install -vt "$out/bin" haxe haxelib haxedoc
    cp -vr std "$out/lib/haxe"
  '';

  dontStrip = true;

  meta = {
    description = "Programming language targeting JavaScript, Flash, NekoVM, PHP, C++";
    homepage = http://haxe.org;
    license = ["GPLv2" "BSD2" /*?*/ ];  # -> docs/license.txt
    maintainers = [stdenv.lib.maintainers.marcweber];
    platforms = stdenv.lib.platforms.linux;
  };
}


{ stdenv, fetchurl, pythonPackages, lzop, postgresql, pv }:

pythonPackages.buildPythonPackage rec {
  name = "wal-e-${version}";
  version = "0.6.9";

  namePrefix = "";

  src = fetchurl {
    url = "https://github.com/wal-e/wal-e/archive/v${version}.tar.gz";
    sha256 = "1yzz9hic8amq7mp0kh04hsmwisk5r374ddja5g8345bl8y3bzbgk";
  };

  # needs tox
  doCheck = false;

  propagatedBuildInputs = [
    pythonPackages.boto
    pythonPackages.gevent
    postgresql
    lzop
    pv
  ];

  meta = {
    description = "A Postgres WAL-shipping disaster recovery and replication toolkit";
    homepage = https://github.com/wal-e/wal-e;
    maintainers = [ stdenv.lib.maintainers.rickynils ];
    license = stdenv.lib.licenses.bsd3;
    platforms = stdenv.lib.platforms.linux;
  };
}

Update from 0.6.9 to 0.6.10

{ stdenv, fetchurl, pythonPackages, lzop, postgresql, pv }:

pythonPackages.buildPythonPackage rec {
  name = "wal-e-${version}";
  version = "0.6.10";

  namePrefix = "";

  src = fetchurl {
    url = "https://github.com/wal-e/wal-e/archive/v${version}.tar.gz";
    sha256 = "1hms24xz7wx3b91vv56fhcc3j0cszwqwnmwhka4yl90202hvdir2";
  };

  # needs tox
  doCheck = false;

  propagatedBuildInputs = [
    pythonPackages.boto
    pythonPackages.gevent
    postgresql
    lzop
    pv
  ];

  meta = {
    description = "A Postgres WAL-shipping disaster recovery and replication toolkit";
    homepage = https://github.com/wal-e/wal-e;
    maintainers = [ stdenv.lib.maintainers.rickynils ];
    license = stdenv.lib.licenses.bsd3;
    platforms = stdenv.lib.platforms.linux;
  };
}


{ config, pkgs, ... }:

with pkgs.lib;

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

  config = mkIf config.gnu {

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

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

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

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

Disable GRUB by default on ARM.

{ config, pkgs, ... }:

with pkgs.lib;

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

  config = mkIf config.gnu {

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

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

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

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