{ stdenv, fetchurl }:

stdenv.mkDerivation {
  name = "dev86-0.16.18";

  src = fetchurl {
    url = http://www.debath.co.uk/dev86/Dev86src-0.16.18.tar.gz;
    sha256 = "1wcg2x8i2fq7kqgazx2il3qfmikyi4kfb23vm45yxlwq72l55604";
  };

  makeFlags = "PREFIX=$(out)";

  # Awful hackery to get dev86 to compile with recent gcc/binutils.
  # See http://bugs.gentoo.org/214964 for some inconclusive
  # discussion.
  preBuild =
    ''
      substituteInPlace makefile.in --replace "-O2" "" --replace "-O" ""
    '';

  meta = {
    description = "Linux 8086 development environment";
    homepage = http://www.debath.co.uk/;
  };
}

Update to 0.16.19 (old sources disappeared)

{ stdenv, fetchurl }:

stdenv.mkDerivation {
  name = "dev86-0.16.19";

  src = fetchurl {
    url = http://www.debath.co.uk/dev86/Dev86src-0.16.19.tar.gz;
    sha256 = "33398b87ca85e2b69e4062cf59f2f7354af46da5edcba036c6f97bae17b8d00e";
  };

  makeFlags = "PREFIX=$(out)";

  # Awful hackery to get dev86 to compile with recent gcc/binutils.
  # See http://bugs.gentoo.org/214964 for some inconclusive
  # discussion.
  preBuild =
    ''
      substituteInPlace makefile.in --replace "-O2" "" --replace "-O" ""
    '';

  meta = {
    description = "Linux 8086 development environment";
    homepage = http://www.debath.co.uk/;
  };
}


args: with args;
stdenv.mkDerivation rec {
	name = "gamin-0.1.9";

	src = fetchurl {
		url = "http://www.gnome.org/~veillard/gamin/sources/${name}.tar.gz";
		sha256 = "0fgjfyr0nlkpdxj94a4qfm82wypljdyv1b6l56v7i9jdx0hcdqhr";
	};

	buildInputs = [python pkgconfig glib];
	configureFlags = "--enable-shared --disable-static --disable-debug --with-python=${python}";
}

Fix compilation with glibc 2.9.

args: with args;
stdenv.mkDerivation rec {
	name = "gamin-0.1.9";

	src = fetchurl {
		url = "http://www.gnome.org/~veillard/gamin/sources/${name}.tar.gz";
		sha256 = "0fgjfyr0nlkpdxj94a4qfm82wypljdyv1b6l56v7i9jdx0hcdqhr";
	};

	buildInputs = [python pkgconfig glib];

        # `_GNU_SOURCE' is needed, e.g., to get `struct ucred' from
        # <sys/socket.h> with Glibc 2.9.
	configureFlags = "--enable-shared --disable-static --disable-debug"
          + " --with-python=${python} CPPFLAGS=-D_GNU_SOURCE";
}


{ stdenv, fetchurl, libgpgerror, gnupg, pkgconfig, glib, pth, libassuan
, useGnupg1 ? false, gnupg1 ? null }:

assert useGnupg1 -> gnupg1 != null;
assert !useGnupg1 -> gnupg != null;

let
  gpgPath = if useGnupg1 then
    "${gnupg1}/bin/gpg"
  else
    "${gnupg}/bin/gpg2";
in
stdenv.mkDerivation rec {
  name = "gpgme-1.6.0";

  src = fetchurl {
    url = "mirror://gnupg/gpgme/${name}.tar.bz2";
    sha256 = "17892sclz3yg45wbyqqrzzpq3l0icbnfl28f101b3062g8cy97dh";
  };

  propagatedBuildInputs = [ libgpgerror glib libassuan pth ];

  nativeBuildInputs = [ pkgconfig gnupg ];

  configureFlags = "--with-gpg=${gpgPath}";

  meta = {
    homepage = "http://www.gnupg.org/related_software/gpgme";
    description = "Library for making GnuPG easier to use";
    license = stdenv.lib.licenses.gpl2;
    platforms = stdenv.lib.platforms.unix;
    maintainers = with stdenv.lib.maintainers; [ fuuzetsu ];
  };
}

Use fixed path for GnuPG binaries

{ stdenv, fetchurl, libgpgerror, gnupg, pkgconfig, glib, pth, libassuan
, useGnupg1 ? false, gnupg1 ? null }:

assert useGnupg1 -> gnupg1 != null;
assert !useGnupg1 -> gnupg != null;

let
  gpgStorePath = if useGnupg1 then gnupg1 else gnupg;
  gpgProgram = if useGnupg1 then "gpg" else "gpg2";
in
stdenv.mkDerivation rec {
  name = "gpgme-1.6.0";

  src = fetchurl {
    url = "mirror://gnupg/gpgme/${name}.tar.bz2";
    sha256 = "17892sclz3yg45wbyqqrzzpq3l0icbnfl28f101b3062g8cy97dh";
  };

  propagatedBuildInputs = [ libgpgerror glib libassuan pth ];

  nativeBuildInputs = [ pkgconfig gnupg ];

  configureFlags = [
    "--with-gpg=${gpgStorePath}/bin/${gpgProgram}"
    "--enable-fixed-path=${gpgStorePath}/bin"
  ];

  meta = {
    homepage = "http://www.gnupg.org/related_software/gpgme";
    description = "Library for making GnuPG easier to use";
    license = stdenv.lib.licenses.gpl2;
    platforms = stdenv.lib.platforms.unix;
    maintainers = with stdenv.lib.maintainers; [ fuuzetsu ];
  };
}


{ fetchurl, stdenv }:

 stdenv.mkDerivation {
  name = "cfitsio-3.43";

  src = fetchurl {
    url = "ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3430.tar.gz";
    sha256 = "1rw481bv5srfmldf1h8bqmyljjh0siqh87xh6rip67ms59ssxpn8";
  };

  # Shared-only build
  buildFlags = "shared";
  patchPhase = '' sed -e '/^install:/s/libcfitsio.a //' -e 's@/bin/@@g' -i Makefile.in
   '';

  meta = with stdenv.lib; {
    homepage = https://heasarc.gsfc.nasa.gov/fitsio/;
    description = "Library for reading and writing FITS data files";
    longDescription =
      '' CFITSIO is a library of C and Fortran subroutines for reading and
         writing data files in FITS (Flexible Image Transport System) data
         format.  CFITSIO provides simple high-level routines for reading and
         writing FITS files that insulate the programmer from the internal
         complexities of the FITS format.  CFITSIO also provides many
         advanced features for manipulating and filtering the information in
         FITS files.
      '';
    # Permissive BSD-style license.
    license = "permissive";
    platforms = platforms.linux;
  };
}

Change has for 3.43 to reflect upstream

{ fetchurl, stdenv }:

 stdenv.mkDerivation {
  name = "cfitsio-3.43";

  src = fetchurl {
    url = "ftp://heasarc.gsfc.nasa.gov/software/fitsio/c/cfitsio3430.tar.gz";
    sha256 = "07fghxh5fl8nqk3q0dh8rvc83npnm0hisxzcj16a6r7gj5pmp40l";
  };

  # Shared-only build
  buildFlags = "shared";
  patchPhase = '' sed -e '/^install:/s/libcfitsio.a //' -e 's@/bin/@@g' -i Makefile.in
   '';

  meta = with stdenv.lib; {
    homepage = https://heasarc.gsfc.nasa.gov/fitsio/;
    description = "Library for reading and writing FITS data files";
    longDescription =
      '' CFITSIO is a library of C and Fortran subroutines for reading and
         writing data files in FITS (Flexible Image Transport System) data
         format.  CFITSIO provides simple high-level routines for reading and
         writing FITS files that insulate the programmer from the internal
         complexities of the FITS format.  CFITSIO also provides many
         advanced features for manipulating and filtering the information in
         FITS files.
      '';
    # Permissive BSD-style license.
    license = "permissive";
    platforms = platforms.linux;
  };
}


{ stdenv, fetchurl, glib, libxml2, pkgconfig, intltool, python
, gnomeSupport ? true, libgnome_keyring, sqlite, glib_networking }:

stdenv.mkDerivation {
  name = "libsoup-2.40.3";

  src = fetchurl {
    url = mirror://gnome/sources/libsoup/2.40/libsoup-2.40.3.tar.xz;
    sha256 = "82c92f1f6f4cbfd501df783ed87e7de9410b4a12a3bb0b19c64722e185d2bbc9";
  };

  buildNativeInputs = [ pkgconfig intltool python ];

  propagatedBuildInputs = [ glib libxml2 ]
    ++ stdenv.lib.optionals gnomeSupport [ libgnome_keyring sqlite ];

  passthru.propagatedUserEnvPackages = [ glib_networking ];

  # glib_networking is a runtime dependency, not a compile-time dependency
  configureFlags = "--disable-tls-check";

  preConfigure = ''
    substituteInPlace libsoup/tld-parser.py \
      --replace "/usr/bin/env python" ${python}/bin/python
  '';

  meta = {
    inherit (glib.meta) maintainers platforms;
  };
}

Revert "libsoup: Update to 2.40.3"

{ stdenv, fetchurl, glib, libxml2, pkgconfig
, gnomeSupport ? true, libgnome_keyring, sqlite, glib_networking }:

stdenv.mkDerivation {
  name = "libsoup-2.38.1";

  src = fetchurl {
    url = mirror://gnome/sources/libsoup/2.38/libsoup-2.38.1.tar.xz;
    sha256 = "16iza4y8pmc4sn90iid88fgminvgcqypy3s2qnmzkzm5qwzr5f3i";
  };

  buildNativeInputs = [ pkgconfig ];
  propagatedBuildInputs = [ glib libxml2 ]
    ++ stdenv.lib.optionals gnomeSupport [ libgnome_keyring sqlite ];
  passthru.propagatedUserEnvPackages = [ glib_networking ];

  # glib_networking is a runtime dependency, not a compile-time dependency
  configureFlags = "--disable-tls-check";

  meta = {
    inherit (glib.meta) maintainers platforms;
  };
}


{ buildEnv, qtbase }: name: paths:

buildEnv {
  inherit name;
  paths = [ qtbase ] ++ paths;

  pathsToLink = [ "/bin" "/mkspecs" "/include" "/lib" "/share" ];
  extraOutputsToInstall = [ "dev" ];

  postBuild = ''
    rm "$out/bin/qmake"
    cp "${qtbase.dev}/bin/qmake" "$out/bin"
    cat >"$out/bin/qt.conf" <<EOF
    [Paths]
    Prefix = $out
    Plugins = ${qtbase.qtPluginPrefix}
    Qml2Imports = ${qtbase.qtQmlPrefix}
    Documentation = ${qtbase.qtDocPrefix}
    EOF
  '';
}

Include the "out" derivation as well as the "dev" in qt5.full

{ buildEnv, qtbase }: name: paths:

buildEnv {
  inherit name;
  paths = [ qtbase ] ++ paths;

  pathsToLink = [ "/bin" "/mkspecs" "/include" "/lib" "/share" ];
  extraOutputsToInstall = [ "out" "dev" ];

  postBuild = ''
    rm "$out/bin/qmake"
    cp "${qtbase.dev}/bin/qmake" "$out/bin"
    cat >"$out/bin/qt.conf" <<EOF
    [Paths]
    Prefix = $out
    Plugins = ${qtbase.qtPluginPrefix}
    Qml2Imports = ${qtbase.qtQmlPrefix}
    Documentation = ${qtbase.qtDocPrefix}
    EOF
  '';
}


{ stdenv, fetchurl, unzip }:

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

  buildInputs = [ unzip ];

  sourceRoot = ".";

  buildFlags = [ "OSTYPE=linux" ];

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

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

Fix output path bin directory.

{ stdenv, fetchurl, unzip }:

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

  buildInputs = [ unzip ];

  sourceRoot = ".";

  buildFlags = [ "OSTYPE=linux" ];

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

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


{ stdenv, fetchurl, alsaLib, bash, help2man }:

stdenv.mkDerivation rec {
  name = "lirc-0.9.1";

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

  preBuild = "patchShebangs .";

  buildInputs = [ alsaLib help2man ];

  configureFlags = [
    "--with-driver=devinput"
    "--sysconfdir=$(out)/etc"
    "--enable-sandboxed"
  ];

  makeFlags = [ "m4dir=$(out)/m4" ];

  meta = with stdenv.lib; {
    description = "Allows to receive and send infrared signals";
    homepage = http://www.lirc.org/;
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = with maintainers; [ pSub ];
  };
}

Update from 0.9.1 to 0.9.1a

{ stdenv, fetchurl, alsaLib, bash, help2man }:

stdenv.mkDerivation rec {
  name = "lirc-0.9.1a";

  src = fetchurl {
    url = "mirror://sourceforge/lirc/${name}.tar.bz2";
    sha256 = "191vhgsds221rzpzjibj005pfr182hq65hniqfd0qqsl5h1zwq8r";
  };

  patches = [
    (fetchurl {
       url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/lirc-0.9.1a-fix-segfaults.patch?h=packages/lirc";
       sha256 = "00ainq7y8yh2r447968jid06cqfb1xirv24xxrkl0gvakrrv9gnh";
    })
  ];

  preBuild = "patchShebangs .";

  buildInputs = [ alsaLib help2man ];

  configureFlags = [
    "--with-driver=devinput"
    "--sysconfdir=$(out)/etc"
    "--enable-sandboxed"
  ];

  makeFlags = [ "m4dir=$(out)/m4" ];

  meta = with stdenv.lib; {
    description = "Allows to receive and send infrared signals";
    homepage = http://www.lirc.org/;
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = with maintainers; [ pSub ];
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  pname = "man-pages";
  version = "5.08";

  src = fetchurl {
    url = "mirror://kernel/linux/docs/man-pages/${pname}-${version}.tar.xz";
    sha256 = "1xzp3f6wvw3wplk1a1x09zfv0jp0pdc9wh95czndh3h8z0qwv9yf";
  };

  makeFlags = [ "MANDIR=$(out)/share/man" ];
  postInstall = ''
    # conflict with shadow-utils
    rm $out/share/man/man5/passwd.5 \
       $out/share/man/man3/getspnam.3
  '';
  outputDocdev = "out";

  meta = with stdenv.lib; {
    description = "Linux development manual pages";
    homepage = "https://www.kernel.org/doc/man-pages/";
    repositories.git = "http://git.kernel.org/pub/scm/docs/man-pages/man-pages";
    license = licenses.gpl2Plus;
    platforms = with platforms; unix;
    priority = 30; # if a package comes with its own man page, prefer it
  };
}

Make it findable by manpages

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  pname = "man-pages";
  version = "5.08";

  src = fetchurl {
    url = "mirror://kernel/linux/docs/man-pages/${pname}-${version}.tar.xz";
    sha256 = "1xzp3f6wvw3wplk1a1x09zfv0jp0pdc9wh95czndh3h8z0qwv9yf";
  };

  makeFlags = [ "MANDIR=$(out)/share/man" ];
  postInstall = ''
    # conflict with shadow-utils
    rm $out/share/man/man5/passwd.5 \
       $out/share/man/man3/getspnam.3

    # The manpath executable looks up manpages from PATH. And this package won't
    # appear in PATH unless it has a /bin folder
    mkdir -p $out/bin
  '';
  outputDocdev = "out";

  meta = with stdenv.lib; {
    description = "Linux development manual pages";
    homepage = "https://www.kernel.org/doc/man-pages/";
    repositories.git = "http://git.kernel.org/pub/scm/docs/man-pages/man-pages";
    license = licenses.gpl2Plus;
    platforms = with platforms; unix;
    priority = 30; # if a package comes with its own man page, prefer it
  };
}


a :
let
  fetchurl = a.fetchurl;

  version = a.lib.attrByPath ["version"] "0.18" a;
  buildInputs = with a; [
    zlib e2fsprogs acl
  ];
in
rec {
  src = fetchurl {
    url = "http://www.kernel.org/pub/linux/kernel/people/mason/btrfs/btrfs-progs-${version}.tar.bz2";
    sha256 = "032g9lyrinpnrx4b8hs5i6qfbmv8x4ss02p26fgvk4zbc0slh7z8";
  };

  inherit buildInputs;
  configureFlags = [];
  makeFlags = ["prefix=$out"];

  /* doConfigure should be removed if not needed */
  phaseNames = ["doMakeInstall"];

  name = "btrfs-progs-" + version;
  meta = {
    description = "BTRFS utilities";
  };
}

Update BtrFS progs. Note: incompatible with older kernels - like 2.6.30

a :
let
  fetchurl = a.fetchurl;

  version = a.lib.attrByPath ["version"] "0.19" a;
  buildInputs = with a; [
    zlib e2fsprogs acl
  ];
in
rec {
  src = fetchurl {
    url = "http://www.kernel.org/pub/linux/kernel/people/mason/btrfs/btrfs-progs-${version}.tar.bz2";
    sha256 = "1z3hmfgv7h489gnh55abm0gzyf2cgjkybhfc2rnm0cvsx01xv8zq";
  };

  inherit buildInputs;
  configureFlags = [];
  makeFlags = ["prefix=$out"];

  /* doConfigure should be removed if not needed */
  phaseNames = ["doMakeInstall"];

  name = "btrfs-progs-" + version;
  meta = {
    description = "BTRFS utilities";
  };
}


{ stdenv, apacheHttpd, autoconf, automake, autoreconfHook, curl, fetchFromGitHub, glib, lasso, libtool, libxml2, libxslt, openssl, pkgconfig, xmlsec }:

stdenv.mkDerivation rec {

  name = "mod_auth_mellon-${version}";
  version = "0.12.0";

  src = fetchFromGitHub {
    owner = "UNINETT";
    repo = "mod_auth_mellon";
    rev = "v${version}";
    sha256 = "1p6v6vgrfvgvc5y2ygqyyxi0klpm3nxaw3fg35zmpmw663w8skqn";
  };

  patches = [
    ./fixdeps.patch
  ];

  buildInputs = [ apacheHttpd autoconf autoreconfHook automake curl glib lasso libtool libxml2 libxslt openssl pkgconfig xmlsec ];

  configureFlags = ["--with-apxs2=${apacheHttpd}/bin/apxs" "--exec-prefix=$out"];

  installPhase = ''
    mkdir -p $out/bin
    cp ./mellon_create_metadata.sh $out/bin
    mkdir -p $out/modules
    cp ./.libs/mod_auth_mellon.so $out/modules
  '';

  meta = with stdenv.lib; {
    homepage = https://github.com/UNINETT/mod_auth_mellon;
    description = "An Apache module with a simple SAML 2.0 service provider";
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
    maintainers = with maintainers; [ womfoo ];
  };

}

Make explicit that 'dev' output of apacheHttpd is used

{ stdenv, apacheHttpd, autoconf, automake, autoreconfHook, curl, fetchFromGitHub, glib, lasso, libtool, libxml2, libxslt, openssl, pkgconfig, xmlsec }:

stdenv.mkDerivation rec {

  name = "mod_auth_mellon-${version}";
  version = "0.12.0";

  src = fetchFromGitHub {
    owner = "UNINETT";
    repo = "mod_auth_mellon";
    rev = "v${version}";
    sha256 = "1p6v6vgrfvgvc5y2ygqyyxi0klpm3nxaw3fg35zmpmw663w8skqn";
  };

  patches = [
    ./fixdeps.patch
  ];

  buildInputs = [ apacheHttpd autoconf autoreconfHook automake curl glib lasso libtool libxml2 libxslt openssl pkgconfig xmlsec ];

  configureFlags = ["--with-apxs2=${apacheHttpd.dev}/bin/apxs" "--exec-prefix=$out"];

  installPhase = ''
    mkdir -p $out/bin
    cp ./mellon_create_metadata.sh $out/bin
    mkdir -p $out/modules
    cp ./.libs/mod_auth_mellon.so $out/modules
  '';

  meta = with stdenv.lib; {
    homepage = https://github.com/UNINETT/mod_auth_mellon;
    description = "An Apache module with a simple SAML 2.0 service provider";
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
    maintainers = with maintainers; [ womfoo ];
  };

}


{ stdenv, fetchurl, pythonPackages }:

pythonPackages.buildPythonApplication rec {
  name = "hy-${version}";
  version = "0.12.1";

  src = fetchurl {
    url = "mirror://pypi/h/hy/${name}.tar.gz";
    sha256 = "1fjip998k336r26i1gpri18syvfjg7z46wng1n58dmc238wm53sx";
  };

  propagatedBuildInputs = with pythonPackages; [ appdirs clint astor rply ];

  meta = {
    description = "A LISP dialect embedded in Python";
    homepage = http://hylang.org/;
    license = stdenv.lib.licenses.mit;
    maintainers = [ stdenv.lib.maintainers.nixy ];
    platforms = stdenv.lib.platforms.all;
  };
}

Update hy to latest version

{ stdenv, fetchurl, pythonPackages }:

pythonPackages.buildPythonApplication rec {
  name = "hy-${version}";
  version = "0.13.1";

  src = fetchurl {
    url = "mirror://pypi/h/hy/${name}.tar.gz";
    sha256 = "1fjip998k336r26i1gpri18syvfjg7z46wng1n58dmc238wm53sx";
  };

  propagatedBuildInputs = with pythonPackages; [ appdirs clint astor rply ];

  meta = {
    description = "A LISP dialect embedded in Python";
    homepage = http://hylang.org/;
    license = stdenv.lib.licenses.mit;
    maintainers = [ stdenv.lib.maintainers.nixy ];
    platforms = stdenv.lib.platforms.all;
  };
}


{stdenv, fetchurl}:

stdenv.mkDerivation rec {
  name = "ortp-0.13.1";

  src = fetchurl {
    url = "mirror://savannah/linphone/ortp/sources/${name}.tar.gz";
    sha256 = "0k2963v4b15xnf4cpkpgjhsb8ckxpf6vdr8dnw7z3mzilji7391b";
  };

  meta = {
    description = "A Real-Time Transport Protocol (RFC3550) stack";
    homepage = http://www.linphone.org/index.php/eng/code_review/ortp;
  };
}

Update oRTP (0.13.1 -> 0.16.3)

{stdenv, fetchurl}:

stdenv.mkDerivation rec {
  name = "ortp-0.16.3";

  src = fetchurl {
    url = "mirror://savannah/linphone/ortp/sources/${name}.tar.gz";
    sha256 = "13805ec34ee818408aa1b4571915ef8f9e544c838a0fca9dff8d2308de6574eb";
  };

  meta = {
    description = "A Real-Time Transport Protocol (RFC3550) stack";
    homepage = http://www.linphone.org/index.php/eng/code_review/ortp;
  };
}


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

{
  my.packages = with pkgs; [
    libqalculate
    xclip
    xdotool
    mpv       # video player
    feh       # image viewer

    # Useful apps
    evince    # pdf reader
  ];

  sound.enable = true;
  hardware.pulseaudio.enable = true;

  services = {
    xserver.enable = true;
    redshift.enable = true;
  };

  # For redshift
  location = (if config.time.timeZone == "America/Toronto" then {
    latitude = 43.70011;
    longitude = -79.4163;
  } else if config.time.timeZone == "Europe/Copenhagen" then {
    latitude = 55.88;
    longitude = 12.5;
  } else {});

  fonts = {
    enableFontDir = true;
    enableGhostscriptFonts = true;

    fonts = with pkgs; [
      ubuntu_font_family
      dejavu_fonts
      fira-code
      fira-code-symbols
      symbola
      noto-fonts
      noto-fonts-cjk
      font-awesome-ttf
    ];

    fontconfig.defaultFonts = {
      sansSerif = ["Ubuntu"];
      monospace = ["Fira Code"];
    };
  };
}

Add calibri to desktop module

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

{
  my.packages = with pkgs; [
    libqalculate
    xclip
    xdotool
    mpv       # video player
    feh       # image viewer

    # Useful apps
    calibri   # managing my ebooks
    evince    # pdf reader
  ];

  sound.enable = true;
  hardware.pulseaudio.enable = true;

  services = {
    xserver.enable = true;
    redshift.enable = true;
  };

  # For redshift
  location = (if config.time.timeZone == "America/Toronto" then {
    latitude = 43.70011;
    longitude = -79.4163;
  } else if config.time.timeZone == "Europe/Copenhagen" then {
    latitude = 55.88;
    longitude = 12.5;
  } else {});

  fonts = {
    enableFontDir = true;
    enableGhostscriptFonts = true;

    fonts = with pkgs; [
      ubuntu_font_family
      dejavu_fonts
      fira-code
      fira-code-symbols
      symbola
      noto-fonts
      noto-fonts-cjk
      font-awesome-ttf
    ];

    fontconfig.defaultFonts = {
      sansSerif = ["Ubuntu"];
      monospace = ["Fira Code"];
    };
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  pname = "redis";
  version = "2.4.7";
  name = "${pname}-${version}";

  src = fetchurl {
    url = "http://redis.googlecode.com/files/redis-2.4.7.tar.gz";
    sha256 = "f91956377b7ff23cc23e0c8758e0b873032f36545c61d88436ebb741bf4dd5e1";
  };

  makeFlags = "PREFIX=$(out)";

  patches = if stdenv.isDarwin then [ ./darwin.patch ] else [];
  meta = {
    homepage = http://redis.io;
    description = "An open source, advanced key-value store";
    license = "BSD";

    platforms = stdenv.lib.platforms.unix;
  };
}

Comment out reference to nonexistent patch so that Hydra doesn't fail at evaluation

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  pname = "redis";
  version = "2.4.7";
  name = "${pname}-${version}";

  src = fetchurl {
    url = "http://redis.googlecode.com/files/redis-2.4.7.tar.gz";
    sha256 = "f91956377b7ff23cc23e0c8758e0b873032f36545c61d88436ebb741bf4dd5e1";
  };

  makeFlags = "PREFIX=$(out)";

  # commented out until the patch is found
  # patches = if stdenv.isDarwin then [ ./darwin.patch ] else [];
  meta = {
    homepage = http://redis.io;
    description = "An open source, advanced key-value store";
    license = "BSD";

    platforms = stdenv.lib.platforms.unix;
  };
}


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

stdenv.mkDerivation {
  name = "tarsnap-1.0.33";

  src = fetchurl {
    url = "https://www.tarsnap.com/download/tarsnap-autoconf-1.0.33.tgz";
    sha256 = "0z8bmra3xms9vcgvkiy9fy1j97192z6w7n658j6zr5cniid8438c";
  };

  buildInputs = [ openssl zlib e2fsprogs ];

  meta = {
    description = "Online backups for the truly paranoid";
    homepage = "http://www.tarsnap.com/";
    maintainers = with stdenv.lib.maintainers; [roconnor];
  };
}

Update tarsnap to version 1.0.34.

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

stdenv.mkDerivation {
  name = "tarsnap-1.0.34";

  src = fetchurl {
    url = "https://www.tarsnap.com/download/tarsnap-autoconf-1.0.34.tgz";
    sha256 = "049q0mbz9i4m87n1r78zf62mcxd04wm49rjqpiy5yzy4z8m1gh0l";
  };

  buildInputs = [ openssl zlib e2fsprogs ];

  meta = {
    description = "Online backups for the truly paranoid";
    homepage = "http://www.tarsnap.com/";
    maintainers = with stdenv.lib.maintainers; [roconnor];
  };
}


{ stdenv, fetchPypi, buildPythonPackage, typed-ast, psutil, isPy3k
, mypy-extensions
, typing-extensions
}:

buildPythonPackage rec {
  pname = "mypy";
  version = "0.761";
  disabled = !isPy3k;

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

  propagatedBuildInputs = [ typed-ast psutil mypy-extensions typing-extensions ];

  # Tests not included in pip package.
  doCheck = false;

  pythonImportsCheck = [
    "mypy"
    "mypy.types"
    "mypy.api"
    "mypy.fastparse"
    "mypy.report"
  ];

  meta = with stdenv.lib; {
    description = "Optional static typing for Python";
    homepage    = "http://www.mypy-lang.org";
    license     = licenses.mit;
    maintainers = with maintainers; [ martingms lnl7 ];
  };
}

Revert "Revert "mypy: 0.761 -> 0.770""

{ stdenv, fetchPypi, buildPythonPackage, typed-ast, psutil, isPy3k
, mypy-extensions
, typing-extensions
}:

buildPythonPackage rec {
  pname = "mypy";
  version = "0.770";
  disabled = !isPy3k;

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

  propagatedBuildInputs = [ typed-ast psutil mypy-extensions typing-extensions ];

  # Tests not included in pip package.
  doCheck = false;

  pythonImportsCheck = [
    "mypy"
    "mypy.types"
    "mypy.api"
    "mypy.fastparse"
    "mypy.report"
  ];

  meta = with stdenv.lib; {
    description = "Optional static typing for Python";
    homepage    = "http://www.mypy-lang.org";
    license     = licenses.mit;
    maintainers = with maintainers; [ martingms lnl7 ];
  };
}


{ stdenv, fetchurl, fox, pkgconfig, gettext, x11, gcc, intltool, file, libpng }:

stdenv.mkDerivation rec {
  name = "xfe-1.34";

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

  buildInputs = [ fox pkgconfig gettext x11 gcc intltool file libpng ];

  preConfigure = ''
    sed -i s,/usr/share/xfe,$out/share/xfe, src/xfedefs.h
  '';

  enableParallelBuilding = true;

  meta = {
    description = "MS-Explorer like file manager for X";
    longDescription = ''
      X File Explorer (Xfe) is an MS-Explorer like file manager for X.
      It is based on the popular, but discontinued, X Win Commander, which was developed by Maxim Baranov.
      Xfe aims to be the filemanager of choice for all the Unix addicts!
    '';
    homepage = "http://sourceforge.net/projects/xfe/";
    license = stdenv.lib.licenses.gpl2;
    maintainers = [ stdenv.lib.maintainers.bbenoist ];
    platforms = stdenv.lib.platforms.linux;
  };
}

Update from 1.34 to 1.37

{ stdenv, fetchurl, fox, pkgconfig, gettext, x11, gcc, intltool, file, libpng }:

stdenv.mkDerivation rec {
  name = "xfe-1.37";

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

  buildInputs = [ fox pkgconfig gettext x11 gcc intltool file libpng ];

  preConfigure = ''
    sed -i s,/usr/share/xfe,$out/share/xfe, src/xfedefs.h
  '';

  enableParallelBuilding = true;

  meta = {
    description = "MS-Explorer like file manager for X";
    longDescription = ''
      X File Explorer (Xfe) is an MS-Explorer like file manager for X.
      It is based on the popular, but discontinued, X Win Commander, which was developed by Maxim Baranov.
      Xfe aims to be the filemanager of choice for all the Unix addicts!
    '';
    homepage = "http://sourceforge.net/projects/xfe/";
    license = stdenv.lib.licenses.gpl2;
    maintainers = [ stdenv.lib.maintainers.bbenoist ];
    platforms = stdenv.lib.platforms.linux;
  };
}


{ callPackage, fetchFromGitHub, ... } @ args:

callPackage ./generic.nix (args // rec {
  version = "0.6.4";

  src = fetchFromGitHub {
    owner = "zfsonlinux";
    repo = "spl";
    rev = "spl-${version}";
    sha256 = "1jja3aqkm2whb4rcw5k5dr9c4gx6hax1w3f82fb9ks2sy731as6r";
  };

  patches = [ ./const.patch ./install_prefix.patch ];
})

Update from 0.6.4 -> 0.6.4.1

{ callPackage, fetchFromGitHub, ... } @ args:

callPackage ./generic.nix (args // rec {
  version = "0.6.4.1";

  src = fetchFromGitHub {
    owner = "zfsonlinux";
    repo = "spl";
    rev = "spl-${version}";
    sha256 = "1rlflraj66ag2gcvzsyfl4zwhq4846ifyzdmnnmscwmdf2qxc1l8";
  };

  patches = [ ./const.patch ./install_prefix.patch ];
})


# This file is autogenerated from update.sh in the same directory.
{
  beta = {
    sha256 = "1jwk0x5hjpah0bl4dpirxwyfxv0d0wnkvfgyja91kkbh8471gzmk";
    sha256bin64 = "10sl3ddd77i1gl3l4yvhkpavfq2bygv7gwql0jnhchmrvyax1cjh";
    version = "50.0.2661.49";
  };
  dev = {
    sha256 = "042h6klyijnhkb4m9lsnfi3qss6pbs4p4981rm4cbc86rsyppkhl";
    sha256bin64 = "1p6lhd3n9q93fkydxksgfv68vz26yj8i2zx1kqby2z9yc0pdcniq";
    version = "51.0.2693.2";
  };
  stable = {
    sha256 = "1ijpbmn38znjjb3h8579x5gsclgjx122lvm0afv17gf2j3w5w4qj";
    sha256bin64 = "17vqvxmy6llg7dpc3pxi0qhwpm9qc9rsq8lgknhwwygvkl8g14sb";
    version = "50.0.2661.102";
  };
}

Update to latest beta and dev channels

# This file is autogenerated from update.sh in the same directory.
{
  beta = {
    sha256 = "0l1434wqhi6c24qyb5ysg1wnd0s9l9i1k6kh6wr3s4acrsbb7p12";
    sha256bin64 = "1ssw92l8zwj8x0zs5h6vxl7d7gj0lqb0x71vsazgd4d0p23nglb1";
    version = "51.0.2704.47";
  };
  dev = {
    sha256 = "0czp4p434yqr5rv3w2vypkyis13x8lc4xph8yh84r9big1ga6fqs";
    sha256bin64 = "0hahamx9k14czswqdh8iwh69lsml0acca5kxvp2kw471g3s55n78";
    version = "52.0.2729.3";
  };
  stable = {
    sha256 = "1ijpbmn38znjjb3h8579x5gsclgjx122lvm0afv17gf2j3w5w4qj";
    sha256bin64 = "17vqvxmy6llg7dpc3pxi0qhwpm9qc9rsq8lgknhwwygvkl8g14sb";
    version = "50.0.2661.102";
  };
}


with import <nixpkgs> {}; {
  beatwaveEnv = clangStdenv.mkDerivation {
    name = "beatwave";
    buildInputs = [ clangStdenv sfml cmake rtags doxygen ];
  };
}

Enable CTest fail output for NixOS dev env

with import <nixpkgs> {}; {
  beatwaveEnv = clangStdenv.mkDerivation {
    name = "beatwave";
    buildInputs = [ clangStdenv sfml cmake rtags doxygen ];
    CTEST_OUTPUT_ON_FAILURE = 1;
  };
}


{ lib
, stdenv
, buildPythonPackage
, fetchFromGitHub
, humanfriendly
, verboselogs
, capturer
, pytest
, mock
, util-linux
, isPy38
}:

buildPythonPackage rec {
  pname = "coloredlogs";
  version = "14.0";

  src = fetchFromGitHub {
    owner = "xolox";
    repo = "python-coloredlogs";
    rev = version;
    sha256 = "0rnmxwrim4razlv4vi3krxk5lc5ksck6h5374j8avqwplika7q2x";
  };

  # capturer is broken on darwin / py38, so we skip the test until a fix for
  # https://github.com/xolox/python-capturer/issues/10 is released.
  doCheck = !(isPy38 && stdenv.isDarwin);
  checkPhase = ''
    PATH=$PATH:$out/bin pytest . -k "not test_plain_text_output_format \
                                     and not test_auto_install"
  '';
  checkInputs = [ pytest mock util-linux verboselogs capturer ];

  pythonImportsCheck = [ "coloredlogs" ];

  propagatedBuildInputs = [ humanfriendly ];

  meta = with lib; {
    description = "Colored stream handler for Python's logging module";
    homepage = "https://github.com/xolox/python-coloredlogs";
    license = licenses.mit;
    maintainers = with maintainers; [ eyjhb ];
  };
}

Disable tests for darwin on all python versions

{ lib
, stdenv
, buildPythonPackage
, fetchFromGitHub
, humanfriendly
, verboselogs
, capturer
, pytest
, mock
, util-linux
}:

buildPythonPackage rec {
  pname = "coloredlogs";
  version = "14.0";

  src = fetchFromGitHub {
    owner = "xolox";
    repo = "python-coloredlogs";
    rev = version;
    sha256 = "0rnmxwrim4razlv4vi3krxk5lc5ksck6h5374j8avqwplika7q2x";
  };

  # capturer is broken on darwin / py38, so we skip the test until a fix for
  # https://github.com/xolox/python-capturer/issues/10 is released.
  doCheck = !stdenv.isDarwin;
  checkPhase = ''
    PATH=$PATH:$out/bin pytest . -k "not test_plain_text_output_format \
                                     and not test_auto_install"
  '';
  checkInputs = [ pytest mock util-linux verboselogs capturer ];

  pythonImportsCheck = [ "coloredlogs" ];

  propagatedBuildInputs = [ humanfriendly ];

  meta = with lib; {
    description = "Colored stream handler for Python's logging module";
    homepage = "https://github.com/xolox/python-coloredlogs";
    license = licenses.mit;
    maintainers = with maintainers; [ eyjhb ];
  };
}


{ pkgs, ... }:

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

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

    # Terminals and core software:
    wmctrl gnome.gnome_keyring

    # Internet Utilities:
    uzbl chromium conkeror ssvnc firefoxWrapper /* asynk */

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

    # Media Ripping:
    handbrake makemkv grip lame

    # Media Editors:
    audacity gimp inkscape darktable imagemagick

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

    # Games:
    mednafen

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

Make sure curl and wget are installed

{ pkgs, ... }:

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

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

    # Terminals and core software:
    wmctrl gnome.gnome_keyring

    # Internet Utilities:
    uzbl chromium conkeror ssvnc firefoxWrapper /* asynk */
    curl wget

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

    # Media Ripping:
    handbrake makemkv grip lame

    # Media Editors:
    audacity gimp inkscape darktable imagemagick

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

    # Games:
    mednafen

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


{stdenv, fetchurl, xlibsWrapper, mesa}:

let version = "8.3.0"; in

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

  src = fetchurl {
    url = "ftp://ftp.freedesktop.org/pub/mesa/demos/${version}/mesa-demos-${version}.tar.bz2";
    sha256 = "1vqb7s5m3fcg2csbiz45mha1pys2xx6rhw94fcyvapqdpm5iawy1";
  };

  buildInputs = [xlibsWrapper mesa];

  configurePhase = "true";

  buildPhase = "
    cd src/xdemos
    gcc glxinfo.c glinfo_common.c -o glxinfo -lGL -lX11
    gcc glxgears.c -o glxgears -lGL -lX11
  ";

  installPhase = "
    mkdir -p $out/bin
    cp glxinfo glxgears $out/bin/
  ";

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

Drop dependency on mesa-noglu.dev and glu.dev

{ stdenv, fetchurl, xlibsWrapper, mesa_noglu }:

let version = "8.3.0"; in

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

  src = fetchurl {
    url = "ftp://ftp.freedesktop.org/pub/mesa/demos/${version}/mesa-demos-${version}.tar.bz2";
    sha256 = "1vqb7s5m3fcg2csbiz45mha1pys2xx6rhw94fcyvapqdpm5iawy1";
  };

  buildInputs = [ xlibsWrapper mesa_noglu ];

  configurePhase = "true";

  buildPhase = "
    cd src/xdemos
    gcc glxinfo.c glinfo_common.c -o glxinfo -lGL -lX11
    gcc glxgears.c -o glxgears -lGL -lX11
  ";

  installPhase = "
    mkdir -p $out/bin
    cp glxinfo glxgears $out/bin/
  ";

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


{ stdenv, fetchFromGitHub, python3Packages }:

python3Packages.buildPythonApplication rec {
  name = "urlwatch-${version}";
  version = "2.21";

  src = fetchFromGitHub {
    owner  = "thp";
    repo   = "urlwatch";
    rev    = version;
    sha256 = "1s6bigkwymxdp9bkgvwg3lbf465i6k8kmak2w7czf4mhwavcfq63";
  };

  propagatedBuildInputs = with python3Packages; [
    appdirs
    cssselect
    keyring
    lxml
    minidb
    pycodestyle
    pyyaml
    requests
    pyppeteer
  ];

  meta = with stdenv.lib; {
    description = "A tool for monitoring webpages for updates";
    homepage = "https://thp.io/2008/urlwatch/";
    license = licenses.bsd3;
    maintainers = with maintainers; [ kmein tv ];
  };
}

Disable tests, name -> pname

{ stdenv, fetchFromGitHub, python3Packages }:

python3Packages.buildPythonApplication rec {
  pname = "urlwatch";
  version = "2.21";

  src = fetchFromGitHub {
    owner  = "thp";
    repo   = "urlwatch";
    rev    = version;
    sha256 = "1s6bigkwymxdp9bkgvwg3lbf465i6k8kmak2w7czf4mhwavcfq63";
  };

  propagatedBuildInputs = with python3Packages; [
    appdirs
    cssselect
    keyring
    lxml
    minidb
    pycodestyle
    pyyaml
    requests
    pyppeteer
  ];

  # no tests
  doCheck = false;

  meta = with stdenv.lib; {
    description = "A tool for monitoring webpages for updates";
    homepage = "https://thp.io/2008/urlwatch/";
    license = licenses.bsd3;
    maintainers = with maintainers; [ kmein tv ];
  };
}


{
  lib,
  rustPlatform,
  fetchFromGitLab,
}:

rustPlatform.buildRustPackage rec {
  pname = "watchlog";
  version = "1.152.0";

  src = fetchFromGitLab {
    owner = "kevincox";
    repo = "watchlog";
    rev = "v${version}";
    sha256 = "sha256-m0sqLi5qxQKfdFtHxo0DX4bV6lUNZP1JWt8NAfY+F5A=";
  };

  cargoSha256 = "sha256-uIaGIHBB/ntGyBZL45E61E9fELR8UGRieb/fJQsB5NE=";

  meta = {
    description = "Easier monitoring of live logs";
    homepage = "https://gitlab.com/kevincox/watchlog";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ kevincox ];
  };
}

Remove Darwin from supported platforms.

{
  lib,
  rustPlatform,
  fetchFromGitLab,
}:

rustPlatform.buildRustPackage rec {
  pname = "watchlog";
  version = "1.152.0";

  src = fetchFromGitLab {
    owner = "kevincox";
    repo = "watchlog";
    rev = "v${version}";
    sha256 = "sha256-m0sqLi5qxQKfdFtHxo0DX4bV6lUNZP1JWt8NAfY+F5A=";
  };

  cargoSha256 = "sha256-uIaGIHBB/ntGyBZL45E61E9fELR8UGRieb/fJQsB5NE=";

  meta = {
    description = "Easier monitoring of live logs";
    homepage = "https://gitlab.com/kevincox/watchlog";
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [ kevincox ];

    # Dependency only supports Linux + Windows: https://github.com/mentaljam/standard_paths/tree/master/src
    platforms = with lib.platforms; linux ++ windows;
  };
}


{ stdenv, fetchurl }:

let
  driverdb = fetchurl {
    url = "http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/trunk/smartmontools/drivedb.h?revision=3812";
    sha256 = "1x22ammjwlb7p3cmd13shqq1payb7nr9pgfa9xifs19qyr77mrwp";
    name = "smartmontools-drivedb.h";
  };
in
stdenv.mkDerivation rec {
  name = "smartmontools-6.2";

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

  patchPhase = ''
    : cp ${driverdb} drivedb.h
    sed -i -e 's@which which >/dev/null || exit 1@alias which="type -p"@' update-smart-drivedb.in
  '';

  meta = {
    description = "Tools for monitoring the health of hard drivers";
    homepage = "http://smartmontools.sourceforge.net/";
    license = stdenv.lib.licenses.gpl2Plus;
    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.simons ];
  };
}

Update driverdb to r3849, and fix broken url

{ stdenv, fetchurl }:

let
  dbrev = "3849";
  driverdb = fetchurl {
    url = "http://sourceforge.net/p/smartmontools/code/${dbrev}/tree/trunk/smartmontools/drivedb.h?format=raw";
    sha256 = "06c1cl0x4sq64l3rmd5rk8wsbggjixphpgj0kf4awqhjgsi102xz";
    name = "smartmontools-drivedb.h";
  };
in
stdenv.mkDerivation rec {
  name = "smartmontools-6.2";

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

  patchPhase = ''
    : cp ${driverdb} drivedb.h
    sed -i -e 's@which which >/dev/null || exit 1@alias which="type -p"@' update-smart-drivedb.in
  '';

  meta = {
    description = "Tools for monitoring the health of hard drivers";
    homepage = "http://smartmontools.sourceforge.net/";
    license = stdenv.lib.licenses.gpl2Plus;
    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.simons ];
  };
}


{stdenv, fetchurl}:

stdenv.mkDerivation rec {
  name = "iptables-1.4.16.2";

  src = fetchurl {
    url = "http://www.netfilter.org/projects/iptables/files/${name}.tar.bz2";
    md5 = "57220bb26866a713073e5614f88071fc";
  };

  # Install header files required by miniupnpd.
  postInstall =
    ''
      cp include/iptables.h $out/include
      cp include/libiptc/libiptc.h include/libiptc/ipt_kernel_headers.h $out/include/libiptc
      mkdir $out/include/iptables
      cp include/iptables/internal.h $out/include/iptables
      mkdir $out/include/net
      cp -prd include/net/netfilter $out/include/net/netfilter
      mkdir $out/include/linux
    '';

  meta = {
    description = "A program to configure the Linux IP packet filtering ruleset";
    homepage = http://www.netfilter.org/projects/iptables/index.html;
    platforms = stdenv.lib.platforms.linux;
  };
}

Update IPTables from 1.4.16.2 -> 1.4.20

{stdenv, fetchurl}:

stdenv.mkDerivation rec {
  name = "iptables-1.4.21";

  src = fetchurl {
    url = "http://www.netfilter.org/projects/iptables/files/${name}.tar.bz2";
    sha256 = "1q6kg7sf0pgpq0qhab6sywl23cngxxfzc9zdzscsba8x09l4q02j";
  };

  configureFlags = ''
    --enable-devel
    --enable-shared
  '';

  meta = {
    description = "A program to configure the Linux IP packet filtering ruleset";
    homepage = http://www.netfilter.org/projects/iptables/index.html;
    platforms = stdenv.lib.platforms.linux;
  };
}


{ stdenv, fetchurl, pkgconfig, udev }:

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

  src = fetchurl {
    url = "mirror://roy/dhcpcd/${name}.tar.xz";
    sha256 = "1m90wsg4m9bcaavh36vlhjghrbdsi5x2yy92ixhgynmzrgnwlqdb";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ 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 = https://roy.marples.name/projects/dhcpcd;
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [ eelco fpletz ];
  };
}

Revert "dhcpcd: 6.11.5 -> 7.0.0"

{ stdenv, fetchurl, pkgconfig, udev }:

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

  src = fetchurl {
    url = "mirror://roy/dhcpcd/${name}.tar.xz";
    sha256 = "17nnhxmbdcc7k2mh6sgvxisqcqbic5540xbig363ds97gvf795kg";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ 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 = https://roy.marples.name/projects/dhcpcd;
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [ eelco fpletz ];
  };
}


# X1 6th generation with a QHD (2560x1440px) display
{ config, lib, ... }:

{
  imports = [
    ../.
  ];

  # Fix font sizes in X
  services.xserver.dpi = 210;
  fonts.fontconfig.dpi = 210;

  # Fix sizes of GTK/GNOME ui elements
  environment.variables = {
    GDK_SCALE = lib.mkDefault "2";
    GDK_DPI_SCALE= lib.mkDefault "0.5";
  };
}

Add optional console font configuration to make it readable on QHD displays

# X1 6th generation with a QHD (2560x1440px) display
{ config, lib, ... }:

{
  imports = [
    ../.
  ];

  # Fix font sizes in X
  services.xserver.dpi = 210;
  fonts.fontconfig.dpi = 210;

  # Fix sizes of GTK/GNOME ui elements
  environment.variables = {
    GDK_SCALE = lib.mkDefault "2";
    GDK_DPI_SCALE= lib.mkDefault "0.5";
  };
  # Enable readable font on console. The example configuration that
  # foollows is taliored towards western languages. To see how to
  # configure the font download the source tarball from
  # http://terminus-font.sourceforge.net/ and read the README file on
  # the root dir

  # i18n = {
  #   # this means ISO8859-1 or ISO8859-15 or Windows-1252 codepages
  #   # (ter-1), 16x32 px (32), normal font weight (n)
  #   consoleFont = "ter-132n";
  #   consoleKeyMap = "us";
  #   defaultLocale = "en_US.UTF-8";
  #   consolePackages = [ pkgs.terminus_font ];
  # };

  # Early configure the console to make the font readable from the
  # start
  # boot.earlyVconsoleSetup = true;
}


{ nixpkgs ? ../../nixpkgs
, runtime-libraries ? ../../runtime-libraries
, strategoxt ? ../../strategoxt
, strj ? ../../strategoxt.jar
} :
let
  pkgs = import nixpkgs {};

  jobs = {
    build = pkgs.releaseTools.antBuild {
      name = "runtime-libraries";
      src = runtime-libraries;
      buildInputs = with pkgs; [ ecj openjdk ];

      postUnpack = ''
        cp ${strategoxt}/strategoxt/ant-contrib/strategoxt-antlib.xml runtime-libraries/org.spoofax.meta.runtime.libraries/
      '';

      preConfigure = ''
        cd org.spoofax.meta.runtime.libraries
      '';

      antTargets = ["all" "install"];
      antProperties = [
        { name = "eclipse.spoofaximp.strategojar"; value = strj; }
        { name = "output"; value = "$out"; }
      ];
      antBuildInputs = [ pkgs.ecj strategoxt strj ];

      ANT_OPTS="-Xss8m -Xmx1024m";

      dontInstall = true;
    };
  };

in jobs

Move copying of strategoxt-antlib.xml into preConfigure.

{ nixpkgs ? ../../nixpkgs
, runtime-libraries ? ../../runtime-libraries
, strategoxt ? ../../strategoxt
, strj ? ../../strategoxt.jar
} :
let
  pkgs = import nixpkgs {};

  jobs = {
    build = pkgs.releaseTools.antBuild {
      name = "runtime-libraries";
      src = runtime-libraries;
      buildInputs = with pkgs; [ ecj openjdk ];

      preConfigure = ''
        cd org.spoofax.meta.runtime.libraries
        cp ${strategoxt}/strategoxt/ant-contrib/strategoxt-antlib.xml .
      '';

      antTargets = ["all" "install"];
      antProperties = [
        { name = "eclipse.spoofaximp.strategojar"; value = strj; }
        { name = "output"; value = "$out"; }
      ];
      antBuildInputs = [ pkgs.ecj strategoxt strj ];

      ANT_OPTS="-Xss8m -Xmx1024m";

      dontInstall = true;
    };
  };

in jobs


{ stdenv, fetchurl, cmake, patchelf, imagemagick }:

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

  src = fetchurl {
    url = "https://launchpad.net/cuneiform-linux/1.1/1.1/+download/cuneiform-linux-1.1.0.tar.bz2";
    sha256 = "1bdvppyfx2184zmzcylskd87cxv56d8f32jf7g1qc8779l2hszjp";
  };

  patches = [
  (fetchurl {
    url = "https://git.archlinux.org/svntogit/community.git/plain/cuneiform/trunk/build-fix.patch?id=a2ec92f05de006b56d16ac6a6c370d54a554861a";
    sha256 = "19cmrlx4khn30qqrpyayn7bicg8yi0wpz1x1bvqqrbvr3kwldxyj";
  })
  ];

  buildInputs = [ imagemagick ];

  nativeBuildInputs = [ cmake ];

  meta = {
    description = "Multi-language OCR system";
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [raskin];
  };
}

Fix build against glibc 2.26

{ stdenv, fetchurl, cmake, patchelf, imagemagick }:

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

  src = fetchurl {
    url = "https://launchpad.net/cuneiform-linux/1.1/1.1/+download/cuneiform-linux-1.1.0.tar.bz2";
    sha256 = "1bdvppyfx2184zmzcylskd87cxv56d8f32jf7g1qc8779l2hszjp";
  };

  patches = [
  (fetchurl {
    url = "https://git.archlinux.org/svntogit/community.git/plain/cuneiform/trunk/build-fix.patch?id=a2ec92f05de006b56d16ac6a6c370d54a554861a";
    sha256 = "19cmrlx4khn30qqrpyayn7bicg8yi0wpz1x1bvqqrbvr3kwldxyj";
  })
  ];

  postPatch = ''
    rm cuneiform_src/Kern/hhh/tigerh/h/strings.h
  '';

  buildInputs = [ imagemagick ];

  nativeBuildInputs = [ cmake ];

  meta = {
    description = "Multi-language OCR system";
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [raskin];
  };
}


{ fetchurl, stdenv, openssl, db, boost, zlib, miniupnpc, qt4 }:

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

  src = fetchurl {
    url = "mirror://sourceforge/bitcoin/${name}-linux.tar.gz";
    sha256 = "036xx06gyrfh65rpdapff3viz1f38vzkj7lnhil6fc0s7pjmsjbk";
  };

  buildInputs = [ openssl db boost zlib miniupnpc qt4 ];

  configurePhase = ''
    cd src
    qmake
  '';

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

  meta = {
      description = "Bitcoin is a peer-to-peer currency";
      longDescription= ''
        Bitcoin is a free open source peer-to-peer electronic cash system that is
        completely decentralized, without the need for a central server or trusted
        parties.  Users hold the crypto keys to their own money and transact directly
        with each other, with the help of a P2P network to check for double-spending.
      '';
      homepage = "http://www.bitcoin.org/";
      maintainers = [ stdenv.lib.maintainers.roconnor ];
      license = "MIT";
  };
}

Update from 0.8.6 -> 0.9.1

{ fetchurl, stdenv, openssl, db48, boost, zlib, miniupnpc, qt4, utillinux
, pkgconfig, protobuf, qrencode }:

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

  src = fetchurl {
    url = "https://bitcoin.org/bin/${version}/${name}-linux.tar.gz";
    sha256 = "3fabc1c629007b465a278525883663d41a2ba62699f2773536a8bf59ca210425";
  };

  # hexdump from utillinux is required for tests
  buildInputs = [
    openssl db48 boost zlib miniupnpc qt4 utillinux pkgconfig protobuf qrencode
  ];

  unpackPhase = ''
    mkdir tmp-extract && (cd tmp-extract && tar xf $src)
    tar xf tmp-extract/bitcoin*/src/bitcoin*.tar*
    cd bitcoin*
  '';

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

  preCheck = ''
    # At least one test requires writing in $HOME
    HOME=$TMPDIR
  '';

  doCheck = true;

  enableParallelBuilding = true;

  meta = {
      description = "Bitcoin is a peer-to-peer currency";
      longDescription= ''
        Bitcoin is a free open source peer-to-peer electronic cash system that is
        completely decentralized, without the need for a central server or trusted
        parties.  Users hold the crypto keys to their own money and transact directly
        with each other, with the help of a P2P network to check for double-spending.
      '';
      homepage = "http://www.bitcoin.org/";
      maintainers = [ stdenv.lib.maintainers.roconnor ];
      license = "MIT";
  };
}


{ lib, mkDerivation, fetchFromGitLab, qmake, libusb1, hidapi, pkg-config }:

mkDerivation rec {
  pname = "openrgb";
  version = "0.6";

  src = fetchFromGitLab {
    owner = "CalcProgrammer1";
    repo = "OpenRGB";
    rev = "release_${version}";
    sha256 = "sha256-x/wGD39Jm/kmcTEZP3BnLXxyv/jkPOJd6mLCO0dp5wM=";
  };

  nativeBuildInputs = [ qmake pkg-config ];
  buildInputs = [ libusb1 hidapi ];

  installPhase = ''
    mkdir -p $out/bin
    cp openrgb $out/bin

    mkdir -p $out/etc/udev/rules.d
    cp 60-openrgb.rules $out/etc/udev/rules.d
  '';

  doInstallCheck = true;
  installCheckPhase = ''
    HOME=$TMPDIR $out/bin/openrgb --help > /dev/null
  '';

  enableParallelBuilding = true;

  meta = with lib; {
    description = "Open source RGB lighting control";
    homepage = "https://gitlab.com/CalcProgrammer1/OpenRGB";
    maintainers = with maintainers; [ jonringer ];
    license = licenses.gpl2;
    platforms = platforms.linux;
  };
}

Fix udev rules with hardcoded /bin/chmod

{ lib, mkDerivation, fetchFromGitLab, qmake, libusb1, hidapi, pkg-config, coreutils }:

mkDerivation rec {
  pname = "openrgb";
  version = "0.6";

  src = fetchFromGitLab {
    owner = "CalcProgrammer1";
    repo = "OpenRGB";
    rev = "release_${version}";
    sha256 = "sha256-x/wGD39Jm/kmcTEZP3BnLXxyv/jkPOJd6mLCO0dp5wM=";
  };

  nativeBuildInputs = [ qmake pkg-config ];
  buildInputs = [ libusb1 hidapi ];

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp openrgb $out/bin

    substituteInPlace 60-openrgb.rules \
      --replace /bin/chmod "${coreutils}/bin/chmod"

    mkdir -p $out/etc/udev/rules.d
    cp 60-openrgb.rules $out/etc/udev/rules.d

    runHook postInstall
  '';

  doInstallCheck = true;
  installCheckPhase = ''
    HOME=$TMPDIR $out/bin/openrgb --help > /dev/null
  '';

  meta = with lib; {
    description = "Open source RGB lighting control";
    homepage = "https://gitlab.com/CalcProgrammer1/OpenRGB";
    maintainers = with maintainers; [ jonringer ];
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
  };
}


{ config, pkgs, ... }:

{
  environment.systemPackages = with pkgs; [
    # Shells
    zsh

    # Editors
    (neovim.override { vimAlias = true; })
    # emacs # in user config, due to customization

    # Development
    gitAndTools.tig

    # Admin
    acpi
    file
    gptfdisk
    gparted
    htop
    pciutils
    tree
    wget
    termite.terminfo

    # Nix
    nix-repl
    nix-prefetch-scripts
    #strategoPackages018.strategoxt # It's broken
  ];

  nix = {
    binaryCaches = [
      "http://cache.nixos.org/"
    ];
    trustedBinaryCaches = [
      "https://hydra.nixos.org/"
      "http://hydra.cryp.to"
      "https://nixcache.reflex-frp.org"
    ];
    binaryCachePublicKeys = [
      "ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI="
    ];
  };
}

Use unstable version of Nix

{ config, pkgs, ... }:

{
  environment.systemPackages = with pkgs; [
    # Shells
    zsh

    # Editors
    (neovim.override { vimAlias = true; })
    # emacs # in user config, due to customization

    # Development
    gitAndTools.tig

    # Admin
    acpi
    file
    gptfdisk
    gparted
    htop
    pciutils
    tree
    wget
    termite.terminfo

    # Nix
    nix-repl
    nix-prefetch-scripts
    #strategoPackages018.strategoxt # It's broken
  ];

  nix = {
    package = pkgs.nixUnstable;
    binaryCaches = [
      "http://cache.nixos.org/"
    ];
    trustedBinaryCaches = [
      "https://hydra.nixos.org/"
      "http://hydra.cryp.to"
      "https://nixcache.reflex-frp.org"
    ];
    binaryCachePublicKeys = [
      "ryantrinkle.com-1:JJiAKaRv9mWgpVAz8dwewnZe0AzzEAzPkagE9SP5NWI="
    ];
  };
}


{stdenv, fetchurl, ncurses, curl, taglib, fftw, mpd_clientlib, pkgconfig}:

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

  src = fetchurl {
    url = "http://unkart.ovh.org/ncmpcpp/ncmpcpp-${version}.tar.bz2";
    sha256 = "1kbkngs4fhf9z53awskqiwdl94i5slvxmjiajkrayi99373fallx";
  };

  buildInputs = [ ncurses curl taglib fftw mpd_clientlib pkgconfig ];

  meta = {
    description = "Curses-based interface for MPD (music player daemon)";
    homepage = http://unkart.ovh.org/ncmpcpp/;
    license = "GPLv2+";
    maintainers = [ stdenv.lib.maintainers.mornfall ];
  };
}

Update the download URL for ncmpcpp

{stdenv, fetchurl, ncurses, curl, taglib, fftw, mpd_clientlib, pkgconfig}:

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

  src = fetchurl {
    url = "http://ncmpcpp.rybczak.net/stable/ncmpcpp-${version}.tar.bz2";
    sha256 = "1kbkngs4fhf9z53awskqiwdl94i5slvxmjiajkrayi99373fallx";
  };

  buildInputs = [ ncurses curl taglib fftw mpd_clientlib pkgconfig ];

  meta = {
    description = "Curses-based interface for MPD (music player daemon)";
    homepage = http://unkart.ovh.org/ncmpcpp/;
    license = "GPLv2+";
    maintainers = [ stdenv.lib.maintainers.mornfall ];
  };
}


{ stdenv, fetchurl, postgresql, ruby }:

with stdenv.lib;
stdenv.mkDerivation rec {
  version = "3.30.3";
  name = "heroku-${version}";

  meta = {
    homepage = "https://toolbelt.heroku.com";
    description = "Everything you need to get started using Heroku";
    maintainers = with maintainers; [ aflatter mirdhyn ];
    license = licenses.mit;
  };

  src = fetchurl {
    url = "https://s3.amazonaws.com/assets.heroku.com/heroku-client/heroku-client-${version}.tgz";
    sha256 = "0m9l04syli4ripkh37lwk0hq4silnp830ddsk3ph77iymzh2iz1f";
  };

  installPhase = ''
    mkdir -p $out
    cp -R * $out/
  '';

  buildInputs = [ ruby postgresql ];
}

Update heroku toolbelt to 3.32.0

{ stdenv, fetchurl, postgresql, ruby }:

with stdenv.lib;
stdenv.mkDerivation rec {
  version = "3.32.0";
  name = "heroku-${version}";

  meta = {
    homepage = "https://toolbelt.heroku.com";
    description = "Everything you need to get started using Heroku";
    maintainers = with maintainers; [ aflatter mirdhyn ];
    license = licenses.mit;
  };

  src = fetchurl {
    url = "https://s3.amazonaws.com/assets.heroku.com/heroku-client/heroku-client-${version}.tgz";
    sha256 = "1596zmnlwshx15xiccfskm71syrlm87jf40y2x0y7wn0vfcyis5s";
  };

  installPhase = ''
    mkdir -p $out
    cp -R * $out/
  '';

  buildInputs = [ ruby postgresql ];
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {

  name = "amd-ucode-2012-09-10";

  src = fetchurl {
    url = "http://www.amd64.org/pub/microcode/${name}.tar";
    sha256 = "065phvhx5hx5ssdd1x2p5m1yv26ak7l5aaw6yk6h95x9mxn5r111";
  };

  installPhase = ''
    mkdir -p $out/amd-ucode
    mv microcode_amd_fam15h.bin microcode_amd.bin $out/amd-ucode/
  '';

  meta = {
    description = "AMD Processor Microcode Patch";
    homepage = "http://www.amd64.org/support/microcode.html";
    license = "non-free";
  };
}

Add mirror url for AMD microcode

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {

  name = "amd-ucode-2012-09-10";

  src = fetchurl {
    urls =
      [ "http://www.amd64.org/pub/microcode/${name}.tar"
        "http://pkgs.fedoraproject.org/repo/pkgs/microcode_ctl/${name}.tar/559bc355d3799538584add80df2996f0/${name}.tar"
      ];
    sha256 = "065phvhx5hx5ssdd1x2p5m1yv26ak7l5aaw6yk6h95x9mxn5r111";
  };

  installPhase = ''
    mkdir -p $out/amd-ucode
    mv microcode_amd_fam15h.bin microcode_amd.bin $out/amd-ucode/
  '';

  meta = {
    description = "AMD Processor Microcode Patch";
    homepage = "http://www.amd64.org/support/microcode.html";
    license = "non-free";
  };
}


{ stdenv, fetchFromGitHub, buildGoModule }:

buildGoModule {
  pname = "linkerd-unstablle";
  version = "2020-05-01";

  src = fetchFromGitHub {
    owner = "linkerd";
    repo = "linkerd2";
    rev = "9e9f3bb1e2aeab8cf20f98f5cad159bbb6f24883";
    sha256 = "1pvj31wz1klwhcqga1m8kixdqsxwmppp9ix6r3wpp4dwfig45fm0";
  };

  vendorSha256 = "0vls58ld50jca5yn73kvg3lx4z83cc7skky54a90pkbj737y58pz";

  subPackages = [ "cli/cmd" ];

  meta = with stdenv.lib; {
    description = "A service mesh for Kubernetes and beyond.";
    homepage = "https://linkerd.io/";
    license = licenses.asl20;
    maintainers = with maintainers; [ Gonzih ];
  };
}

Fix typo in linkerd package name

{ stdenv, fetchFromGitHub, buildGoModule }:

buildGoModule {
  pname = "linkerd-unstable";
  version = "2020-05-01";

  src = fetchFromGitHub {
    owner = "linkerd";
    repo = "linkerd2";
    rev = "9e9f3bb1e2aeab8cf20f98f5cad159bbb6f24883";
    sha256 = "1pvj31wz1klwhcqga1m8kixdqsxwmppp9ix6r3wpp4dwfig45fm0";
  };

  vendorSha256 = "0vls58ld50jca5yn73kvg3lx4z83cc7skky54a90pkbj737y58pz";

  subPackages = [ "cli/cmd" ];

  meta = with stdenv.lib; {
    description = "A service mesh for Kubernetes and beyond.";
    homepage = "https://linkerd.io/";
    license = licenses.asl20;
    maintainers = with maintainers; [ Gonzih ];
  };
}


{stdenv, fetchurl}:

let
  pname = "polyml";
  version = "5.3";
in

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

  src = fetchurl {
    url = "mirror://sourceforge/${pname}/${pname}.${version}.tar.gz";
    sha256 = "154e836f4e65b5c72f8190d3c02e5ed237921cef716cb49add1e0e1e35fb2af4";
  };

  meta = {
    description = "Standard ML compiler and interpreter";
    longDescription = ''
      Poly/ML is a full implementation of Standard ML.
    '';
    homepage = http://www.polyml.org/;
    license = "LGPL";
  };
}

Update PolyML to version 5.4 Also enable hydra build for linux

{stdenv, fetchurl}:

let
  pname = "polyml";
  version = "5.4";
in

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

  src = fetchurl {
    url = "mirror://sourceforge/${pname}/${pname}.${version}.tar.gz";
    sha256 = "1ykbm4zk260dkdr8jl7mjaqxy98h65fq0z82k44b1fp5q8zy5d34";
  };

  meta = {
    description = "Standard ML compiler and interpreter";
    longDescription = ''
      Poly/ML is a full implementation of Standard ML.
    '';
    homepage = http://www.polyml.org/;
    license = "LGPL";
    platforms = with stdenv.lib.platforms; linux;
    maintainers = [ #Add your name here!
      stdenv.lib.maintainers.z77z
    ];
  };
}


{ pkgs ? import <nixpkgs> {} }:

with pkgs;
let funs = pkgs.callPackage ./nix/rust-nightly.nix { };
    cargoNightly = funs.cargo {
      date = "2016-10-04";
      hash = "1na7achkhl0vjlr0ncfkhvl0pqzbkhn02b6n1d7z1acr00wrbg75";
    };

    rustNightly = funs.rust {
      date = "2016-10-04";
      hash = "1bgwncmmxwdvsh59q7fwv3rdbb9l5bvlaj0fyr700y4rb7bxrs93";
    };

in stdenv.mkDerivation {
  name = "rux-build-env";

  SSL_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt";

  buildInputs = [
    gnumake
    (binutils.override { cross = { config = "x86_64-none-elf"; }; })
    qemu
    file
    gdb
    rustNightly
    cargoNightly
  ];
}

Add missing dependency for build

{ pkgs ? import <nixpkgs> {} }:

with pkgs;
let funs = pkgs.callPackage ./nix/rust-nightly.nix { };
    cargoNightly = funs.cargo {
      date = "2016-10-04";
      hash = "1na7achkhl0vjlr0ncfkhvl0pqzbkhn02b6n1d7z1acr00wrbg75";
    };

    rustNightly = funs.rust {
      date = "2016-10-04";
      hash = "1bgwncmmxwdvsh59q7fwv3rdbb9l5bvlaj0fyr700y4rb7bxrs93";
    };

in stdenv.mkDerivation {
  name = "rux-build-env";

  SSL_CERT_FILE = "/etc/ssl/certs/ca-bundle.crt";

  buildInputs = [
    gnumake
    (binutils.override { cross = { config = "x86_64-none-elf"; }; })
    qemu
    file
    gdb
    rustNightly
    cargoNightly
    curl
  ];
}


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

{ stdenv, callPackage, haskellPackages, tzdata, harmonicsType ? "free" }:

let
  tcd       = callPackage ./libtcd.nix    {};
  harmonics = callPackage ./harmonics.nix { type = harmonicsType; };
  xtide     = callPackage ./xtide.nix     {};

  inherit (stdenv.lib) concatStringsSep;
in
  with haskellPackages;

  mkDerivation rec {
    pname = "Tides";
    version = "0.1.0.0";
    src = ./.;
    isLibrary = true;
    isExecutable = true;
    libraryHaskellDepends = [ base ];
    executableHaskellDepends = [ base HSH random time time-locale-compat tz QuickCheck ];
    executableSystemDepends = [ tcd ];
    testHaskellDepends = [ base process ];
    enableSharedExecutables = false;
    enableSharedLibraries = false;
    configureFlags = [
      "--ghc-option=-DDEFAULT_TIDE_DB_PATH=\"${harmonics}/share/xtide\""
    ];
    shellHook = ''
      configure() {
        cabal configure --enable-tests '${concatStringsSep "' '" configureFlags}' "$@"
      }
      export HFILE_PATH=${harmonics}/share/xtide
      export PATH=${xtide}/bin:$PATH
    '';
    preCheck = "export TZDIR=${tzdata}/share/zoneinfo";
    description = "A program for exploring tidal prediction data";
    license = stdenv.lib.licenses.mit;
  }

Stop exporting the Tides library in nix

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

{ stdenv, callPackage, haskellPackages, tzdata, harmonicsType ? "free" }:

let
  tcd       = callPackage ./libtcd.nix    {};
  harmonics = callPackage ./harmonics.nix { type = harmonicsType; };
  xtide     = callPackage ./xtide.nix     {};

  inherit (stdenv.lib) concatStringsSep;
in
  with haskellPackages;

  mkDerivation rec {
    pname = "Tides";
    version = "0.1.0.0";
    src = ./.;
    isLibrary = false;
    isExecutable = true;
    libraryHaskellDepends = [ base ];
    executableHaskellDepends = [ base HSH random time time-locale-compat tz QuickCheck ];
    executableSystemDepends = [ tcd ];
    testHaskellDepends = [ base process ];
    enableSharedExecutables = false;
    enableSharedLibraries = false;
    configureFlags = [
      "--ghc-option=-DDEFAULT_TIDE_DB_PATH=\"${harmonics}/share/xtide\""
    ];
    shellHook = ''
      configure() {
        cabal configure --enable-tests '${concatStringsSep "' '" configureFlags}' "$@"
      }
      export HFILE_PATH=${harmonics}/share/xtide
      export PATH=${xtide}/bin:$PATH
    '';
    preCheck = "export TZDIR=${tzdata}/share/zoneinfo";
    description = "A program for exploring tidal prediction data";
    license = stdenv.lib.licenses.mit;
  }


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

with nixpkgs;

let

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

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

      '';

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

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

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

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

in import nixpkgs {
  overlays = [ overlay ];
}

Allow building with python 3.8 using nix

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

with nixpkgs;

let

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

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

      '';

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

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

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

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

in import nixpkgs {
  overlays = [ overlay ];
}


{ stdenv, fetchgit }:

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

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

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

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

    installTargets = [ "install_base" "install_full" ];

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

Add python so patchShebangs can patch python scripts

{ stdenv, fetchgit, python }:

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

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

    buildInputs = [ python ];

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

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

    installTargets = [ "install_base" "install_full" ];

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


{stdenv, fetchurl}:

let
  version = "5.4.1";
in

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

  src = fetchurl {
    url = "mirror://sourceforge/polyml/polyml.${version}.tar.gz";
    sha256 = "514d1d07be487b783d4dfa29dbd550b3396640579ce135a9eb5a61f08e7f9cac";
  };

  meta = {
    description = "Standard ML compiler and interpreter";
    longDescription = ''
      Poly/ML is a full implementation of Standard ML.
    '';
    homepage = http://www.polyml.org/;
    license = stdenv.lib.licenses.lgpl21;
    platforms = with stdenv.lib.platforms; linux;
    maintainers = [ #Add your name here!
      stdenv.lib.maintainers.z77z
    ];
  };
}

Update PolyML to version 5.5.1

{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "polyml-5.5.1";

  src = fetchurl {
    url = "mirror://sourceforge/polyml/polyml.5.5.1.tar.gz";
    sha256 = "16i0ir5mydl7381aijihkll19khp3z8dq0g2ja6k0pcbpkd0k06g";
  };

  meta = {
    description = "Standard ML compiler and interpreter";
    longDescription = ''
      Poly/ML is a full implementation of Standard ML.
    '';
    homepage = http://www.polyml.org/;
    license = stdenv.lib.licenses.lgpl21;
    platforms = with stdenv.lib.platforms; linux;
    maintainers = [ #Add your name here!
      stdenv.lib.maintainers.z77z
    ];
  };
}


# This file is autogenerated from update.sh in the same directory.
{
  dev = {
    version = "34.0.1809.0";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-34.0.1809.0.tar.xz";
    sha256 = "0hyqqqq2hzbzk325pk9bc70lsh0al2nqf1mlahybp5vigy5jzy88";
  };
  beta = {
    version = "33.0.1750.46";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-33.0.1750.46.tar.xz";
    sha256 = "04n43c4vn8i7qhlybqb19c2c8kri8nc1wpa2l83vin4sqxkq519h";
  };
  stable = {
    version = "32.0.1700.102";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-32.0.1700.102.tar.xz";
    sha256 = "0jxwhd7cd60ivisrnzcglqqnmy99np1vvjqa27y42d852xjx84ys";
  };
}

Update stable channel from 32.0.1700.102 -> 32.0.1700.107

# This file is autogenerated from update.sh in the same directory.
{
  dev = {
    version = "34.0.1809.0";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-34.0.1809.0.tar.xz";
    sha256 = "0hyqqqq2hzbzk325pk9bc70lsh0al2nqf1mlahybp5vigy5jzy88";
  };
  beta = {
    version = "33.0.1750.46";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-33.0.1750.46.tar.xz";
    sha256 = "04n43c4vn8i7qhlybqb19c2c8kri8nc1wpa2l83vin4sqxkq519h";
  };
  stable = {
    version = "32.0.1700.107";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-32.0.1700.107.tar.xz";
    sha256 = "1bf1gbjf4r9nf3xdn7zgq0ny1ihak21ka4rkkiadxsg8aq9vdsqz";
  };
}


{ stdenv, fetchurl, pkgconfig, fftw, libsndfile, libsamplerate
, python, alsaLib, jackaudio }:

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

  src = fetchurl {
    url = "http://aubio.org/pub/${name}.tar.bz2";
    sha256 = "18ik5nn8n984f0wnrwdfhc06b8blqgm9b2hrm7hc9m0rr039mpj9";
  };

  buildInputs =
    [ pkgconfig fftw libsndfile libsamplerate python
      # optional:
      alsaLib jackaudio
    ];

  meta = {
    description = "Library for audio labelling";
    homepage = http://aubio.org/;
    license = "GPLv2";
    maintainers = [ stdenv.lib.maintainers.marcweber ];
    platforms = stdenv.lib.platforms.linux;
  };
}

Fix the build, tidy up and add myself as a maintainer

{ stdenv, fetchurl, alsaLib, fftw, jackaudio, libsamplerate
, libsndfile, pkgconfig, python
}:

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

  src = fetchurl {
    url = "http://aubio.org/pub/${name}.tar.bz2";
    sha256 = "18ik5nn8n984f0wnrwdfhc06b8blqgm9b2hrm7hc9m0rr039mpj9";
  };

  buildInputs = [
    alsaLib fftw jackaudio libsamplerate libsndfile pkgconfig python
  ];

  configurePhase = "python waf configure --prefix=$out";

  buildPhase = "python waf";

  installPhase = "python waf install";

  meta = with stdenv.lib; {
    description = "Library for audio labelling";
    homepage = http://aubio.org/;
    license = licenses.gpl2;
    maintainers = [ maintainers.goibhniu maintainers.marcweber ];
    platforms = platforms.linux;
  };
}


{ lib
, fetchurl
, python2Packages
}:

python2Packages.buildPythonApplication rec {
  name = "salt-pepper-${version}";
  version = "0.5.0";
  src = fetchurl {
    url = "https://github.com/saltstack/pepper/releases/download/${version}/${name}.tar.gz";
    sha256 = "0gf4v5y1kp16i1na4c9qw7cgrpsh21p8ldv9r6b8gdwcxzadxbck";
  };

  doCheck = false; # no tests available

  meta = with lib; {
    description = "A CLI front-end to a running salt-api system";
    homepage = https://github.com/saltstack/pepper;
    maintainers = [ maintainers.pierrer ];
    license = licenses.asl20;
  };
}

Update salt-pepper from 0.5.0 to 0.5.5

{ lib
, fetchurl
, python2Packages
}:

python2Packages.buildPythonApplication rec {
  name = "salt-pepper-${version}";
  version = "0.5.5";
  src = fetchurl {
    url = "https://github.com/saltstack/pepper/releases/download/${version}/${name}.tar.gz";
    sha256 = "1wj1k64ly6af6qsmiizlx32jxh23a37smd9wb57l5zl0x8sfqq1n";
  };

  doCheck = false; # no tests available

  meta = with lib; {
    description = "A CLI front-end to a running salt-api system";
    homepage = https://github.com/saltstack/pepper;
    maintainers = [ maintainers.pierrer ];
    license = licenses.asl20;
  };
}


{stdenv, fetchurl, fuse, python, perl, keyutils, pam, nss, nspr}:
stdenv.mkDerivation {
  name = "ecryptfs-82";

  src = fetchurl {
    url = http://launchpad.net/ecryptfs/trunk/82/+download/ecryptfs-utils_82.orig.tar.gz;
    sha256 = "1w3swispgp71prz8h56hqby2wwnvam5vllqvc69rn8cf605i69a6";
  };

  NIX_CFLAGS_COMPILE = "-I${nspr}/include/nspr -I${nss}/include/nss";

  buildInputs = [ python perl keyutils pam nss nspr ];

  meta = {
    description = "Enterprise-class stacked cryptographic filesystem";
    license = "GPLv2+";
  };
}

Update from 82 -> 104

{ stdenv, fetchurl, pkgconfig, perl, keyutils, nss, nspr, python, pam
, intltool, makeWrapper, coreutils, gettext, cryptsetup, lvm2, rsync, which }:

stdenv.mkDerivation {
  name = "ecryptfs-104";

  src = fetchurl {
    url = http://launchpad.net/ecryptfs/trunk/104/+download/ecryptfs-utils_104.orig.tar.gz;
    sha256 = "0f3lzpjw97vcdqzzgii03j3knd6pgwn1y0lpaaf46iidaiv0282a";
  };

  buildInputs = [ pkgconfig perl nss nspr python pam intltool makeWrapper ];
  propagatedBuildInputs = [ coreutils gettext cryptsetup lvm2 rsync keyutils which ];

  postInstall = ''
    FILES="$(grep -r '/bin/sh' $out/bin | sed 's,:.*,,' | uniq)"
    for file in $FILES; do
      sed -i $file -e "s,\(/sbin/u\?mount.ecryptfs\(_private\)\?\),$out\1," \
        -e "s,\(/sbin/cryptsetup\),${cryptsetup}\1," \
        -e "s,\(/sbin/dmsetup\),${lvm2}\1," \
        -e 's,/sbin/\(unix_chkpwd\),\1,'
      wrapProgram $file \
        --prefix PATH ":" "${coreutils}/bin" \
        --prefix PATH ":" "${gettext}/bin" \
        --prefix PATH ":" "${rsync}/bin" \
        --prefix PATH ":" "${keyutils}/bin" \
        --prefix PATH ":" "${which}/bin" \
        --prefix PATH ":" "$out/bin"
    done
  '';

  meta = with stdenv.lib; {
    description = "Enterprise-class stacked cryptographic filesystem";
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
  };
}


{stdenv, fetchurl, unzip}:

stdenv.mkDerivation {
  name = "openjdk-7b127";

  src = fetchurl {
    url = http://www.java.net/download/openjdk/jdk7/promoted/b147/openjdk-7-fcs-src-b147-27_jun_2011.zip;
    sha256 = "1qhwlz9y5qmwmja4qnxg6sn3pgsg1i11fb9j41w8l26acyhk34rs";
  };

  buildInputs = [ unzip ];
}

Add 'free' to $PATH for the build

{stdenv, fetchurl, unzip, procps}:

stdenv.mkDerivation {
  name = "openjdk-7b127";

  src = fetchurl {
    url = http://www.java.net/download/openjdk/jdk7/promoted/b147/openjdk-7-fcs-src-b147-27_jun_2011.zip;
    sha256 = "1qhwlz9y5qmwmja4qnxg6sn3pgsg1i11fb9j41w8l26acyhk34rs";
  };

  buildInputs = [ unzip procps ];
}


{ stdenv, lib, fetchurl, gtk, libdv, libjpeg, libpng, libX11, pkgconfig, SDL, SDL_gfx
, withMinimal ? false
}:

# TODO:
# - make dependencies optional
# - libpng-apng as alternative to libpng?
# - libXxf86dga support? checking for XF86DGAQueryExtension in -lXxf86dga... no

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

  src = fetchurl {
    url = "mirror://sourceforge/mjpeg/${name}.tar.gz";
    sha256 = "01y4xpfdvd4zgv6fmcjny9mr1gbfd4y2i4adp657ydw6fqyi8kw6";
  };

  hardeningDisable = [ "format" ];

  buildInputs = [ libdv libjpeg libpng pkgconfig ]
              ++ lib.optional (!withMinimal) [ gtk libX11 SDL SDL_gfx ];

  NIX_CFLAGS_COMPILE = lib.optional (!withMinimal) "-I${SDL}/include/SDL";

  postPatch = ''
    sed -i -e '/ARCHFLAGS=/s:=.*:=:' configure
  '';

  enableParallelBuilding = true;

  outputs = [ "out" "lib" ];

  meta = with stdenv.lib; {
    description = "A suite of programs for processing MPEG or MJPEG video";
    homepage = "http://mjpeg.sourceforge.net/";
    license = licenses.gpl2;
    platforms = platforms.unix;
    maintainers = with maintainers; [ abbradar ];
  };
}

Make explicit that 'dev' output of SDL is used

{ stdenv, lib, fetchurl, gtk, libdv, libjpeg, libpng, libX11, pkgconfig, SDL, SDL_gfx
, withMinimal ? false
}:

# TODO:
# - make dependencies optional
# - libpng-apng as alternative to libpng?
# - libXxf86dga support? checking for XF86DGAQueryExtension in -lXxf86dga... no

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

  src = fetchurl {
    url = "mirror://sourceforge/mjpeg/${name}.tar.gz";
    sha256 = "01y4xpfdvd4zgv6fmcjny9mr1gbfd4y2i4adp657ydw6fqyi8kw6";
  };

  hardeningDisable = [ "format" ];

  buildInputs = [ libdv libjpeg libpng pkgconfig ]
              ++ lib.optional (!withMinimal) [ gtk libX11 SDL SDL_gfx ];

  NIX_CFLAGS_COMPILE = lib.optional (!withMinimal) "-I${SDL.dev}/include/SDL";

  postPatch = ''
    sed -i -e '/ARCHFLAGS=/s:=.*:=:' configure
  '';

  enableParallelBuilding = true;

  outputs = [ "out" "lib" ];

  meta = with stdenv.lib; {
    description = "A suite of programs for processing MPEG or MJPEG video";
    homepage = "http://mjpeg.sourceforge.net/";
    license = licenses.gpl2;
    platforms = platforms.unix;
    maintainers = with maintainers; [ abbradar ];
  };
}


{ lib, stdenv, fetchFromGitHub, libroxml, proj, libyamlcpp, boost } :

stdenv.mkDerivation rec {
  pname = "osm2xmap";
  version = "2.0";

  src = fetchFromGitHub {
    sha256 = "1d3f18wzk240yp0q8i2vskhcfj5ar61s4hw83vgps0wr2aglph3w";
    repo = "osm2xmap";
    owner = "sembruk";
    rev = "v${version}";
  };

  makeFlags = [
    "GIT_VERSION=${version}"
    "GIT_TIMESTAMP="
    "SHAREDIR=${placeholder "out"}/share/osm2xmap"
    "INSTALL_BINDIR=${placeholder "out"}/bin"
    "INSTALL_MANDIR=${placeholder "out"}/share/man/man1"
  ];

  NIX_CFLAGS_COMPILE = "-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H";

  buildInputs = [ libroxml proj libyamlcpp boost ];

  meta = with lib; {
    homepage = "https://github.com/sembruk/osm2xmap";
    description = "Converter from OpenStreetMap data format to OpenOrienteering Mapper format";
    license = licenses.gpl3;
    maintainers = [ maintainers.mpickering ];
    platforms = with lib.platforms; linux;
    # it probably needs https://proj.org/development/migration.html
    broken = true;
  };
}

Revert "osm2xmap: mark as broken"

{ lib, stdenv, fetchFromGitHub, libroxml, proj, libyamlcpp, boost } :

stdenv.mkDerivation rec {
  pname = "osm2xmap";
  version = "2.0";

  src = fetchFromGitHub {
    sha256 = "1d3f18wzk240yp0q8i2vskhcfj5ar61s4hw83vgps0wr2aglph3w";
    repo = "osm2xmap";
    owner = "sembruk";
    rev = "v${version}";
  };

  makeFlags = [
    "GIT_VERSION=${version}"
    "GIT_TIMESTAMP="
    "SHAREDIR=${placeholder "out"}/share/osm2xmap"
    "INSTALL_BINDIR=${placeholder "out"}/bin"
    "INSTALL_MANDIR=${placeholder "out"}/share/man/man1"
  ];

  NIX_CFLAGS_COMPILE = "-DACCEPT_USE_OF_DEPRECATED_PROJ_API_H";

  buildInputs = [ libroxml proj libyamlcpp boost ];

  meta = with lib; {
    homepage = "https://github.com/sembruk/osm2xmap";
    description = "Converter from OpenStreetMap data format to OpenOrienteering Mapper format";
    license = licenses.gpl3;
    maintainers = [ maintainers.mpickering ];
    platforms = with lib.platforms; linux;
  };
}


{stdenv, fetchurl, pkgconfig }:

stdenv.mkDerivation rec {
  name = "liboil-0.3.17";

  src = fetchurl {
    url = "${meta.homepage}/download/${name}.tar.gz";
    sha256 = "0sgwic99hxlb1av8cm0albzh8myb7r3lpcwxfm606l0bkc3h4pqh";
  };

  buildInputs = [ pkgconfig ];

  patches = [ ./x86_64-cpuid.patch ];

  # fix "argb_paint_i386.c:53:Incorrect register `%rax' used with `l' suffix"
  # errors
  configureFlags = stdenv.lib.optional stdenv.isDarwin "--build=x86_64";

  meta = with stdenv.lib; {
    description = "A library of simple functions that are optimized for various CPUs";
    homepage    = http://liboil.freedesktop.org;
    license     = licenses.bsd2;
    maintainers = with maintainers; [ lovek323 ];
    platforms   = platforms.all;
  };
}

Fix liboil build on Darwin

{stdenv, fetchurl, pkgconfig }:

stdenv.mkDerivation rec {
  name = "liboil-0.3.17";

  src = fetchurl {
    url = "${meta.homepage}/download/${name}.tar.gz";
    sha256 = "0sgwic99hxlb1av8cm0albzh8myb7r3lpcwxfm606l0bkc3h4pqh";
  };

  buildInputs = [ pkgconfig ];

  patches = [ ./x86_64-cpuid.patch ];

  # fix "argb_paint_i386.c:53:Incorrect register `%rax' used with `l' suffix"
  # errors
  configureFlags = stdenv.lib.optional stdenv.isDarwin "--build=x86_64";

  # fixes a cast in inline asm: easier than patching
  buildFlags = stdenv.lib.optional stdenv.isDarwin "CFLAGS=-fheinous-gnu-extensions";

  meta = with stdenv.lib; {
    description = "A library of simple functions that are optimized for various CPUs";
    homepage    = http://liboil.freedesktop.org;
    license     = licenses.bsd2;
    maintainers = with maintainers; [ lovek323 ];
    platforms   = platforms.all;
  };
}


{ stdenv, fetchFromGitHub, pkgconfig, cmake
, zlib, python, libssh2, openssl, curl, http-parser
, libiconv, Security
}:

stdenv.mkDerivation (rec {
  name = "libgit2-${version}";
  version = "0.26.8";
  # keep the version in sync with pythonPackages.pygit2 and gnome3.libgit2-glib

  src = fetchFromGitHub {
    owner = "libgit2";
    repo = "libgit2";
    rev = "v${version}";
    sha256 = "0wmjgvz8nrpk2dsn5bcc87nl0j5hb6pah2hzrj0b6jkk9mnin9fl";
  };

  cmakeFlags = [ "-DTHREADSAFE=ON" ];

  nativeBuildInputs = [ cmake python pkgconfig ];

  buildInputs = [ zlib libssh2 openssl http-parser curl ]
    ++ stdenv.lib.optional stdenv.isDarwin Security;

  propagatedBuildInputs = stdenv.lib.optional (!stdenv.isLinux) [ libiconv ];

  enableParallelBuilding = true;

  doCheck = false; # hangs. or very expensive?

  meta = with stdenv.lib; {
    description = "The Git linkable library";
    homepage = https://libgit2.github.com/;
    license = licenses.gpl2;
    platforms = with platforms; all;
  };
} // stdenv.lib.optionalAttrs (!stdenv.isLinux) {
})

Revert "libgit2: 0.26.6 -> 0.26.8"

{ stdenv, fetchFromGitHub, pkgconfig, cmake
, zlib, python, libssh2, openssl, curl, http-parser
, libiconv, Security
}:

stdenv.mkDerivation (rec {
  name = "libgit2-${version}";
  version = "0.26.6";
  # keep the version in sync with pythonPackages.pygit2 and gnome3.libgit2-glib

  src = fetchFromGitHub {
    owner = "libgit2";
    repo = "libgit2";
    rev = "v${version}";
    sha256 = "17pjvprmdrx4h6bb1hhc98w9qi6ki7yl57f090n9kbhswxqfs7s3";
  };

  cmakeFlags = [ "-DTHREADSAFE=ON" ];

  nativeBuildInputs = [ cmake python pkgconfig ];

  buildInputs = [ zlib libssh2 openssl http-parser curl ]
    ++ stdenv.lib.optional stdenv.isDarwin Security;

  propagatedBuildInputs = stdenv.lib.optional (!stdenv.isLinux) [ libiconv ];

  enableParallelBuilding = true;

  doCheck = false; # hangs. or very expensive?

  meta = with stdenv.lib; {
    description = "The Git linkable library";
    homepage = https://libgit2.github.com/;
    license = licenses.gpl2;
    platforms = with platforms; all;
  };
} // stdenv.lib.optionalAttrs (!stdenv.isLinux) {
})


{ pkgs }:
let
  marge = pkgs.callPackage ./marge.nix {};
  version = marge.version;
  basicShadow =
    # minimal user setup, so ssh won't whine 'No user exists for uid 0'
    pkgs.runCommand "basic-shadow-setup" {}
      ''
        mkdir -p $out
        cd $out
        ${pkgs.dockerTools.shadowSetup}
        mkdir -p root/.ssh
      '';
in
  pkgs.dockerTools.buildImage {
    name = "smarkets/marge-bot";
    tag = "${version}";
    contents =
      with pkgs; [
        basicShadow
        bash
        coreutils
        git
        glibcLocales
        openssh
      ] ++ [ marge ];
    config = {
      Entrypoint = [ "/bin/marge.app" ];
      Env = ["LANG=en_US.UTF-8" ''LOCALE_ARCHIVE=/lib/locale/locale-archive''];
    };
  }

Fix docker image root user creation broken in 95d31c7

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


{ stdenv, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  name = "hcloud-${version}";
  version = "1.6.1";
  goPackagePath = "github.com/hetznercloud/cli";

  src = fetchFromGitHub {
    owner = "hetznercloud";
    repo = "cli";
    rev = "v${version}";
    sha256 = "0v5n7y8vb23iva51kb15da198yk7glc1fix193icrk3pvcbj5bjr";
  };

  buildFlagsArray = [ "-ldflags=" "-w -X github.com/hetznercloud/cli/cli.Version=${version}" ];

  meta = {
    description = "A command-line interface for Hetzner Cloud, a provider for cloud virtual private servers";
    homepage = https://github.com/hetznercloud/cli;
    license = stdenv.lib.licenses.mit;
    platforms = stdenv.lib.platforms.all;
    maintainers = [ stdenv.lib.maintainers.zauberpony ];
  };
}

Add autocomplete support for bash and zsh

{ stdenv, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  name = "hcloud-${version}";
  version = "1.6.1";
  goPackagePath = "github.com/hetznercloud/cli";

  src = fetchFromGitHub {
    owner = "hetznercloud";
    repo = "cli";
    rev = "v${version}";
    sha256 = "0v5n7y8vb23iva51kb15da198yk7glc1fix193icrk3pvcbj5bjr";
  };

  buildFlagsArray = [ "-ldflags=" "-w -X github.com/hetznercloud/cli/cli.Version=${version}" ];

  postInstall = ''
    mkdir -p \
      $bin/etc/bash_completion.d \
      $bin/share/zsh/vendor-completions

    # Add bash completions
    $bin/bin/hcloud completion bash > "$bin/etc/bash_completion.d/hcloud"

    # Add zsh completions
    echo "#compdef hcloud" > "$bin/share/zsh/vendor-completions/_hcloud"
    $bin/bin/hcloud completion zsh >> "$bin/share/zsh/vendor-completions/_hcloud"
  '';

  meta = {
    description = "A command-line interface for Hetzner Cloud, a provider for cloud virtual private servers";
    homepage = https://github.com/hetznercloud/cli;
    license = stdenv.lib.licenses.mit;
    platforms = stdenv.lib.platforms.all;
    maintainers = [ stdenv.lib.maintainers.zauberpony ];
  };
}


{ fetchFromGitHub, stdenv, autoreconfHook }:

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

  src = fetchFromGitHub {
    owner = "mrjimenez";
    repo = "pupnp";
    rev = "release-${version}";
    sha256 = "1w0kfq1pg3y2wl6gwkm1w872g0qz29w1z9wj08xxmwnk5mkpvsrl";
  };

  nativeBuildInputs = [ autoreconfHook ];

  hardeningDisable = [ "fortify" ];

  meta = {
    description = "libupnp, an open source UPnP development kit for Linux";

    longDescription = ''
      The Linux SDK for UPnP Devices (libupnp) provides developers
      with an API and open source code for building control points,
      devices, and bridges that are compliant with Version 1.0 of the
      UPnP Device Architecture Specification.
    '';

    license = "BSD-style";

    homepage = http://pupnp.sourceforge.net/;
    platforms = stdenv.lib.platforms.unix;
  };
}

Revert "libupnp: 1.6.21 -> 1.8.3"

{ fetchFromGitHub, stdenv, autoreconfHook }:

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

  src = fetchFromGitHub {
    owner = "mrjimenez";
    repo = "pupnp";
    rev = "release-${version}";
    sha256 = "07ksfhadinaa20542gblrxi9pqz0v6y70a836hp3qr4037id4nm9";
  };

  nativeBuildInputs = [ autoreconfHook ];

  hardeningDisable = [ "fortify" ];

  meta = {
    description = "libupnp, an open source UPnP development kit for Linux";

    longDescription = ''
      The Linux SDK for UPnP Devices (libupnp) provides developers
      with an API and open source code for building control points,
      devices, and bridges that are compliant with Version 1.0 of the
      UPnP Device Architecture Specification.
    '';

    license = "BSD-style";

    homepage = http://pupnp.sourceforge.net/;
    platforms = stdenv.lib.platforms.unix;
  };
}


{ stdenv, fetchurl, pkgconfig, libuuid }:

stdenv.mkDerivation rec {
  name = "e2fsprogs-1.42.7";

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

  buildInputs = [ pkgconfig libuuid ];

  crossAttrs = {
    preConfigure = ''
      export CC=$crossConfig-gcc
    '';
  };

  # libuuid, libblkid, uuidd and fsck are in util-linux-ng (the "libuuid" dependency).
  configureFlags = "--enable-elf-shlibs --disable-libuuid --disable-libblkid --disable-uuidd --disable-fsck";

  enableParallelBuilding = true;

  preInstall = "installFlagsArray=('LN=ln -s')";

  postInstall = "make install-libs";

  dontGzipMan = true; # See issue #523

  meta = {
    homepage = http://e2fsprogs.sourceforge.net/;
    description = "Tools for creating and checking ext2/ext3/ext4 filesystems";
    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.eelco ];
  };
}

Revert "e2fsprogs: Fix manpages", no more need for this

{ stdenv, fetchurl, pkgconfig, libuuid }:

stdenv.mkDerivation rec {
  name = "e2fsprogs-1.42.7";

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

  buildInputs = [ pkgconfig libuuid ];

  crossAttrs = {
    preConfigure = ''
      export CC=$crossConfig-gcc
    '';
  };

  # libuuid, libblkid, uuidd and fsck are in util-linux-ng (the "libuuid" dependency).
  configureFlags = "--enable-elf-shlibs --disable-libuuid --disable-libblkid --disable-uuidd --disable-fsck";

  enableParallelBuilding = true;

  preInstall = "installFlagsArray=('LN=ln -s')";

  postInstall = "make install-libs";

  meta = {
    homepage = http://e2fsprogs.sourceforge.net/;
    description = "Tools for creating and checking ext2/ext3/ext4 filesystems";
    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.eelco ];
  };
}


{ stdenv, fetchurl }:

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

  src = fetchurl {
    url = ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/stable/freetds-stable.tgz;
    sha256 = "0r946axzxs0czsmr7283w7vmk5jx3jnxxc32d2ncxsrsh2yli0ba";
  };

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

Update expression with working url.

{ stdenv, fetchurl }:

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

  src = fetchurl {
    url = ftp://ftp.astron.com/pub/freetds/stable/freetds-stable.tgz;
    sha256 = "0r946axzxs0czsmr7283w7vmk5jx3jnxxc32d2ncxsrsh2yli0ba";
  };

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


{stdenv, fetchurl, audiofile, libtiff}:
stdenv.mkDerivation rec {
  version = "0.0.6";
  pname = "spandsp";
  src=fetchurl {
    url = "https://www.soft-switch.org/downloads/spandsp/spandsp-${version}.tar.gz";
    sha256 = "0rclrkyspzk575v8fslzjpgp4y2s4x7xk3r55ycvpi4agv33l1fc";
  };
  buildInputs = [];
  propagatedBuildInputs = [audiofile libtiff];
  meta = {
    homepage = http://www.creytiv.com/baresip.html;
    platforms = with stdenv.lib.platforms; linux;
    maintainers = with stdenv.lib.maintainers; [raskin];
    license = stdenv.lib.licenses.gpl2;
    downloadPage = "http://www.soft-switch.org/downloads/spandsp/";
    inherit version;
    updateWalker = true;
  };
}

Use multiple outputs to reduce closure size

{stdenv, fetchurl, audiofile, libtiff}:
stdenv.mkDerivation rec {
  version = "0.0.6";
  pname = "spandsp";
  src=fetchurl {
    url = "https://www.soft-switch.org/downloads/spandsp/spandsp-${version}.tar.gz";
    sha256 = "0rclrkyspzk575v8fslzjpgp4y2s4x7xk3r55ycvpi4agv33l1fc";
  };
  outputs = [ "out" "dev" ];
  propagatedBuildInputs = [audiofile libtiff];
  meta = {
    homepage = http://www.creytiv.com/baresip.html;
    platforms = with stdenv.lib.platforms; linux;
    maintainers = with stdenv.lib.maintainers; [raskin];
    license = stdenv.lib.licenses.gpl2;
    downloadPage = "http://www.soft-switch.org/downloads/spandsp/";
    inherit version;
    updateWalker = true;
  };
}


a :
let
  s = import ./src-for-default.nix;
  buildInputs = with a; [
    chipmunk sqlite curl zlib bzip2 libjpeg libpng
    freeglut mesa SDL SDL_mixer SDL_image SDL_net SDL_ttf
    lua5 ode libxdg_basedir libxml2
  ];
in
rec {
  src = a.fetchUrlFromSrcInfo s;

  inherit (s) name;
  inherit buildInputs;
  configureFlags = [];

  /* doConfigure should be removed if not needed */
  phaseNames = [ "doConfigure" "doMakeInstall"];

  meta = {
    description = "X-Moto - obstacled race game";
    maintainers = [
      a.lib.maintainers.raskin
      a.lib.maintainers.viric
    ];
    platforms = a.lib.platforms.linux;
  };
}

Fix Xmoto build (missing include)

a :
let
  s = import ./src-for-default.nix;
  buildInputs = with a; [
    chipmunk sqlite curl zlib bzip2 libjpeg libpng
    freeglut mesa SDL SDL_mixer SDL_image SDL_net SDL_ttf
    lua5 ode libxdg_basedir libxml2
  ];
in
rec {
  src = a.fetchUrlFromSrcInfo s;

  inherit (s) name;
  inherit buildInputs;
  configureFlags = [];

  /* doConfigure should be removed if not needed */
  phaseNames = [ "patchIncludes" "doConfigure" "doMakeInstall"];
  patchIncludes = a.fullDepEntry ''
    sed -e '1i#include <sys/types.h>' -i src/helpers//System.cpp
    sed -e '1i#include <unistd.h>' -i src/helpers//System.cpp
  '' ["doUnpack" "minInit"];

  meta = {
    description = "X-Moto - obstacled race game";
    maintainers = [
      a.lib.maintainers.raskin
      a.lib.maintainers.viric
    ];
    platforms = a.lib.platforms.linux;
  };
}


{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "netselect-0.3";

  src = fetchurl {
    url = http://alumnit.ca/~apenwarr/netselect/netselect-0.3.tar.gz;
    sha256 = "0y69z59vylj9x9nk5jqn6ihx7dkzg09gpv2w1q1rs8fmi4jr90gy";
  };

  preBuild = "
    makeFlagsArray=(PREFIX=$out)
    substituteInPlace Makefile --replace '-o root' '' --replace '-g root' ''
  ";

  meta = {
    homepage = http://alumnit.ca/~apenwarr/netselect/;
    description = "An ultrafast intelligent parallelizing binary-search implementation of \"ping\"";
    license = "BSD";
    platforms = stdenv.lib.platforms.linux;
  };
}

Fix attempt to use unsupported permissions on files in store

{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "netselect-0.3";

  src = fetchurl {
    url = http://alumnit.ca/~apenwarr/netselect/netselect-0.3.tar.gz;
    sha256 = "0y69z59vylj9x9nk5jqn6ihx7dkzg09gpv2w1q1rs8fmi4jr90gy";
  };

  preBuild = ''
    makeFlagsArray=(PREFIX=$out)
    substituteInPlace Makefile \
      --replace "-o root" "" \
      --replace "-g root" "" \
      --replace "4755"    "0755"
  '';

  meta = {
    homepage = http://alumnit.ca/~apenwarr/netselect/;
    description = "An ultrafast intelligent parallelizing binary-search implementation of \"ping\"";
    license = "BSD";
    platforms = stdenv.lib.platforms.linux;
  };
}


{ config, pkgs, ... }:

  {
  # List packages installed in system profile. To search by name, run:
  environment.systemPackages =
    [
      pkgs.awscli
      pkgs.clojure
      pkgs.docker
      pkgs.fira-code
      pkgs.htop
      pkgs.jq
      pkgs.mosh
      pkgs.neovim
      pkgs.nodejs
      pkgs.ripgrep
      pkgs.skhd
      pkgs.tmux
      pkgs.vim
      pkgs.yabai
    ];

    nixpkgs.overlays = [
      (self: super: {
        neovim = super.neovim.override {
          viAlias = true;
          vimAlias = true;
        };
      })
    ];

  # Used for backwards compatibility, please read the changelog before changing.
  # $ darwin-rebuild changelog
  system.stateVersion = 4;

 # Fonts
 fonts = {
   enableFontDir = true;
   fonts = [ pkgs.fira-code ];
 };

  # Shell
  programs.bash.enable = false;
  programs.zsh.enable = true;

  # Enable/Disable services
  services.skhd.enable = true;
  services.yabai = {
    enable = true;
    package = pkgs.yabai;
  };

}

Add new darwin Nix packages

{ config, pkgs, ... }:

  {
  # List packages installed in system profile. To search by name, run:
  environment.systemPackages =
    [
      pkgs.awscli
      pkgs.clojure
      pkgs.docker
      pkgs.docker-compose
      pkgs.fira-code
      pkgs.fzf
      pkgs.htop
      pkgs.jq
      pkgs.kubectl
      pkgs.mosh
      pkgs.neovim
      pkgs.nodejs
      pkgs.ripgrep
      pkgs.skhd
      pkgs.tmux
      pkgs.vim
      pkgs.watch
      pkgs.yabai
    ];

    nixpkgs.overlays = [
      (self: super: {
        neovim = super.neovim.override {
          viAlias = true;
          vimAlias = true;
        };
      })
    ];

  # Used for backwards compatibility, please read the changelog before changing.
  # $ darwin-rebuild changelog
  system.stateVersion = 4;

 # Fonts
 fonts = {
   enableFontDir = true;
   fonts = [ pkgs.fira-code ];
 };

  # Shell
  programs.bash.enable = false;
  programs.zsh.enable = true;

  # Enable/Disable services
  services.skhd.enable = true;
  services.yabai = {
    enable = true;
    package = pkgs.yabai;
  };

}