{ pkgs, ... }:

{
  programs.neovim.enable = true;
  programs.neovim.vimAlias = true;
  programs.neovim.configure = {
    customRC = builtins.readFile ./init.vim;
  };
  # TODO include other neovim settings
  home.file.".vimrc".source = ./init.vim;

  # EDITOR is actually line editor. Yay history.
  home.sessionVariables.EDITOR = "vim -e";
  # VISUAL is is for full terminal.
  home.sessionVariables.VISUAL = "vim";
}

Fix neovim home manager warning

{ pkgs, ... }:

{
  programs.neovim.enable = true;
  programs.neovim.vimAlias = true;
  programs.neovim.extraConfig = builtins.readFile ./init.vim;
  # TODO include other neovim settings
  home.file.".vimrc".source = ./init.vim;

  # EDITOR is actually line editor. Yay history.
  home.sessionVariables.EDITOR = "vim -e";
  # VISUAL is is for full terminal.
  home.sessionVariables.VISUAL = "vim";
}


{ stdenv, fetchurl, fftwFloat, gtk2, ladspaPlugins, libjack2, liblo, libxml2
, makeWrapper, pkgconfig, perlPackages
}:

stdenv.mkDerivation {
  name = "jamin-0.95.0";

  src = fetchurl {
    url = "mirror://sourceforge/jamin/jamin-0.95.0.tar.gz";
    sha256 = "0g5v74cm0q3p3pzl6xmnp4rqayaymfli7c6z8s78h9rgd24fwbvn";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ fftwFloat gtk2 ladspaPlugins libjack2 liblo libxml2 makeWrapper ]
    ++ (with perlPackages; [ perl XMLParser ]);

  NIX_LDFLAGS = "-ldl";

  postInstall = ''
    wrapProgram $out/bin/jamin --set LADSPA_PATH ${ladspaPlugins}/lib/ladspa
  '';

  meta = with stdenv.lib; {
    homepage = "http://jamin.sourceforge.net";
    description = "JACK Audio Mastering interface";
    license = licenses.gpl2;
    maintainers = [ maintainers.nico202 ];
    platforms = platforms.linux;
  };
}

Put version into variable, use variable interpolation

{ stdenv, fetchurl, fftwFloat, gtk2, ladspaPlugins, libjack2, liblo, libxml2
, makeWrapper, pkgconfig, perlPackages
}:

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

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

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ fftwFloat gtk2 ladspaPlugins libjack2 liblo libxml2 makeWrapper ]
    ++ (with perlPackages; [ perl XMLParser ]);

  NIX_LDFLAGS = "-ldl";

  postInstall = ''
    wrapProgram $out/bin/jamin --set LADSPA_PATH ${ladspaPlugins}/lib/ladspa
  '';

  meta = with stdenv.lib; {
    homepage = "http://jamin.sourceforge.net";
    description = "JACK Audio Mastering interface";
    license = licenses.gpl2;
    maintainers = [ maintainers.nico202 ];
    platforms = platforms.linux;
  };
}


{stdenv, fetchurl, m4}:

stdenv.mkDerivation rec {
  name = "elfutils-0.143";

  src = fetchurl {
    url = "https://fedorahosted.org/releases/e/l/elfutils/${name}.tar.bz2";
    sha256 = "1zrqs93m6frg7j70a96xdhdb4mnzmqgh91f9bbm39jnmgs50qp23";
  };

  buildInputs = [m4];

  dontAddDisableDepTrack = true;

  meta = {
    homepage = https://fedorahosted.org/elfutils/;
  };
}

Update elfutils: the old ones are inaccessible, and too old to be found on other mirrors

{stdenv, fetchurl, m4}:

stdenv.mkDerivation rec {
  name = "elfutils-0.148";

  src = fetchurl {
    urls = [
      "https://fedorahosted.org/releases/e/l/elfutils/${name}.tar.bz2"
      "mirror://gentoo/distfiles/${name}.tar.bz2"
      ];
    sha256 = "1nl7x2gidd2i048yjlvyzhpbca9793z435cw8bsircjxfi5gmswa";
  };

  buildInputs = [m4];

  dontAddDisableDepTrack = true;

  meta = {
    homepage = https://fedorahosted.org/elfutils/;
  };
}


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

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

Fix build for iOS cross compilation

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

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


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

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

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

  buildInputs = [ zlib bzip2 openssl attr lzo libgcrypt e2fsprogs ];

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

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

Allow dar to build on Darwin

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

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

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

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

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

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


{ stdenv, fetchurl, eventlog, pkgconfig, glib, python, systemd, perl }:

stdenv.mkDerivation {
  name = "syslog-ng-3.5.4.1";

  src = fetchurl {
    url = "http://www.balabit.com/downloads/files?path=/syslog-ng/sources/3.5.4.1/source/syslog-ng_3.5.4.1.tar.gz";
    sha256 = "0rkgrmnyx1x6m3jw5n49k7r1dcg79lxh900g74rgvd3j86g9dilj";
  };

  buildInputs = [ eventlog pkgconfig glib python systemd perl ];

  configureFlags = [
    "--enable-dynamic-linking"
    "--enable-systemd"
    "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
  ];

  meta = {
    homepage = "http://www.balabit.com/network-security/syslog-ng/";
    description = "Next-generation syslogd with advanced networking and filtering capabilities";
    license = stdenv.lib.licenses.gpl2;
  };
}

Update from 3.5.4.1 to 3.5.6

{ stdenv, fetchurl, eventlog, pkgconfig, glib, python, systemd, perl }:

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

  version = "3.5.6";

  src = fetchurl {
    url = "http://www.balabit.com/downloads/files?path=/syslog-ng/sources/${version}/source/syslog-ng_${version}.tar.gz";
    sha256 = "19i1idklpgn6mz0mg7194by5fjgvvh5n4v2a0rr1z0778l2038kc";
  };

  buildInputs = [ eventlog pkgconfig glib python systemd perl ];

  configureFlags = [
    "--enable-dynamic-linking"
    "--enable-systemd"
    "--with-systemdsystemunitdir=$(out)/etc/systemd/system"
  ];

  meta = with stdenv.lib; {
    homepage = "http://www.balabit.com/network-security/syslog-ng/";
    description = "Next-generation syslogd with advanced networking and filtering capabilities";
    license = licenses.gpl2;
    maintainers = [ maintainers.rickynils ];
  };
}


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

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

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

  buildInputs = [ pcsclite pkgconfig libusb1 ];

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

Update from 1.4.14 -> 1.4.15

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

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

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

  buildInputs = [ pcsclite pkgconfig libusb1 ];

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


{ stdenv, fetchurl, xz, zlib, pkgconfig, libxslt }:

stdenv.mkDerivation rec {
  name = "kmod-12";

  src = fetchurl {
    url = "mirror://kernel/linux/utils/kernel/kmod/${name}.tar.xz";
    sha256 = "c6189dd8c5a1e8d9224e8506bd188c0cd5dfa119fd6b7e5869b3640cbe8bf92f";
  };

  # Disable xz/zlib support to prevent needing them in the initrd.

  buildInputs = [ pkgconfig libxslt /* xz zlib */ ];

  configureFlags = [ "--sysconfdir=/etc" /* "--with-xz" "--with-zlib" */ ];

  patches = [ ./module-dir.patch ];

  postInstall = ''
    ln -s kmod $out/bin/lsmod
    mkdir -p $out/sbin
    for prog in rmmod insmod modinfo modprobe depmod; do
      ln -sv $out/bin/kmod $out/sbin/$prog
    done
  '';

  meta = {
    homepage = http://www.kernel.org/pub/linux/utils/kernel/kmod/;
    description = "Tools for loading and managing Linux kernel modules";
    maintainers = [ stdenv.lib.maintainers.shlevy ];
    platforms = stdenv.lib.platforms.linux;
  };
}

Upgrade kmod from 12 -> 15

{ stdenv, fetchurl, xz, zlib, pkgconfig, libxslt }:

stdenv.mkDerivation rec {
  name = "kmod-15";

  src = fetchurl {
    url = "mirror://kernel/linux/utils/kernel/kmod/${name}.tar.xz";
    sha256 = "17nasn7kpbmbcgyfn9lh50k00bg6qmccxrhzd2m4d6wjw6khxvz8";
  };

  # Disable xz/zlib support to prevent needing them in the initrd.

  buildInputs = [ pkgconfig libxslt /* xz zlib */ ];

  configureFlags = [ "--sysconfdir=/etc" /* "--with-xz" "--with-zlib" */ ];

  patches = [ ./module-dir.patch ];

  postInstall = ''
    ln -s kmod $out/bin/lsmod
    mkdir -p $out/sbin
    for prog in rmmod insmod modinfo modprobe depmod; do
      ln -sv $out/bin/kmod $out/sbin/$prog
    done
  '';

  meta = {
    homepage = http://www.kernel.org/pub/linux/utils/kernel/kmod/;
    description = "Tools for loading and managing Linux kernel modules";
    maintainers = [ stdenv.lib.maintainers.shlevy ];
    platforms = stdenv.lib.platforms.linux;
  };
}


{ stdenv, fetchurl, gnu_efi }:

stdenv.mkDerivation rec {
  name = "gummiboot-16";

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

  buildFlags = [
    "GNU_EFI=${gnu_efi}"
  ];

  installPhase = "mkdir -p $out/bin; mv gummiboot.efi $out/bin";

  src = fetchurl {
    url = "http://cgit.freedesktop.org/gummiboot/snapshot/${name}.tar.gz";
    sha256 = "1znvbxrhc7pkbhbw9bvg4zhfkp81q7fy4mq2jsw6vimccr7h29a0";
  };

  meta = {
    description = "A simple UEFI boot manager which executes configured EFI images";

    homepage = http://freedesktop.org/wiki/Software/gummiboot;

    license = stdenv.lib.licenses.lgpl21Plus;

    platforms = [ "x86_64-linux" ];

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

Fix build on 32-bit Linux

{ stdenv, fetchurl, gnu_efi }:

stdenv.mkDerivation rec {
  name = "gummiboot-16";

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

  buildFlags = [
    "GNU_EFI=${gnu_efi}"
  ] ++ stdenv.lib.optional (stdenv.system == "i686-linux") "ARCH=ia32";

  installPhase = "mkdir -p $out/bin; mv gummiboot.efi $out/bin";

  src = fetchurl {
    url = "http://cgit.freedesktop.org/gummiboot/snapshot/${name}.tar.gz";
    sha256 = "1znvbxrhc7pkbhbw9bvg4zhfkp81q7fy4mq2jsw6vimccr7h29a0";
  };

  meta = {
    description = "A simple UEFI boot manager which executes configured EFI images";

    homepage = http://freedesktop.org/wiki/Software/gummiboot;

    license = stdenv.lib.licenses.lgpl21Plus;

    platforms = [ "x86_64-linux" "i686-linux" ];

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


{ stdenv, fetchurl, zlib, readline }:

let version = "9.3.2"; in

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

  src = fetchurl {
    url = "mirror://postgresql/source/v${version}/${name}.tar.bz2";
    sha256 = "700da51a71857e092f6af1c85fcd86b46d7d5cd2f2ba343cafb1f206c20232d7";
  };

  buildInputs = [ zlib readline ];

  enableParallelBuilding = true;

  makeFlags = [ "world" ];

  patches = [ ./disable-resolve_symlinks.patch ];

  installTargets = [ "install-world" ];

  LC_ALL = "C";

  passthru = {
    inherit readline;
    psqlSchema = "9.3";
  };

  meta = {
    homepage = http://www.postgresql.org/;
    description = "A powerful, open source object-relational database system";
    license = "bsd";
  };
}

Configure postgresql-9.3 with support for the ossp-uuid module

{ stdenv, fetchurl, zlib, readline, libossp_uuid }:

let version = "9.3.2"; in

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

  src = fetchurl {
    url = "mirror://postgresql/source/v${version}/${name}.tar.bz2";
    sha256 = "700da51a71857e092f6af1c85fcd86b46d7d5cd2f2ba343cafb1f206c20232d7";
  };

  buildInputs = [ zlib readline libossp_uuid ];

  enableParallelBuilding = true;

  makeFlags = [ "world" ];

  configureFlags =
    ''
      --with-ossp-uuid
    '';

  patches = [ ./disable-resolve_symlinks.patch ];

  installTargets = [ "install-world" ];

  LC_ALL = "C";

  passthru = {
    inherit readline;
    psqlSchema = "9.3";
  };

  meta = {
    homepage = http://www.postgresql.org/;
    description = "A powerful, open source object-relational database system";
    license = "bsd";
  };
}


{stdenv, fetchurl}:
stdenv.mkDerivation rec {
  name = "gf2x-${version}";
  version = "1.2";

  src = fetchurl {
    # find link to latest version (with file id) here: https://gforge.inria.fr/projects/gf2x/
    url = "https://gforge.inria.fr/frs/download.php/file/36934/gf2x-1.2.tar.gz";
    sha256 = "0d6vh1mxskvv3bxl6byp7gxxw3zzpkldrxnyajhnl05m0gx7yhk1";
  };

  meta = with stdenv.lib; {
    description = ''Routines for fast arithmetic in GF(2)[x]'';
    homepage = http://gf2x.gforge.inria.fr;
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ raskin ];
    platforms = platforms.linux;
  };
}

Mark gf2x as supported on darwin

{stdenv, fetchurl}:
stdenv.mkDerivation rec {
  name = "gf2x-${version}";
  version = "1.2";

  src = fetchurl {
    # find link to latest version (with file id) here: https://gforge.inria.fr/projects/gf2x/
    url = "https://gforge.inria.fr/frs/download.php/file/36934/gf2x-1.2.tar.gz";
    sha256 = "0d6vh1mxskvv3bxl6byp7gxxw3zzpkldrxnyajhnl05m0gx7yhk1";
  };

  meta = with stdenv.lib; {
    description = ''Routines for fast arithmetic in GF(2)[x]'';
    homepage = http://gf2x.gforge.inria.fr;
    license = licenses.gpl2Plus;
    maintainers = with maintainers; [ raskin ];
    platforms = platforms.unix;
  };
}


{ stdenv, fetchFromGitLab, buildGoPackage, ruby }:

buildGoPackage rec {
  pname = "gitlab-shell-go";
  version = "11.0.0";
  src = fetchFromGitLab {
    owner = "gitlab-org";
    repo = "gitlab-shell";
    rev = "v${version}";
    sha256 = "1ca4yil8gp1cm7w939irp1x2y907z2mkdqiap8ik8mqp8svv1m44";
  };

  buildInputs = [ ruby ];

  patches = [ ./remove-hardcoded-locations.patch ];

  goPackagePath = "gitlab.com/gitlab-org/gitlab-shell";
  goDeps = ./deps.nix;

  postInstall = ''
    cp -r "$NIX_BUILD_TOP/go/src/$goPackagePath"/bin/* $bin/bin
    cp -r "$NIX_BUILD_TOP/go/src/$goPackagePath"/{support,VERSION} $bin/
  '';

  meta = with stdenv.lib; {
    description = "SSH access and repository management app for GitLab";
    homepage = http://www.gitlab.com/;
    platforms = platforms.linux;
    maintainers = with maintainers; [ fpletz globin talyz ];
    license = licenses.mit;
  };
}

Change name from gitlab-shell-go to gitlab-shell

{ stdenv, fetchFromGitLab, buildGoPackage, ruby }:

buildGoPackage rec {
  pname = "gitlab-shell";
  version = "11.0.0";
  src = fetchFromGitLab {
    owner = "gitlab-org";
    repo = "gitlab-shell";
    rev = "v${version}";
    sha256 = "1ca4yil8gp1cm7w939irp1x2y907z2mkdqiap8ik8mqp8svv1m44";
  };

  buildInputs = [ ruby ];

  patches = [ ./remove-hardcoded-locations.patch ];

  goPackagePath = "gitlab.com/gitlab-org/gitlab-shell";
  goDeps = ./deps.nix;

  postInstall = ''
    cp -r "$NIX_BUILD_TOP/go/src/$goPackagePath"/bin/* $bin/bin
    cp -r "$NIX_BUILD_TOP/go/src/$goPackagePath"/{support,VERSION} $bin/
  '';

  meta = with stdenv.lib; {
    description = "SSH access and repository management app for GitLab";
    homepage = http://www.gitlab.com/;
    platforms = platforms.linux;
    maintainers = with maintainers; [ fpletz globin talyz ];
    license = licenses.mit;
  };
}


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

Update tarsnap to version 1.0.35

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

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

  src = fetchurl {
    url = "https://www.tarsnap.com/download/tarsnap-autoconf-1.0.35.tgz";
    sha256 = "16lc14rwrq84fz95j1g10vv0qki0qw73lzighidj5g23pib6g7vc";
  };

  buildInputs = [ openssl zlib e2fsprogs ];

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


{ stdenv, fetchurl, perl }:
stdenv.mkDerivation rec {
  version = "2.18.1";
  name = "checkbashisms-${version}";

  src = fetchurl {
    url = "mirror://debian/pool/main/d/devscripts/devscripts_${version}.tar.xz";
    sha256 = "1yaygfzv5jzvcbahz6sdfnzhch9mxgsrlsym2ad62nk0svsnp24n";
  };

  buildInputs = [ perl ];

  # The link returns directly the script. No need for unpacking
  unpackPhase = "true";

  installPhase = ''
    install -D -m755 $src $out/bin/checkbashisms
  '';

  meta = {
    homepage = https://sourceforge.net/projects/checkbaskisms/;
    description = "Check shell scripts for non-portable syntax";
    license = stdenv.lib.licenses.gpl2;
    platforms = stdenv.lib.platforms.unix;
  };
}

Revert "checkbashism: 2.0.0.2 -> 2.18.1"

{ stdenv, fetchurl, perl }:
stdenv.mkDerivation rec {
  version = "2.0.0.2";
  name = "checkbashisms-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/project/checkbaskisms/${version}/checkbashisms";
    sha256 = "1vm0yykkg58ja9ianfpm3mgrpah109gj33b41kl0jmmm11zip9jd";
  };

  buildInputs = [ perl ];

  # The link returns directly the script. No need for unpacking
  unpackPhase = "true";

  installPhase = ''
    install -D -m755 $src $out/bin/checkbashisms
  '';

  meta = {
    homepage = https://sourceforge.net/projects/checkbaskisms/;
    description = "Check shell scripts for non-portable syntax";
    license = stdenv.lib.licenses.gpl2;
    platforms = stdenv.lib.platforms.unix;
  };
}


{ fetchgit, stdenv, openssl, pcre }:

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

  src = fetchgit {
    url = "https://github.com/samr7/vanitygen";
    rev = "refs/tags/${version}";
    sha256  = "1vzfv74hhiyrrpvjca8paydx1ashgbgn5plzrx4swyzxy1xkamah";
  };

  buildInputs = [ openssl pcre ];

  installPhase = ''
    ensureDir $out/bin
    cp vanitygen $out/bin
    cp keyconv $out/bin/vanitygen-keyconv
  '';

  meta = {
      description = "Bitcoin vanity address generator";
      longDescription= ''
        Vanitygen can search for exact prefixes or regular expression
        matches, so you can generate Bitcoin addresses that starts
        with the needed mnemonic.

        Vanitygen can generate regular bitcoin addresses, namecoin
        addresses, and testnet addresses.

        When searching for exact prefixes, vanitygen will ensure that
        the prefix is possible, will provide a difficulty estimate,
        and will run about 30% faster.
      '';
      homepage = "https://github.com/samr7/vanitygen";
      license = "AGPLv3";
  };
}

Add platforms meta attribute to vanitygen

{ fetchgit, stdenv, openssl, pcre }:

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

  src = fetchgit {
    url = "https://github.com/samr7/vanitygen";
    rev = "refs/tags/${version}";
    sha256  = "1vzfv74hhiyrrpvjca8paydx1ashgbgn5plzrx4swyzxy1xkamah";
  };

  buildInputs = [ openssl pcre ];

  installPhase = ''
    ensureDir $out/bin
    cp vanitygen $out/bin
    cp keyconv $out/bin/vanitygen-keyconv
  '';

  meta = {
      description = "Bitcoin vanity address generator";
      longDescription= ''
        Vanitygen can search for exact prefixes or regular expression
        matches, so you can generate Bitcoin addresses that starts
        with the needed mnemonic.

        Vanitygen can generate regular bitcoin addresses, namecoin
        addresses, and testnet addresses.

        When searching for exact prefixes, vanitygen will ensure that
        the prefix is possible, will provide a difficulty estimate,
        and will run about 30% faster.
      '';
      homepage = "https://github.com/samr7/vanitygen";
      license = "AGPLv3";
      platforms = stdenv.lib.platforms.all;
  };
}


{ stdenv, fetchurl, flex, bison, sendmailPath ? "/var/setuid-wrappers/sendmail" }:

stdenv.mkDerivation rec {
  name = "petidomo-4.2";

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

  buildInputs = [ flex bison ];

  configureFlags = "--with-mta=${sendmailPath}";

  enableParallelBuilding = true;

  doCheck = true;

  meta = {
    homepage = "http://petidomo.sourceforge.net/";
    description = "a simple and easy to administer mailing list server";
    license = stdenv.lib.licenses.gpl3plus;

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

Fix petidomo license meta attribute

{ stdenv, fetchurl, flex, bison, sendmailPath ? "/var/setuid-wrappers/sendmail" }:

stdenv.mkDerivation rec {
  name = "petidomo-4.2";

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

  buildInputs = [ flex bison ];

  configureFlags = "--with-mta=${sendmailPath}";

  enableParallelBuilding = true;

  doCheck = true;

  meta = {
    homepage = "http://petidomo.sourceforge.net/";
    description = "a simple and easy to administer mailing list server";
    license = stdenv.lib.licenses.gpl3Plus;

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


{ stdenv, buildPythonPackage, fetchPypi, urllib3, certifi, django, flask, tornado, sanic, aiohttp, bottle, rq, falcon, pyramid, celery }:

buildPythonPackage rec {
  pname = "sentry-sdk";
  version = "0.8.1";

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

  checkInputs = [ django flask tornado sanic aiohttp bottle rq falcon pyramid celery ];

  propagatedBuildInputs = [ urllib3 certifi ];

  meta = with stdenv.lib; {
    homepage = "https://github.com/getsentry/sentry-python";
    description = "New Python SDK for Sentry.io";
    license = licenses.bsd2;
    maintainers = with maintainers; [ gebner ];
  };
}

Remove unnecessary `sentry-sdk` dependencies causing problems in python27 builds

{ stdenv, buildPythonPackage, fetchPypi, isPy3k, urllib3, certifi, django, flask, tornado, bottle, rq, falcon, celery, pyramid, sanic, aiohttp }:

buildPythonPackage rec {
  pname = "sentry-sdk";
  version = "0.8.1";

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

  checkInputs = [ django flask tornado bottle rq falcon ]
  ++ stdenv.lib.optionals isPy3k [ celery pyramid sanic aiohttp ];

  propagatedBuildInputs = [ urllib3 certifi ];

  meta = with stdenv.lib; {
    homepage = "https://github.com/getsentry/sentry-python";
    description = "New Python SDK for Sentry.io";
    license = licenses.bsd2;
    maintainers = with maintainers; [ gebner ];
  };
}


# This file was generated by go2nix.
{ stdenv, lib, pkgconfig, goPackages, fetchFromGitHub }:

with goPackages;

buildGoPackage rec {
  name = "ngrok-${version}";
  version = "1.7.1";
  rev = "${version}";

  goPackagePath = "ngrok";

  src = fetchFromGitHub {
    inherit rev;
    owner = "inconshreveable";
    repo = "ngrok";
    sha256 = "1r4nc9knp0nxg4vglg7v7jbyd1nh1j2590l720ahll8a4fbsx5a4";
  };

  goDeps = ./deps.json;

  buildInputs = [ go-bindata ];

  preConfigure = ''
    sed -e '/jteeuwen\/go-bindata/d' \
        -e '/export GOPATH/d' \
        -e 's/go get/#go get/' \
        -e 's|bin/go-bindata|go-bindata|' -i Makefile
    make assets BUILDTAGS=release
    export sourceRoot=$sourceRoot/src/ngrok
  '';

  buildFlags = [ "-tags release" ];
}

FIX go-bindata moved to all-packages

# This file was generated by go2nix.
{ stdenv, lib, pkgconfig, goPackages, go-bindata, fetchFromGitHub }:

with goPackages;

buildGoPackage rec {
  name = "ngrok-${version}";
  version = "1.7.1";
  rev = "${version}";

  goPackagePath = "ngrok";

  src = fetchFromGitHub {
    inherit rev;
    owner = "inconshreveable";
    repo = "ngrok";
    sha256 = "1r4nc9knp0nxg4vglg7v7jbyd1nh1j2590l720ahll8a4fbsx5a4";
  };

  goDeps = ./deps.json;

  buildInputs = [ go-bindata ];

  preConfigure = ''
    sed -e '/jteeuwen\/go-bindata/d' \
        -e '/export GOPATH/d' \
        -e 's/go get/#go get/' \
        -e 's|bin/go-bindata|go-bindata|' -i Makefile
    make assets BUILDTAGS=release
    export sourceRoot=$sourceRoot/src/ngrok
  '';

  buildFlags = [ "-tags release" ];
}


{ lib, buildPythonPackage, fetchPypi
, matplotlib
, traitlets

# tests
, ipython
}:

buildPythonPackage rec {
  pname = "matplotlib-inline";
  version = "0.1.3";

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

  propagatedBuildInputs = [
    matplotlib # not documented, but required
    traitlets
  ];

  # wants to import ipython, which creates a circular dependency
  doCheck = false;
  pythonImportsCheck = [ "matplotlib_inline" ];

  passthru.tests = { inherit ipython; };

  meta = with lib; {
    description = "Matplotlib Inline Back-end for IPython and Jupyter";
    homepage = "https://github.com/ipython/matplotlib-inline";
    license = licenses.bsd3;
    maintainers = with maintainers; [ jonringer ];
  };
}

Revert "Revert "matplotlib-inline: Don't depend on matplotlib -> smaller ipython closure""

{ lib, buildPythonPackage, fetchPypi
, traitlets

# tests
, ipython
}:

buildPythonPackage rec {
  pname = "matplotlib-inline";
  version = "0.1.3";

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

  propagatedBuildInputs = [
    traitlets
  ];

  # wants to import ipython, which creates a circular dependency
  doCheck = false;
  pythonImportsCheck = [ "matplotlib_inline" ];

  passthru.tests = { inherit ipython; };

  meta = with lib; {
    description = "Matplotlib Inline Back-end for IPython and Jupyter";
    homepage = "https://github.com/ipython/matplotlib-inline";
    license = licenses.bsd3;
    maintainers = with maintainers; [ jonringer ];
  };
}


{ fetchurl, stdenv, emacs }:

stdenv.mkDerivation {
  name = "quack-0.30";

  src = fetchurl {
    # XXX: Upstream URL is not versioned, which might eventually break this.
    url = "http://www.neilvandyke.org/quack/quack.el";
    sha256 = "1j68azxbc54hdk3cw9q95qpz99wgj9xxgrzzwmydxh3zafy5faqs";
  };

  buildInputs = [ emacs ];

  builder = ./builder.sh;

  meta = {
    description = ''Quack: Enhanced Emacs Support for Editing and
                    Running Scheme Code'';
    homepage = http://www.neilvandyke.org/quack/;
    license = "GPLv2+";
  };
}

Update hash to the current version.

{ fetchurl, stdenv, emacs }:

stdenv.mkDerivation {
  name = "quack-0.30";

  src = fetchurl {
    # XXX: Upstream URL is not versioned, which might eventually break this.
    url = "http://www.neilvandyke.org/quack/quack.el";
    sha256 = "1xmpbdb064s3l3cv4agf03ir1g7xfzyvlqayr3yy5f8z3i6pf7mi";
  };

  buildInputs = [ emacs ];

  builder = ./builder.sh;

  meta = {
    description = ''Quack: Enhanced Emacs Support for Editing and
                    Running Scheme Code'';
    homepage = http://www.neilvandyke.org/quack/;
    license = "GPLv2+";
  };
}


{ pkgs, nix, nixpkgs, config, lib, ... }:
{
  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "skypeforlinux"
    "slack"
    "spotify"
    "spotify-unwrapped"
    "vscode"
    "vscode-with-extensions"
    "zoom"
    "1password"
  ];

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

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

  programs.zsh.enable = true;

  system.stateVersion = 4;
  users = {
    users.sebastian = {
      home = /Users/sebastian;
    };
  };

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

Set up remote (linux) build host on macbook using docker

{ pkgs, nix, nixpkgs, config, lib, ... }:
{
  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "skypeforlinux"
    "slack"
    "spotify"
    "spotify-unwrapped"
    "vscode"
    "vscode-with-extensions"
    "zoom"
    "1password"
  ];

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

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

  programs.zsh.enable = true;

  system.stateVersion = 4;
  users = {
    users.sebastian = {
      home = /Users/sebastian;
    };
  };

  nix = {
    package = pkgs.nixUnstable;
    extraOptions = ''
      experimental-features = nix-command flakes
    '';
    distributedBuilds = true;
    buildMachines = [ {
      hostName = "nix-docker";
      sshUser = "root";
      sshKey = "/etc/nix/docker_rsa";
      systems = [ "x86_64-linux" ];
      maxJobs = 2;
    } ];
  };
  services.nix-daemon.enable = true;
}


{stdenv, fetchurl, unzip, autoconf, automake, makeWrapper, pkgconfig
, gnome3, avahi, gtk3, libnotify, pulseaudio, x11}:

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

  src = fetchurl {
    url = "https://github.com/christophgysin/pasystray/archive/${name}.zip";
    sha256 = "0n41qm04kilhc827yx8y1ijslmajg2dxykaf3s3aq6s6bjzzw8bh";
  };

  buildInputs = [ unzip autoconf automake makeWrapper pkgconfig
                  gnome3.defaultIconTheme
                  avahi gtk3 libnotify pulseaudio x11 ];

  preConfigure = ''
    aclocal
    autoconf
    autoheader
    automake --add-missing
  '';

  preFixup = ''
    wrapProgram "$out/bin/pasystray" \
      --prefix XDG_DATA_DIRS : "${gnome3.defaultIconTheme}/share:$GSETTINGS_SCHEMAS_PATH"
  '';

  meta = with stdenv.lib; {
    description = "PulseAudio system tray";
    homepage = "https://github.com/christophgysin/pasystray";
    license = licenses.lgpl21Plus;
    maintainers = [ maintainers.exlevan ];
    platfoms = platforms.linux;
  };
}

Update pasystray to current version.

{stdenv, fetchurl, unzip, autoconf, automake, makeWrapper, pkgconfig
, gnome3, avahi, gtk3, libnotify, pulseaudio, x11}:

stdenv.mkDerivation rec {
  name = "pasystray-0.5.2";

  src = fetchurl {
    url = "https://github.com/christophgysin/pasystray/archive/${name}.zip";
    sha256 = "084jld5zk89h4akll73bwhfav6mpg55zmdd5kvlg396rqi9lqkj4";
  };

  buildInputs = [ unzip autoconf automake makeWrapper pkgconfig
                  gnome3.defaultIconTheme
                  avahi gtk3 libnotify pulseaudio x11 ];

  preConfigure = ''
    aclocal
    autoconf
    autoheader
    automake --add-missing
  '';

  preFixup = ''
    wrapProgram "$out/bin/pasystray" \
      --prefix XDG_DATA_DIRS : "${gnome3.defaultIconTheme}/share:$GSETTINGS_SCHEMAS_PATH"
  '';

  meta = with stdenv.lib; {
    description = "PulseAudio system tray";
    homepage = "https://github.com/christophgysin/pasystray";
    license = licenses.lgpl21Plus;
    maintainers = [ maintainers.exlevan ];
    platfoms = platforms.linux;
  };
}


{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "axel-2.4";
  src = fetchurl {
    url = https://alioth.debian.org/frs/download.php/3016/axel-2.4.tar.bz2;
    sha256 = "ebc7d40e989c680d2afa632a17e5208101608924cf446da20814a6f3c3338612";
  };

  meta = {
    description = "Console downloading program with some features for parallel connections for faster downloading";
  };
}

Switch Axel to a publically accessible download source

{stdenv, fetchurl}:

stdenv.mkDerivation {
  name = "axel-2.4";
  src = fetchurl {
    urls = [
      #https://alioth.debian.org/frs/download.php/3016/axel-2.4.tar.bz2
      mirror://debian/pool/main/a/axel/axel_2.4.orig.tar.gz
    ];
    sha256 = "0dl0r9byd2ps90cq2nj1y7ib6gnkb5y9f3a3fmhcnjrm9smmg6im";
  };

  meta = {
    description = "Console downloading program with some features for parallel connections for faster downloading";
  };
}


{ stdenv
, buildPythonPackage
, fetchPypi
, lib
, python
, serpent
, dill
, cloudpickle
, msgpack
, isPy27
, selectors34
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "Pyro4";
  version = "4.80";

  src = fetchPypi {
    inherit pname version;
    sha256 = "46847ca703de3f483fbd0b2d22622f36eff03e6ef7ec7704d4ecaa3964cb2220";
  };

  propagatedBuildInputs = [
    serpent
  ] ++ lib.optionals isPy27 [ selectors34 ];

  buildInputs = [
    dill
    cloudpickle
    msgpack
  ];

  checkInputs = [ pytestCheckHook ];

  # add testsupport.py to PATH
  preCheck = "PYTHONPATH=tests/PyroTests:$PYTHONPATH";

  # ignore network related tests, which fail in sandbox
  pytestFlagsArray = [ "--ignore=tests/PyroTests/test_naming.py" ]
    # test hangs on darwin with sandbox enabled
    ++ lib.optionals stdenv.isDarwin [ "--ignore=tests/PyroTests/test_daemon.py" ];

  disabledTests = [
    "StartNSfunc"
    "Broadcast"
    "GetIP"
  ];

  meta = with stdenv.lib; {
    description = "Distributed object middleware for Python (RPC)";
    homepage = "https://github.com/irmen/Pyro4";
    license = licenses.mit;
    maintainers = with maintainers; [ prusnak ];
  };
}

Fix hanging tests on darwin

{ stdenv
, buildPythonPackage
, fetchPypi
, lib
, python
, serpent
, dill
, cloudpickle
, msgpack
, isPy27
, selectors34
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "Pyro4";
  version = "4.80";

  src = fetchPypi {
    inherit pname version;
    sha256 = "46847ca703de3f483fbd0b2d22622f36eff03e6ef7ec7704d4ecaa3964cb2220";
  };

  propagatedBuildInputs = [
    serpent
  ] ++ lib.optionals isPy27 [ selectors34 ];

  buildInputs = [
    dill
    cloudpickle
    msgpack
  ];

  checkInputs = [ pytestCheckHook ];

  # add testsupport.py to PATH
  preCheck = "PYTHONPATH=tests/PyroTests:$PYTHONPATH";

  # ignore network related tests, which fail in sandbox
  pytestFlagsArray = [ "--ignore=tests/PyroTests/test_naming.py" ];

  disabledTests = [
    "StartNSfunc"
    "Broadcast"
    "GetIP"
  ];

  # otherwise the tests hang the build
  __darwinAllowLocalNetworking = true;

  meta = with stdenv.lib; {
    description = "Distributed object middleware for Python (RPC)";
    homepage = "https://github.com/irmen/Pyro4";
    license = licenses.mit;
    maintainers = with maintainers; [ prusnak ];
  };
}


{ stdenv, fetchFromGitHub, gtk }:

stdenv.mkDerivation rec {
  version = "6a5f14cfe697b0a829456a1fd560acdcddc6043f";
  name = "paper-gtk-theme-${version}";

  src = fetchFromGitHub {
    owner = "snwh";
    repo = "paper-gtk-theme";
    sha256 = "0kyn3a6sq0z22vds6szl630jv20pjskjbdg0wc8abxzwg0vwxc5m";
    rev = version;
  };

  dontBuild = true;
  installPhase = ''
    mkdir -p $out/share/themes/Paper/
    cp -r ./Paper/ $out/share/themes/
  '';

  preferLocalBuild = true;

  meta = with stdenv.lib; {
    description = "Paper is a modern desktop theme suite. Its design is mostly flat with a minimal use of shadows for depth.";
    homepage = "http://snwh.org/paper/";
    license = licenses.gpl3;
    maintainers = [ maintainers.simonvandel ];
    platforms = platforms.linux;
  };
}

Make description conform to nixos standards

{ stdenv, fetchFromGitHub, gtk }:

stdenv.mkDerivation rec {
  version = "6a5f14cfe697b0a829456a1fd560acdcddc6043f";
  name = "paper-gtk-theme-${version}";

  src = fetchFromGitHub {
    owner = "snwh";
    repo = "paper-gtk-theme";
    sha256 = "0kyn3a6sq0z22vds6szl630jv20pjskjbdg0wc8abxzwg0vwxc5m";
    rev = version;
  };

  dontBuild = true;
  installPhase = ''
    mkdir -p $out/share/themes/Paper/
    cp -r ./Paper/ $out/share/themes/
  '';

  preferLocalBuild = true;

  meta = with stdenv.lib; {
    description = "A modern desktop theme suite featuring a mostly flat with a minimal use of shadows for depth";
    homepage = "http://snwh.org/paper/";
    license = licenses.gpl3;
    maintainers = [ maintainers.simonvandel ];
    platforms = platforms.linux;
  };
}


{ lib }:
let
  inherit (lib.systems) parse;
  inherit (lib.systems.inspect) patterns;

in rec {
  all     = [ {} ]; # `{}` matches anything
  none    = [];

  arm     = [ patterns.isAarch32 ];
  aarch64 = [ patterns.isAarch64 ];
  x86     = [ patterns.isx86 ];
  i686    = [ patterns.isi686 ];
  x86_64  = [ patterns.isx86_64 ];
  mips    = [ patterns.isMips ];
  riscv   = [ patterns.isRiscV ];

  cygwin  = [ patterns.isCygwin ];
  darwin  = [ patterns.isDarwin ];
  freebsd = [ patterns.isFreeBSD ];
  # Should be better, but MinGW is unclear, and HURD is bit-rotted.
  gnu     = [ { kernel = parse.kernels.linux; abi = parse.abis.gnu; } ];
  illumos = [ patterns.isSunOS ];
  linux   = [ patterns.isLinux ];
  netbsd  = [ patterns.isNetBSD ];
  openbsd = [ patterns.isOpenBSD ];
  unix    = patterns.isUnix; # Actually a list
  windows = [ patterns.isWindows ];

  inherit (lib.systems.doubles) mesaPlatforms;
}

Fix `nix-env -qaP -f . --xml --meta`

{ lib }:
let
  inherit (lib.systems) parse;
  inherit (lib.systems.inspect) patterns;

  abis = lib.mapAttrs (_: abi: builtins.removeAttrs abi [ "assertions" ]) parse.abis;

in rec {
  all     = [ {} ]; # `{}` matches anything
  none    = [];

  arm     = [ patterns.isAarch32 ];
  aarch64 = [ patterns.isAarch64 ];
  x86     = [ patterns.isx86 ];
  i686    = [ patterns.isi686 ];
  x86_64  = [ patterns.isx86_64 ];
  mips    = [ patterns.isMips ];
  riscv   = [ patterns.isRiscV ];

  cygwin  = [ patterns.isCygwin ];
  darwin  = [ patterns.isDarwin ];
  freebsd = [ patterns.isFreeBSD ];
  # Should be better, but MinGW is unclear, and HURD is bit-rotted.
  gnu     = [ { kernel = parse.kernels.linux; abi = abis.gnu; } ];
  illumos = [ patterns.isSunOS ];
  linux   = [ patterns.isLinux ];
  netbsd  = [ patterns.isNetBSD ];
  openbsd = [ patterns.isOpenBSD ];
  unix    = patterns.isUnix; # Actually a list
  windows = [ patterns.isWindows ];

  inherit (lib.systems.doubles) mesaPlatforms;
}


let pkgs = import <nixpkgs> {};

in pkgs.stdenv.mkDerivation rec {
  name = "vinylwhere";

  buildInputs = with pkgs; [
    awscli
    caddy
    fish
    jq
    nodejs-9_x
    pup
  ];
}

Upgrade NodeJS version to 10.x

let pkgs = import <nixpkgs> {};

in pkgs.stdenv.mkDerivation rec {
  name = "vinylwhere";

  buildInputs = with pkgs; [
    awscli
    caddy
    fish
    jq
    nodejs-10_x
    pup
  ];
}


{ lib
, buildPythonPackage
, fetchPypi
, pkgs
, argcomplete
, pyyaml
, xmltodict
# Test inputs
, coverage
, flake8
, jq
, pytest
, unixtools
, toml
}:

buildPythonPackage rec {
  pname = "yq";
  version = "2.11.1";

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

  propagatedBuildInputs = [
    pyyaml
    xmltodict
    argcomplete
  ];

  doCheck = true;

  checkInputs = [
   unixtools.script
   pytest
   coverage
   flake8
   pkgs.jq
   toml
  ];

  # tests fails if stdin is not a tty
  checkPhase = "echo | script -c 'pytest ./test/test.py'";

  pythonImportsCheck = [ "yq" ];

  meta = with lib; {
    description = "Command-line YAML processor - jq wrapper for YAML documents.";
    homepage = "https://github.com/kislyuk/yq";
    license = [ licenses.asl20 ];
    maintainers = [ maintainers.womfoo ];
  };
}

Revert "python3.pkgs.yq: make stdin a tty for tests"

{ lib
, buildPythonPackage
, fetchPypi
, pkgs
, argcomplete
, pyyaml
, xmltodict
# Test inputs
, coverage
, flake8
, jq
, pytest
, toml
}:

buildPythonPackage rec {
  pname = "yq";
  version = "2.11.1";

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

  postPatch = ''
    substituteInPlace test/test.py --replace "expect_exit_codes={0} if sys.stdin.isatty() else {2}" "expect_exit_codes={0}"
  '';

  propagatedBuildInputs = [
    pyyaml
    xmltodict
    argcomplete
  ];

  doCheck = true;

  checkInputs = [
   pytest
   coverage
   flake8
   pkgs.jq
   toml
  ];

  checkPhase = "pytest ./test/test.py";

  pythonImportsCheck = [ "yq" ];

  meta = with lib; {
    description = "Command-line YAML processor - jq wrapper for YAML documents.";
    homepage = "https://github.com/kislyuk/yq";
    license = [ licenses.asl20 ];
    maintainers = [ maintainers.womfoo ];
  };
}


{ stdenv, fetchurl, perlPackages, makeWrapper }:

perlPackages.buildPerlPackage {
  pname = "File-Rename";
  version = "0.20";

  src = fetchurl {
    url = "mirror://cpan/authors/id/R/RM/RMBARKER/File-Rename-0.20.tar.gz";
    sha256 = "1cf6xx2hiy1xalp35fh8g73j67r0w0g66jpcbc6971x9jbm7bvjy";
  };

  nativeBuildInputs = [ makeWrapper ];

  postInstall = ''
    wrapProgram $out/bin/rename \
      --prefix PERL5LIB : $out/${perlPackages.perl.libPrefix}
  '';

  doCheck = !stdenv.isDarwin;

  meta = with stdenv.lib; {
    description = "Perl extension for renaming multiple files";
    license = licenses.artistic1;
    maintainers = with maintainers; [ peterhoeg ];
  };
}

Fix an incorrect platform test that misidentifies Darwin as Windows

{ stdenv, fetchurl, perlPackages, makeWrapper }:

perlPackages.buildPerlPackage {
  pname = "File-Rename";
  version = "0.20";

  src = fetchurl {
    url = "mirror://cpan/authors/id/R/RM/RMBARKER/File-Rename-0.20.tar.gz";
    sha256 = "1cf6xx2hiy1xalp35fh8g73j67r0w0g66jpcbc6971x9jbm7bvjy";
  };

  nativeBuildInputs = [ makeWrapper ];

  # Fix an incorrect platform test that misidentifies Darwin as Windows
  postPatch = ''
    substituteInPlace Makefile.PL \
      --replace '/win/i' '/MSWin32/'
  '';

  postInstall = ''
    wrapProgram $out/bin/rename \
      --prefix PERL5LIB : $out/${perlPackages.perl.libPrefix}
  '';

  doCheck = !stdenv.isDarwin;

  meta = with stdenv.lib; {
    description = "Perl extension for renaming multiple files";
    license = licenses.artistic1;
    maintainers = with maintainers; [ peterhoeg ];
  };
}


{ lib }:

self: super: {
  haskell = super.haskell // {
    compiler = super.haskell.compiler // lib.mapAttrs (n: v: v.overrideAttrs (drv: {
      patches = (drv.patches or []) ++ lib.optionals self.stdenv.targetPlatform.useAndroidPrebuilt [
        ./8.6.y/android-patches/force-relocation.patch
      ];
    })) { inherit (super.haskell.compiler) ghc865 ghcSplices; };
  };
  libffi = if self.stdenv.targetPlatform.useAndroidPrebuilt
    then
      super.libffi.overrideAttrs (drv: {
        name = "libffi-3.3-rc0";
        patches = [];
        src = builtins.fetchurl {
          url = "https://github.com/libffi/libffi/releases/download/v3.3-rc0/libffi-3.3-rc0.tar.gz";
          sha256 = "1kqfyar1xaxrylrw7j1nclqvcgr6a2cisazaamw1a18wpym6fga0";
        };
        postFixup = "";
      })
    else
      super.libffi;
}

Add explanation for libffi override

{ lib }:

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


{ stdenv, sbt, z3, jdk }:

stdenv.mkDerivation rec {
  name = "cuanto-${version}";
  version = "dev";
  src = ./.;
  buildInputs = [ sbt z3 (jdk.override {minimal = true;}) ];
}

Set minimal jdk if on Linux

{ stdenv, sbt, z3, jdk }:

# If we're using Linux openjdk, there is an option that removes lots
# of unneeded extra dependencies.
let jdk' =
      if stdenv.isDarwin
      then jdk
      else jdk.override {minimal = true;};

in

stdenv.mkDerivation rec {
  name = "cuanto-${version}";
  version = "dev";
  src = ./.;
  buildInputs = [ sbt z3 jdk ];
}


{ stdenv, fetchurl }:

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

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

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

Allow to specify checksum hash library.

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

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

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

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

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

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

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


{ stdenv, fetchFromGitHub, libpcap }:

let version = "1.3.6";
in stdenv.mkDerivation {
  name = "xl2tpd-${version}";

  src = fetchFromGitHub {
    owner = "xelerance";
    repo = "xl2tpd";
    rev = "v${version}";
    sha256 = "17lnsk9fsyfp2g5hha7psim6047wj9qs8x4y4w06gl6bbf36jm9z";
  };

  buildInputs = [ libpcap ];

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

  meta = with stdenv.lib; {
    homepage = http://www.xelerance.com/software/xl2tpd/;
    description = "Layer 2 Tunnelling Protocol Daemon (RFC 2661)";
    platforms = platforms.linux;
    license = licenses.gpl2;
    maintainers = with maintainers; [ abbradar ];
  };
}

Add ability to use pppd to xl2tpd

{ stdenv, fetchFromGitHub, libpcap, ppp }:

let version = "1.3.6";
in stdenv.mkDerivation {
  name = "xl2tpd-${version}";

  src = fetchFromGitHub {
    owner = "xelerance";
    repo = "xl2tpd";
    rev = "v${version}";
    sha256 = "17lnsk9fsyfp2g5hha7psim6047wj9qs8x4y4w06gl6bbf36jm9z";
  };

  buildInputs = [ libpcap ];

  postPatch = ''
    substituteInPlace l2tp.h --replace /usr/sbin/pppd ${ppp}/sbin/pppd
  '';

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

  meta = with stdenv.lib; {
    homepage = http://www.xelerance.com/software/xl2tpd/;
    description = "Layer 2 Tunnelling Protocol Daemon (RFC 2661)";
    platforms = platforms.linux;
    license = licenses.gpl2;
    maintainers = with maintainers; [ abbradar ];
  };
}


{ lib, stdenv
, fetchFromGitHub
, nix-update-script
, fetchpatch
, pantheon
, meson
, ninja
, pkg-config
, vala
, libgee
, granite
, gtk3
, cups
, switchboard
}:

stdenv.mkDerivation rec {
  pname = "switchboard-plug-printers";
  version = "2.1.9";

  src = fetchFromGitHub {
    owner = "elementary";
    repo = pname;
    rev = version;
    sha256 = "sha256-tnAJyyPN/Xy1pmlgBpgO2Eb5CeHrRltjQTHmuTPBt8s=";
  };

  passthru = {
    updateScript = nix-update-script {
      attrPath = "pantheon.${pname}";
    };
  };

  nativeBuildInputs = [
    meson
    ninja
    pkg-config
    vala
  ];

  buildInputs = [
    cups
    granite
    gtk3
    libgee
    switchboard
  ];

  meta = with lib; {
    description = "Switchboard Printers Plug";
    homepage = "https://github.com/elementary/switchboard-plug-printers";
    license = licenses.lgpl3Plus;
    platforms = platforms.linux;
    maintainers = pantheon.maintainers;
  };

}

Fix build with latest Vala

{ lib, stdenv
, fetchFromGitHub
, nix-update-script
, fetchpatch
, pantheon
, meson
, ninja
, pkg-config
, vala
, libgee
, granite
, gtk3
, cups
, switchboard
}:

stdenv.mkDerivation rec {
  pname = "switchboard-plug-printers";
  version = "2.1.9";

  src = fetchFromGitHub {
    owner = "elementary";
    repo = pname;
    rev = version;
    sha256 = "sha256-tnAJyyPN/Xy1pmlgBpgO2Eb5CeHrRltjQTHmuTPBt8s=";
  };

  patches = [
    # Fix build with latest Vala.
    (fetchpatch {
      url = "https://github.com/elementary/switchboard-plug-printers/commit/5eced5ddda6f229d7265ea0a713f6c1cd181a526.patch";
      sha256 = "lPTNqka6jjvv1JnAqVzVIQBIdDXlCOQ5ASvgZNuEUC8=";
    })
  ];

  passthru = {
    updateScript = nix-update-script {
      attrPath = "pantheon.${pname}";
    };
  };

  nativeBuildInputs = [
    meson
    ninja
    pkg-config
    vala
  ];

  buildInputs = [
    cups
    granite
    gtk3
    libgee
    switchboard
  ];

  meta = with lib; {
    description = "Switchboard Printers Plug";
    homepage = "https://github.com/elementary/switchboard-plug-printers";
    license = licenses.lgpl3Plus;
    platforms = platforms.linux;
    maintainers = pantheon.maintainers;
  };

}


{ stdenv, fetchurl, cmake, boost, gmp, mpfr }:

stdenv.mkDerivation rec {
  version = "4.3";

  name = "cgal-${version}";

  src = fetchurl {
    url = "https://gforge.inria.fr/frs/download.php/32995/CGAL-${version}.tar.xz";
    sha256 = "015vw57dmy43bf63mg3916cgcsbv9dahwv24bnmiajyanj2mhiyc";
  };

  buildInputs = [ cmake boost gmp mpfr ];

  doCheck = false;

  meta = with stdenv.lib; {
    description = "Computational Geometry Algorithms Library";
    homepage = "http://cgal.org/";
    license = licenses.gpl3Plus; # some parts are GPLv3+, some are LGPLv3+
    platforms = platforms.linux;
    maintainers = [ maintainers.raskin ];
  };
}

Update CGAL; NB: updating requires going through a formto get the fresh links

{ stdenv, fetchurl, cmake, boost, gmp, mpfr }:

stdenv.mkDerivation rec {
  version = "4.4";

  name = "cgal-${version}";

  src = fetchurl {
    url = "https://gforge.inria.fr/frs/download.php/33526/CGAL-${version}.tar.xz";
    sha256 = "1s0ylyrx74vgw6vsg6xxk4b07jrxh8pqcmxcbkx46v01nczv3ixj";
  };

  buildInputs = [ cmake boost gmp mpfr ];

  doCheck = false;

  meta = with stdenv.lib; {
    description = "Computational Geometry Algorithms Library";
    homepage = "http://cgal.org/";
    license = licenses.gpl3Plus; # some parts are GPLv3+, some are LGPLv3+
    platforms = platforms.linux;
    maintainers = [ maintainers.raskin ];
  };
}


{ fetchurl, stdenv, openssl, pkgconfig, db, zlib, cyrus_sasl, perl }:

stdenv.mkDerivation rec {
  name = "isync-1.3.1";

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

  nativeBuildInputs = [ pkgconfig perl ];
  buildInputs = [ openssl db cyrus_sasl zlib ];

  meta = with stdenv.lib; {
    homepage = "http://isync.sourceforge.net/";
    description = "Free IMAP and MailDir mailbox synchronizer";
    license = licenses.gpl2Plus;
    platforms = platforms.unix;
  };
}

Add myself (@primeos) as maintainer

{ stdenv, fetchurl, pkg-config, perl
, openssl, db, zlib, cyrus_sasl
}:

stdenv.mkDerivation rec {
  pname = "isync";
  version = "1.3.1";

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

  nativeBuildInputs = [ pkg-config perl ];
  buildInputs = [ openssl db cyrus_sasl zlib ];

  meta = with stdenv.lib; {
    homepage = "http://isync.sourceforge.net/";
    # https://sourceforge.net/projects/isync/
    changelog = "https://sourceforge.net/p/isync/isync/ci/v${version}/tree/NEWS";
    description = "Free IMAP and MailDir mailbox synchronizer";
    longDescription = ''
      mbsync (formerly isync) is a command line application which synchronizes
      mailboxes. Currently Maildir and IMAP4 mailboxes are supported. New
      messages, message deletions and flag changes can be propagated both ways.
    '';
    license = licenses.gpl2Plus;
    platforms = platforms.unix;
    maintainers = with maintainers; [ primeos ];
  };
}


args: with args;
stdenv.mkDerivation {
  name = "wvdial-1.16";

  src = fetchurl {
    url = http://wvstreams.googlecode.com/files/wvdial-1.61.tar.gz;
    sha256 = "0mzcrv8mc60gbdrixc9k8ammbslvjb9x2cs50yf1jq67aabapzsg";
  };

  buildInputs = [wvstreams pkgconfig];

  preConfigure = ''
    find -type f | xargs sed -i 's@/bin/bash@bash@g'
    export makeFlags="prefix=$out"
    # not sure about this line
    sed -i 's@/etc/ppp/peers@$out/etc/ppp/peers@' Makefile.in
  '';

  meta = {
    description = "dialer automatically recognizing the modem";
    homepage = http://alumnit.ca/wiki/index.php?page=WvDial;
    license = "LGPL";
    maintainers = [stdenv.lib.maintainers.marcweber];
    platforms = stdenv.lib.platforms.linux;
  };
}

Fix the wvdial version in 'name'

args: with args;
stdenv.mkDerivation rec {
  name = "wvdial-1.61";

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

  buildInputs = [wvstreams pkgconfig];

  preConfigure = ''
    find -type f | xargs sed -i 's@/bin/bash@bash@g'
    export makeFlags="prefix=$out"
    # not sure about this line
    sed -i 's@/etc/ppp/peers@$out/etc/ppp/peers@' Makefile.in
  '';

  meta = {
    description = "dialer automatically recognizing the modem";
    homepage = http://alumnit.ca/wiki/index.php?page=WvDial;
    license = "LGPL";
    maintainers = [stdenv.lib.maintainers.marcweber];
    platforms = stdenv.lib.platforms.linux;
  };
}


{ stdenv, fetchurl, pkgs, pythonPackages }:

pythonPackages.buildPythonPackage rec {
  version = "0.8.1";
  name = "khard-${version}";
  namePrefix = "";

  src = fetchurl {
    url = "https://github.com/scheibler/khard/archive/v${version}.tar.gz";
    sha256 = "13axfrs96isirx0c483545xdmjwwfq1k7yy92xpk7l184v71rgi1";
  };

  propagatedBuildInputs = with pythonPackages; [
    configobj
    vobject
    argparse
  ];

  buildInputs = with pythonPackages; [
    pkgs.vdirsyncer
    pyyaml
  ];

  meta = {
    homepage = https://github.com/scheibler/khard;
    description = "Console carddav client";
    license = stdenv.lib.licenses.gpl3;
    maintainers = with stdenv.lib.maintainers; [ matthiasbeyer ];
  };
}

Fix version 0.8.1 runtime error by rewriting dependencies

{ stdenv, fetchurl, pkgs, pythonPackages }:

pythonPackages.buildPythonPackage rec {
  version = "0.8.1";
  name = "khard-${version}";
  namePrefix = "";

  src = fetchurl {
    url = "https://github.com/scheibler/khard/archive/v${version}.tar.gz";
    sha256 = "13axfrs96isirx0c483545xdmjwwfq1k7yy92xpk7l184v71rgi1";
  };

  propagatedBuildInputs = with pythonPackages; [
    atomicwrites
    configobj
    vobject
    argparse
    pyyaml
  ];

  buildInputs = with pythonPackages; [
    pkgs.vdirsyncer
  ];

  meta = {
    homepage = https://github.com/scheibler/khard;
    description = "Console carddav client";
    license = stdenv.lib.licenses.gpl3;
    maintainers = with stdenv.lib.maintainers; [ matthiasbeyer ];
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "haveged-${version}";
  version = "1.7c";

  src = fetchurl {
    url = "http://www.issihosts.com/haveged/haveged-${version}.tar.gz";
    sha256 = "08gi3d9lbrllk5lyxw8l65py88xhia48w758lqjddh3gv7g7wfa0";
  };

  meta = {
    description = "A simple entropy daemon";
    longDescription = ''
      The haveged project is an attempt to provide an easy-to-use, unpredictable
      random number generator based upon an adaptation of the HAVEGE algorithm.
      Haveged was created to remedy low-entropy conditions in the Linux random device
      that can occur under some workloads, especially on headless servers. Current development
      of haveged is directed towards improving overall reliablity and adaptability while minimizing
      the barriers to using haveged for other tasks.
    '';
    homepage = http://www.issihosts.com/haveged/;
    license = stdenv.lib.licenses.gpl3;
    maintainers = stdenv.lib.maintainers.iElectric;
    platforms = stdenv.lib.platforms.unix;
  };
}

Update from 1.7c to 1.9.1

{ stdenv, fetchurl }:

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

  src = fetchurl {
    url = "http://www.issihosts.com/haveged/haveged-${version}.tar.gz";
    sha256 = "059pxlfd4l5dqhd6r3lynzfz4wby2f17294fy17pi9j2jpnn68ww";
  };

  meta = {
    description = "A simple entropy daemon";
    longDescription = ''
      The haveged project is an attempt to provide an easy-to-use, unpredictable
      random number generator based upon an adaptation of the HAVEGE algorithm.
      Haveged was created to remedy low-entropy conditions in the Linux random device
      that can occur under some workloads, especially on headless servers. Current development
      of haveged is directed towards improving overall reliablity and adaptability while minimizing
      the barriers to using haveged for other tasks.
    '';
    homepage = http://www.issihosts.com/haveged/;
    license = stdenv.lib.licenses.gpl3;
    maintainers = stdenv.lib.maintainers.iElectric;
    platforms = stdenv.lib.platforms.unix;
  };
}


{ lib
, buildPythonPackage
, fetchPypi
, pytestCheckHook
, google-cloud-core
, google-api-core
, mock
}:

buildPythonPackage rec {
  pname = "google-cloud-resource-manager";
  version = "1.0.2";

  src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-5njC5yO7NTU81i9vmJoe1RBYPS1fU/3K5tgH7twyT+I=";
  };

  propagatedBuildInputs = [ google-api-core google-cloud-core ];

  checkInputs = [ mock pytestCheckHook ];

  # prevent google directory from shadowing google imports
  preCheck = ''
    rm -r google
  '';

  pythonImportsCheck = [ "google.cloud.resource_manager" ];

  meta = with lib; {
    description = "Google Cloud Resource Manager API client library";
    homepage = "https://github.com/googleapis/python-resource-manager";
    license = licenses.asl20;
    maintainers = with maintainers; [ SuperSandro2000 ];
  };
}

Add missing depedencies, fix imports

{ lib
, buildPythonPackage
, fetchPypi
, pytestCheckHook
, google-cloud-core
, google-api-core
, grpc-google-iam-v1
, proto-plus
, mock
}:

buildPythonPackage rec {
  pname = "google-cloud-resource-manager";
  version = "1.0.2";

  src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-5njC5yO7NTU81i9vmJoe1RBYPS1fU/3K5tgH7twyT+I=";
  };

  propagatedBuildInputs = [ google-api-core google-cloud-core grpc-google-iam-v1 proto-plus ];

  checkInputs = [ mock pytestCheckHook ];

  # prevent google directory from shadowing google imports
  preCheck = ''
    rm -r google
  '';

  pythonImportsCheck = [
    "google.cloud.resourcemanager"
    "google.cloud.resourcemanager_v3"
  ];

  meta = with lib; {
    description = "Google Cloud Resource Manager API client library";
    homepage = "https://github.com/googleapis/python-resource-manager";
    license = licenses.asl20;
    maintainers = with maintainers; [ SuperSandro2000 ];
  };
}


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

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

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

  modSha256 = "0z3asz7v1izg81f9xifx9s2sp5hly173hajsn9idi3bkv0h78is2";

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

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

Remove gobject-introspection and put pkgconfig in native

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

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

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

  modSha256 = "0z3asz7v1izg81f9xifx9s2sp5hly173hajsn9idi3bkv0h78is2";

  nativeBuildInputs = [
    pkgconfig
  ];

  buildInputs = [
    pango
    cairo
    gtk2
  ];

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


{stdenv, fetchurl, coq}:

stdenv.mkDerivation rec {

  name = "coq-bedrock-${coq.coq-version}-${version}";
  version = "20140722";

  src = fetchurl {
    url = "http://plv.csail.mit.edu/bedrock/bedrock-${version}.tgz";
    sha256 = "0aaa98q42rsy9hpsxji21bqznizfvf6fplsw6jq42h06j0049k80";
  };

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

  enableParallelBuilding = true;

  buildPhase = ''
    make -j$NIX_BUILD_CORES -C src/reification
    make -j$NIX_BUILD_CORES -C src
  '';

  installPhase = ''
    COQLIB=$out/lib/coq/${coq.coq-version}/
    mkdir -p $COQLIB/user-contrib/Bedrock
    cp -pR src/* $COQLIB/user-contrib/Bedrock
  '';

  meta = with stdenv.lib; {
    homepage = http://plv.csail.mit.edu/bedrock/;
    description = "A library that turns Coq into a tool much like classical verification systems";
    maintainers = with maintainers; [ jwiegley ];
    platforms = coq.meta.platforms;
  };

}

Change build to use "src native"

{stdenv, fetchurl, coq}:

stdenv.mkDerivation rec {

  name = "coq-bedrock-${coq.coq-version}-${version}";
  version = "20140722";

  src = fetchurl {
    url = "http://plv.csail.mit.edu/bedrock/bedrock-${version}.tgz";
    sha256 = "0aaa98q42rsy9hpsxji21bqznizfvf6fplsw6jq42h06j0049k80";
  };

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

  enableParallelBuilding = true;

  buildPhase = ''
    make -j$NIX_BUILD_CORES -C src/reification
    make -j$NIX_BUILD_CORES -C src
    make -j$NIX_BUILD_CORES -C src native
    # make -j$NIX_BUILD_CORES -C platform
    # make -j$NIX_BUILD_CORES -C platform -f Makefile.cito
  '';

  installPhase = ''
    COQLIB=$out/lib/coq/${coq.coq-version}/
    mkdir -p $COQLIB/user-contrib/Bedrock
    cp -pR src/* $COQLIB/user-contrib/Bedrock
  '';

  meta = with stdenv.lib; {
    homepage = http://plv.csail.mit.edu/bedrock/;
    description = "A library that turns Coq into a tool much like classical verification systems";
    maintainers = with maintainers; [ jwiegley ];
    platforms = coq.meta.platforms;
  };

}


{ stdenv, fetchurl }:

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

    src = fetchurl {
        url="http://luajit.org/download/${name}.tar.gz";
        sha256="0f3cykihfdn3gi6na9p0xjd4jnv26z18m441n5vyg42q9abh4ln0";
    };

    patchPhase = ''
      substituteInPlace Makefile \
        --replace ldconfig ${stdenv.glibc}/sbin/ldconfig
    '';

    installPhase = ''
        make install PREFIX=$out
    '';

    meta = {
        description= "Just-in-time compiler and interpreter for lua 5.1.";
        homepage = http://luajit.org;
        license = stdenv.lib.licenses.mit;
    };
}

Fix LuaJIT evaluation on non-Linux platforms

{ stdenv, fetchurl }:

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

    src = fetchurl {
        url="http://luajit.org/download/${name}.tar.gz";
        sha256="0f3cykihfdn3gi6na9p0xjd4jnv26z18m441n5vyg42q9abh4ln0";
    };

    patchPhase = stdenv.lib.optionalString (stdenv.gcc.libc != null)
    ''
      substituteInPlace Makefile \
        --replace ldconfig ${stdenv.gcc.libc}/sbin/ldconfig
    '';

    installPhase = ''
        make install PREFIX=$out
    '';

    meta = {
        description= "Just-in-time compiler and interpreter for lua 5.1.";
        homepage = http://luajit.org;
        license = stdenv.lib.licenses.mit;
	platorms = stdenv.lib.platforms.linux;
    };
}


{stdenv, fetchurl, gperf, flex, bison}:

stdenv.mkDerivation rec {
  name = "verilog-0.9.3";

  src = fetchurl {
    url = "mirror://sourceforce/${name}.tar.gz";
    sha256 = "dd68c8ab874a93805d1e93fa76ee1e91fc0c7b20822ded3e57b6536cd8c0d1ba";
  };

  buildInputs = [ gperf flex bison ];

  meta = {
    description = "Icarus Verilog compiler";
    homepage = http://www.icarus.com;
    license = "GPLv2+";
    maintainers = with stdenv.lib.maintainers; [winden];
    platforms = with stdenv.lib.platforms; linux;
  };
}

Fix for the verilog package, from Antonio Vargas Gonzalez

{stdenv, fetchurl, gperf, flex, bison}:

stdenv.mkDerivation rec {
  name = "verilog-0.9.3";

  src = fetchurl {
    url = "mirror://sourceforge/iverilog/0.9.3/verilog-0.9.3.tar.gz";
    sha256 = "dd68c8ab874a93805d1e93fa76ee1e91fc0c7b20822ded3e57b6536cd8c0d1ba";
  };

  buildInputs = [ gperf flex bison ];

  meta = {
    description = "Icarus Verilog compiler";
    homepage = http://www.icarus.com;
    license = "GPLv2+";
    maintainers = with stdenv.lib.maintainers; [winden];
    platforms = with stdenv.lib.platforms; linux;
  };
}


{ stdenv, fetchurl, openssl, pkgconfig
, withPerl ? false, perl
, withPython ? false, python3
, withTcl ? false, tcl
, withCyrus ? true, cyrus_sasl
}:

with stdenv.lib;
stdenv.mkDerivation rec {
  name = "znc-1.4";

  src = fetchurl {
    url = "http://znc.in/releases/${name}.tar.gz";
    sha256 = "0lkv58pq4d5lzcyx8v8anzinx0sx0zw0js4jij13jb8qxp88zsc6";
  };

  buildInputs = [ openssl pkgconfig ]
    ++ optional withPerl perl
    ++ optional withPython python3
    ++ optional withTcl tcl
    ++ optional withCyrus cyrus_sasl;

  configureFlags = optionalString withPerl "--enable-perl "
    + optionalString withPython "--enable-python "
    + optionalString withTcl "--enable-tcl --with-tcl=${tcl}/lib "
    + optionalString withCyrus "--enable-cyrus ";

  meta = with stdenv.lib; {
    description = "Advanced IRC bouncer";
    homepage = http://wiki.znc.in/ZNC;
    maintainers = with maintainers; [ viric ];
    license = licenses.asl20;
    platforms = platforms.unix;
  };
}

Update znc from 1.4 to 1.6.0

{ stdenv, fetchurl, openssl, pkgconfig
, withPerl ? false, perl
, withPython ? false, python3
, withTcl ? false, tcl
, withCyrus ? true, cyrus_sasl
}:

with stdenv.lib;
stdenv.mkDerivation rec {
  name = "znc-1.6.0";

  src = fetchurl {
    url = "http://znc.in/releases/${name}.tar.gz";
    sha256 = "df622aeae34d26193c738dff6499e56ad669ec654484e19623738d84cc80aba7";
  };

  buildInputs = [ openssl pkgconfig ]
    ++ optional withPerl perl
    ++ optional withPython python3
    ++ optional withTcl tcl
    ++ optional withCyrus cyrus_sasl;

  configureFlags = optionalString withPerl "--enable-perl "
    + optionalString withPython "--enable-python "
    + optionalString withTcl "--enable-tcl --with-tcl=${tcl}/lib "
    + optionalString withCyrus "--enable-cyrus ";

  meta = with stdenv.lib; {
    description = "Advanced IRC bouncer";
    homepage = http://wiki.znc.in/ZNC;
    maintainers = with maintainers; [ viric ];
    license = licenses.asl20;
    platforms = platforms.unix;
  };
}


{ config, pkgs, nixpkgs, lib, ... }:
let
  nixFlakes = (pkgs.writeScriptBin "nixFlakes" ''
      exec ${pkgs.nixUnstable}/bin/nix --experimental-features "nix-command flakes" "$@"
    '');
in {
  imports = [
    ../common.nix
    ../common-linux.nix
  ];

  services.emacs.enable = true;

  programs.zsh.shellAliases.bat = "batcat";

  home.packages = with pkgs; [
    zlib
    dmenu
    autorandr
    arandr
    picom
    espeak
    blink1-tool
    flameshot
    nyxt
    byzanz
    xrectsel
    dunst
    libnotify
    gnome-icon-theme
    _1password
    nixFlakes
    xmonad-with-packages
  ];

  home.file.".xsessionrc".text = ''
    export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$HOME/.local/bin:$PATH
    xset r rate 200 50
    '';

  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "1password"
    "skypeforlinux"
    "slack"
    "spotify"
    "spotify-unwrapped"
    "vscode"
    "vscode-with-extensions"
    "zoom"
    "1password"
  ];
}

Add linux host dependencies sass and esbuild

{ config, pkgs, nixpkgs, lib, ... }:
let
  nixFlakes = (pkgs.writeScriptBin "nixFlakes" ''
      exec ${pkgs.nixUnstable}/bin/nix --experimental-features "nix-command flakes" "$@"
    '');
in {
  imports = [
    ../common.nix
    ../common-linux.nix
  ];

  services.emacs.enable = true;

  programs.zsh.shellAliases.bat = "batcat";

  home.packages = with pkgs; [
    zlib
    dmenu
    autorandr
    arandr
    picom
    espeak
    blink1-tool
    flameshot
    nyxt
    byzanz
    xrectsel
    dunst
    libnotify
    gnome-icon-theme
    _1password
    nixFlakes
    xmonad-with-packages
    sass
    esbuild
  ];

  home.file.".xsessionrc".text = ''
    export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:$HOME/.local/bin:$PATH
    xset r rate 200 50
    '';

  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "1password"
    "skypeforlinux"
    "slack"
    "spotify"
    "spotify-unwrapped"
    "vscode"
    "vscode-with-extensions"
    "zoom"
    "1password"
  ];
}


{ stdenv
, fetchurl
, perl

, cyrus-sasl
, libbson
, openssl
}:

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

  src = fetchurl {
    url = "https://github.com/mongodb/mongo-c-driver/releases/download"
      + "/${version}/${name}.tar.gz";
    sha256 = "f1f725bd13bb58ee31e0b25d7940b84ad132d27383fba439f61b828cbe36feb5";
  };

  nativeBuildInputs = [
    perl
  ];

  buildInputs = [
    cyrus-sasl
    libbson
    openssl
  ];

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

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

Use system libs and move includes to root

{ stdenv
, fetchurl
, perl

, cyrus-sasl
, libbson
, openssl
, snappy
, zlib
}:

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

  src = fetchurl {
    url = "https://github.com/mongodb/mongo-c-driver/releases/download"
      + "/${version}/${name}.tar.gz";
    sha256 = "f1f725bd13bb58ee31e0b25d7940b84ad132d27383fba439f61b828cbe36feb5";
  };

  nativeBuildInputs = [
    perl
  ];

  buildInputs = [
    cyrus-sasl
    libbson
    openssl
    snappy
    zlib
  ];

  configureFlags = [
    "--disable-examples"
    "--disable-tests"
    "--enable-sasl=yes"
    "--enable-ssl=openssl"
    "--enable-crypto-system-profile"
    "--with-libbson=system"
    "--with-snappy=system"
    "--with-zlib=system"
  ];

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

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


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

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

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

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

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

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

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

Add myself as a maintainer

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

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

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

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

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

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

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


{
  description = "glualint - Linter and pretty printer for Garry's Mod's variant of Lua.";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
    let
      pkgs = nixpkgs.legacyPackages.${system};
      haskellPackages = pkgs.haskellPackages;
      staticHaskellPackages = pkgs.pkgsStatic.haskellPackages;
    in {
      packages.glualint = haskellPackages.callPackage ./default.nix {};
      packages.glualint-static = staticHaskellPackages.callPackage ./default.nix {};
      defaultPackage = self.packages.${system}.glualint-static;

      devShell = pkgs.mkShell {
        buildInputs = with haskellPackages; [
          cabal-install
          (ghcWithPackages (self: with self; [
            aeson array base bytestring containers directory filemanip filepath
            ListLike MissingH mtl optparse-applicative parsec pretty signal
            uu-parsinglib uuagc uuagc-cabal deepseq
          ]))
        ];
      };
    }
  );
}

Add HLS to the development environment

{
  description = "glualint - Linter and pretty printer for Garry's Mod's variant of Lua.";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs";
    flake-utils.url = "github:numtide/flake-utils";
  };

  outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system:
    let
      pkgs = nixpkgs.legacyPackages.${system};
      haskellPackages = pkgs.haskellPackages;
      staticHaskellPackages = pkgs.pkgsStatic.haskellPackages;
    in {
      packages.glualint = haskellPackages.callPackage ./default.nix {};
      packages.glualint-static = staticHaskellPackages.callPackage ./default.nix {};
      defaultPackage = self.packages.${system}.glualint-static;

      devShell = pkgs.mkShell {
        buildInputs = with haskellPackages; [
          cabal-install
          (ghcWithPackages (self: with self; [
            aeson array base bytestring containers directory filemanip filepath
            ListLike MissingH mtl optparse-applicative parsec pretty signal
            uu-parsinglib uuagc uuagc-cabal deepseq
          ]))
          haskell-language-server
        ];
      };
    }
  );
}


{ fetchurl, stdenv, zlib, lzo, libgcrypt
, guileBindings, guile }:

assert guileBindings -> guile != null;

stdenv.mkDerivation rec {

  name = "gnutls-2.4.1";

  src = fetchurl {
    url = "mirror://gnu/gnutls/${name}.tar.bz2";
    sha256 = "1zg5ggf8raydr939glq5mwssly84c6czy1hi5gf00wwdhak0256r";
  };

  patches = [ ./tmpdir.patch ];

  configurePhase = ''
    ./configure --prefix="$out" --enable-guile --with-guile-site-dir="$out/share/guile/site"
  '';

  buildInputs = [zlib lzo libgcrypt]
    ++ stdenv.lib.optional guileBindings guile;

  doCheck = true;

  meta = {
    description = "The GNU Transport Layer Security Library";

    longDescription = ''
       GnuTLS is a project that aims to develop a library which
       provides a secure layer, over a reliable transport
       layer. Currently the GnuTLS library implements the proposed
       standards by the IETF's TLS working group.

       Quoting from the TLS protocol specification:

       "The TLS protocol provides communications privacy over the
       Internet. The protocol allows client/server applications to
       communicate in a way that is designed to prevent eavesdropping,
       tampering, or message forgery."
    '';

    homepage = http://www.gnu.org/software/gnutls/;
    license = "LGPLv2.1+";
  };
}

Move libgcrypt to propagatedBuildInputs of gnutls, problems with, say, Pidgin without that.

{ fetchurl, stdenv, zlib, lzo, libgcrypt
, guileBindings, guile }:

assert guileBindings -> guile != null;

stdenv.mkDerivation rec {

  name = "gnutls-2.4.1";

  src = fetchurl {
    url = "mirror://gnu/gnutls/${name}.tar.bz2";
    sha256 = "1zg5ggf8raydr939glq5mwssly84c6czy1hi5gf00wwdhak0256r";
  };

  patches = [ ./tmpdir.patch ];

  configurePhase = ''
    ./configure --prefix="$out" --enable-guile --with-guile-site-dir="$out/share/guile/site"
  '';

  buildInputs = [zlib lzo]
    ++ stdenv.lib.optional guileBindings guile;

  propagatedBuildInputs = [libgcrypt];

  doCheck = true;

  meta = {
    description = "The GNU Transport Layer Security Library";

    longDescription = ''
       GnuTLS is a project that aims to develop a library which
       provides a secure layer, over a reliable transport
       layer. Currently the GnuTLS library implements the proposed
       standards by the IETF's TLS working group.

       Quoting from the TLS protocol specification:

       "The TLS protocol provides communications privacy over the
       Internet. The protocol allows client/server applications to
       communicate in a way that is designed to prevent eavesdropping,
       tampering, or message forgery."
    '';

    homepage = http://www.gnu.org/software/gnutls/;
    license = "LGPLv2.1+";
  };
}


{ lib, buildGoModule, fetchFromGitHub }:

buildGoModule rec {
  pname = "mmake";
  version = "1.4.0";

  src = fetchFromGitHub {
    owner = "tj";
    repo = "mmake";
    rev = "v${version}";
    sha256 = "sha256-JPsVfLIl06PJ8Nsfu7ogwrttB1G93HTKbZFqUTSV9O8=";
  };

  vendorSha256 = "sha256-0z+sujzzBl/rtzXbhL4Os+jYfLUuO9PlXshUDxAH9DU=";

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

  checkFlags = [ "-short" ];

  meta = with lib; {
    homepage = "https://github.com/tj/mmake";
    description = "A small program  which wraps make to provide additional functionality";
    longDescription = ''
      Mmake is a small program  which wraps make to provide additional
      functionality,  such   as  user-friendly  help   output,  remote
      includes,  and   eventually  more.   It  otherwise  acts   as  a
      pass-through to standard make.
    '';
    license = licenses.mit;
    maintainers = [ maintainers.gabesoft ];
  };
}

Disable non-localhost network access tests

{ lib, buildGoModule, fetchFromGitHub }:

buildGoModule rec {
  pname = "mmake";
  version = "1.4.0";

  src = fetchFromGitHub {
    owner = "tj";
    repo = "mmake";
    rev = "v${version}";
    sha256 = "sha256-JPsVfLIl06PJ8Nsfu7ogwrttB1G93HTKbZFqUTSV9O8=";
  };

  vendorSha256 = "sha256-0z+sujzzBl/rtzXbhL4Os+jYfLUuO9PlXshUDxAH9DU=";

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

  # Almost all tests require non-local networking, trying to resolve githubusercontent.com.
  doCheck = false;

  meta = with lib; {
    homepage = "https://github.com/tj/mmake";
    description = "A small program  which wraps make to provide additional functionality";
    longDescription = ''
      Mmake is a small program  which wraps make to provide additional
      functionality,  such   as  user-friendly  help   output,  remote
      includes,  and   eventually  more.   It  otherwise  acts   as  a
      pass-through to standard make.
    '';
    license = licenses.mit;
    maintainers = [ maintainers.gabesoft ];
  };
}


{ config, pkgs, ... }:

{
  programs.git = {
    enable = true;
    userName = "Sebastian Nagel";
    userEmail = "sebastian.nagel@ncoding.at";

    extraConfig = {
      color.ui = true;
      diff.submodule = "log";
      fetch.recurseSubmodules = "on-demand";
      pull.rebase = "preserve";
      push.default = "simple";
      rerere = {
        enabled = true;
        autoupdate = true;
      };
      status.submoduleSummary = true;
    };

    aliases = {
      co = "checkout";
      graph = "log --graph --oneline --decorate";
      changelog = "log --pretty=format:'%s' --no-merges";
      count = "shortlog -sn";
      wtf = "!${./git-wtf}";
      dlm = "!${./git-delete-local-merged}";
      up = "!${./git-up}";
      sup = "!${./git-sup}";
    };

    ignores = [
      "*~"
      "*.swp"
      ".clang_complete"
      "TAGS"
      "dist*/"
    ];
  };

  programs.zsh.shellAliases = {
    gf = "git fetch --prune";
    gl = "git graph";
    gla = "git graph --all";
    gd = "git diff";
    gc = "git commit";
    ga = "git add -p";
    gco = "git checkout";
    gb = "git branch";
    gs = "git status -sb";
  };
}

Fix git deprecation of rebase --preserve-merges

{ config, pkgs, ... }:

{
  programs.git = {
    enable = true;
    userName = "Sebastian Nagel";
    userEmail = "sebastian.nagel@ncoding.at";

    extraConfig = {
      color.ui = true;
      diff.submodule = "log";
      fetch.recurseSubmodules = "on-demand";
      pull.rebase = "merges";
      push.default = "simple";
      rerere = {
        enabled = true;
        autoupdate = true;
      };
      status.submoduleSummary = true;
    };

    aliases = {
      co = "checkout";
      graph = "log --graph --oneline --decorate";
      changelog = "log --pretty=format:'%s' --no-merges";
      count = "shortlog -sn";
      wtf = "!${./git-wtf}";
      dlm = "!${./git-delete-local-merged}";
      up = "!${./git-up}";
      sup = "!${./git-sup}";
    };

    ignores = [
      "*~"
      "*.swp"
      ".clang_complete"
      "TAGS"
      "dist*/"
    ];
  };

  programs.zsh.shellAliases = {
    gf = "git fetch --prune";
    gl = "git graph";
    gla = "git graph --all";
    gd = "git diff";
    gc = "git commit";
    ga = "git add -p";
    gco = "git checkout";
    gb = "git branch";
    gs = "git status -sb";
  };
}


{ stdenv, fetchFromGitHub, pkgconfig, cmake, gtk2, wxGTK30, libpulseaudio, curl,
  gettext, glib, portaudio }:

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

  src = fetchFromGitHub {
    owner = "OpenCPN";
    repo = "OpenCPN";
    rev = "v${version}";
    sha256 = "1z9xfc5fgbdslzak3iqg9nx6wggxwv8qwfxfhvfblkyg6kjw30dg";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ cmake gtk2 wxGTK30 libpulseaudio curl gettext
                  glib portaudio ];

  cmakeFlags = [
    "-DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2.out}/lib/gtk-2.0/include"
    "-DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib.out}/lib/glib-2.0/include"
  ];

  enableParallelBuilding = true;

  meta = {
    description = "A concise ChartPlotter/Navigator";
    maintainers = [ stdenv.lib.maintainers.kragniz ];
    platforms = stdenv.lib.platforms.all;
    license = stdenv.lib.licenses.gpl2;
    homepage = https://opencpn.org/;
  };
}

Set platforms to x86_64-linux exclusively

{ stdenv, fetchFromGitHub, pkgconfig, cmake, gtk2, wxGTK30, libpulseaudio, curl,
  gettext, glib, portaudio }:

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

  src = fetchFromGitHub {
    owner = "OpenCPN";
    repo = "OpenCPN";
    rev = "v${version}";
    sha256 = "1z9xfc5fgbdslzak3iqg9nx6wggxwv8qwfxfhvfblkyg6kjw30dg";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ cmake gtk2 wxGTK30 libpulseaudio curl gettext
                  glib portaudio ];

  cmakeFlags = [
    "-DGTK2_GDKCONFIG_INCLUDE_DIR=${gtk2.out}/lib/gtk-2.0/include"
    "-DGTK2_GLIBCONFIG_INCLUDE_DIR=${glib.out}/lib/glib-2.0/include"
  ];

  enableParallelBuilding = true;

  meta = {
    description = "A concise ChartPlotter/Navigator";
    maintainers = [ stdenv.lib.maintainers.kragniz ];
    platforms = [ "x86_64-linux" ];
    license = stdenv.lib.licenses.gpl2;
    homepage = https://opencpn.org/;
  };
}


{ stdenv, fetchurl, x11, libXmu }:

stdenv.mkDerivation rec {
  name = "xclip-0.12";

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

  buildInputs = [ x11 libXmu ];

  meta = {
    description = "Tool to access the X clipboard from a console application";
    homepage = http://sourceforge.net/projects/xclip/;
    license = stdenv.lib.licenses.gpl2;
  };
}

Update xclip to a more recent version (svn)

{ stdenv, fetchsvn, x11, libXmu, autoconf, automake, libtool }:

stdenv.mkDerivation rec {
  # The last release from 2012, 0.12, lacks '-targets'
  name = "xclip-0.12-svn-20140209";

  src = fetchsvn {
    url = "svn://svn.code.sf.net/p/xclip/code/trunk";
    sha256 = "0d6r38xas5l79l700sdm14l41vvjqhah613367ha8kcvx54zkddz";
  };

  preConfigure = "autoreconf -vfi";

  buildInputs = [ x11 libXmu autoconf automake libtool ];

  meta = {
    description = "Tool to access the X clipboard from a console application";
    homepage = http://sourceforge.net/projects/xclip/;
    license = stdenv.lib.licenses.gpl2;
  };
}


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

stdenv.mkDerivation rec {
  name = "feh-2.11";

  src = fetchurl {
    url = "http://feh.finalrewind.org/${name}.tar.bz2";
    sha256 = "1y41ixsp5nhvb29hhiyh8g1g28lc0kki619skgxcv5iisc93dk4x";
  };

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

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

  postInstall = ''
    wrapProgram "$out/bin/feh" --prefix PATH : "${libjpeg}/bin" \
                               --add-flags '--theme=feh'
  '';

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

Update feh from 2.11 to 2.12.

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

stdenv.mkDerivation rec {
  name = "feh-2.12";

  src = fetchurl {
    url = "http://feh.finalrewind.org/${name}.tar.bz2";
    sha256 = "0ckhidmsms2l5jycp0qf71jzmb3bpbhjq3bcgfpvfvszah7pmq30";
  };

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

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

  postInstall = ''
    wrapProgram "$out/bin/feh" --prefix PATH : "${libjpeg}/bin" \
                               --add-flags '--theme=feh'
  '';

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


{ stdenv, fetch-bower, git }: name: version: target: outputHash: stdenv.mkDerivation {
  name = "${name}-${version}";
  realBuilder = "${fetch-bower}/bin/fetch-bower";
  args = [ name version target ];
  outputHashMode = "recursive";
  outputHashAlgo = "sha256";
  inherit outputHash;
  PATH = "${git}/bin";
}

Make fetchBower a bit more like a normal mkDerivation, which is easier to test. Also, in some cases, the result of fetchBower is different depending on the value of $out. For now, it seems that it works best if using a local output directory before copying to $out.

{ stdenv, fetch-bower, git }: name: version: target: outputHash: stdenv.mkDerivation {
  name = "${name}-${version}";
  buildCommand = ''
    out=$PWD/out fetch-bower ${name} ${version} ${target}
    cp -R out $out
  '';
  outputHashMode = "recursive";
  outputHashAlgo = "sha256";
  inherit outputHash;
  buildInputs = [git fetch-bower];
}


{ clipnotify, makeWrapper, xsel, dmenu, util-linux, gawk, stdenv, fetchFromGitHub, lib }:
let
  runtimePath = lib.makeBinPath [ clipnotify xsel dmenu util-linux gawk ];
in
stdenv.mkDerivation rec {
  pname = "clipmenu";
  version = "6.2.0";

  src = fetchFromGitHub {
    owner  = "cdown";
    repo   = "clipmenu";
    rev    = version;
    sha256 = "sha256-nvctEwyho6kl4+NXi76jT2kG7nchmI2a7mgxlgjXA5A=";
  };

  makeFlags = [ "PREFIX=$(out)" ];
  buildInputs = [ makeWrapper ];
  nativeBuildInputs = [ xsel clipnotify ];

  installPhase = ''
    for bin in $out/bin/*; do
      wrapProgram "$bin" --prefix PATH : "${runtimePath}"
    done
  '';

  meta = with stdenv.lib; {
    description = "Clipboard management using dmenu";
    inherit (src.meta) homepage;
    maintainers = with maintainers; [ jb55 ];
    license = licenses.publicDomain;
  };
}

Fix systemd service, clipctl, clipmenud

{ stdenv
, lib
, fetchFromGitHub
, makeWrapper
, clipnotify
, coreutils
, dmenu
, gawk
, util-linux
, xdotool
, xsel
}:
stdenv.mkDerivation rec {
  pname = "clipmenu";
  version = "6.2.0";

  src = fetchFromGitHub {
    owner  = "cdown";
    repo   = "clipmenu";
    rev    = version;
    sha256 = "sha256-nvctEwyho6kl4+NXi76jT2kG7nchmI2a7mgxlgjXA5A=";
  };

  postPatch = ''
    sed -i init/clipmenud.service \
      -e "s,/usr/bin,$out/bin,"
  '';

  makeFlags = [ "PREFIX=$(out)" ];
  buildInputs = [ makeWrapper ];
  nativeBuildInputs = [ xsel clipnotify ];

  postFixup = ''
    sed -i "$out/bin/clipctl" -e 's,clipmenud\$,\.clipmenud-wrapped\$,'

    wrapProgram "$out/bin/clipmenu" \
      --prefix PATH : "${lib.makeBinPath [ xsel ]}"

    wrapProgram "$out/bin/clipmenud" \
      --set PATH "${lib.makeBinPath [ clipnotify coreutils gawk util-linux xdotool xsel ]}"
  '';

  meta = with stdenv.lib; {
    description = "Clipboard management using dmenu";
    inherit (src.meta) homepage;
    maintainers = with maintainers; [ jb55 ];
    license = licenses.publicDomain;
  };
}


{ lib
, stdenv
, fetchFromGitLab
, meson
, ninja
, pkg-config
, wrapGAppsHook
, glib
, gsound
, libgudev
, json-glib
, vala
, gobject-introspection
}:

stdenv.mkDerivation rec {
  pname = "feedbackd-unstable";
  version = "2021-01-25";

  src = fetchFromGitLab {
    domain = "source.puri.sm";
    owner = "Librem5";
    repo = "feedbackd";
    rev = "v0.0.0+git${builtins.replaceStrings ["-"] [""] version}";
    sha256 = "184ag10sfzrka533inv6f38x6z769kq5jj56vdkcm65j5h786w5v";
  };

  nativeBuildInputs = [
    meson
    ninja
    pkg-config
    wrapGAppsHook
    vala
    gobject-introspection
  ];

  buildInputs = [
    glib
    gsound
    libgudev
    json-glib
  ];

  meta = with lib; {
    description = "A daemon to provide haptic (and later more) feedback on events";
    homepage = "https://source.puri.sm/Librem5/feedbackd";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ pacman99 ];
    platforms = platforms.linux;
  };
}

Add udev rules to output

{ lib
, stdenv
, fetchFromGitLab
, meson
, ninja
, pkg-config
, wrapGAppsHook
, glib
, gsound
, libgudev
, json-glib
, vala
, gobject-introspection
}:

stdenv.mkDerivation rec {
  pname = "feedbackd-unstable";
  version = "2021-01-25";

  src = fetchFromGitLab {
    domain = "source.puri.sm";
    owner = "Librem5";
    repo = "feedbackd";
    rev = "v0.0.0+git${builtins.replaceStrings ["-"] [""] version}";
    sha256 = "184ag10sfzrka533inv6f38x6z769kq5jj56vdkcm65j5h786w5v";
  };

  nativeBuildInputs = [
    meson
    ninja
    pkg-config
    wrapGAppsHook
    vala
    gobject-introspection
  ];

  buildInputs = [
    glib
    gsound
    libgudev
    json-glib
  ];

  postInstall = ''
    mkdir -p $out/lib/udev/rules.d
    sed "s|/usr/libexec/|$out/libexec/|" < $src/debian/feedbackd.udev > $out/lib/udev/rules.d/90-feedbackd.rules
  '';

  meta = with lib; {
    description = "A daemon to provide haptic (and later more) feedback on events";
    homepage = "https://source.puri.sm/Librem5/feedbackd";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ pacman99 ];
    platforms = platforms.linux;
  };
}


{ stdenv, fetchFromGitHub, getopt, which, pkgconfig, gtk3 } :

stdenv.mkDerivation (rec {
  name = "pqiv-${version}";
  version = "2.10.2";

  src = fetchFromGitHub {
    owner = "phillipberndt";
    repo = "pqiv";
    rev = version;
    sha256 = "0zn7ps73lw04l9i4777c90ik07v3hkg66mnpz8vvvwjyi40i77a7";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ getopt which gtk3 ];

  prePatch = "patchShebangs .";

  meta = with stdenv.lib; {
    description = "Powerful image viewer with minimal UI";
    homepage = http://www.pberndt.com/Programme/Linux/pqiv;
    license = licenses.gpl3;
    maintainers = [ maintainers.ndowens ];
    platforms = platforms.linux;
  };
})

Add dependencies so all backends are available

{ stdenv, fetchFromGitHub, getopt, which, pkgconfig, gtk3,
ffmpeg, imagemagick, libarchive, libspectre, libwebp, poppler
}:

stdenv.mkDerivation (rec {
  name = "pqiv-${version}";
  version = "2.10.2";

  src = fetchFromGitHub {
    owner = "phillipberndt";
    repo = "pqiv";
    rev = version;
    sha256 = "0zn7ps73lw04l9i4777c90ik07v3hkg66mnpz8vvvwjyi40i77a7";
  };

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [
    getopt which gtk3
    ffmpeg imagemagick libarchive libspectre libwebp poppler
  ];

  prePatch = "patchShebangs .";

  meta = with stdenv.lib; {
    description = "Powerful image viewer with minimal UI";
    homepage = http://www.pberndt.com/Programme/Linux/pqiv;
    license = licenses.gpl3;
    maintainers = [ maintainers.ndowens ];
    platforms = platforms.linux;
  };
})


{ stdenv, fetchurl }:

stdenv.mkDerivation {
  name = "proj-4.9.2";

  src = fetchurl {
    url = http://download.osgeo.org/proj/proj-4.9.2.tar.gz;
    sha256 = "15kpcmz3qjxfrs6vq48mgyvb4vxscmwgkzrdcn71a60wxp8rmgv0";
  };

  meta = with stdenv.lib; {
    description = "Cartographic Projections Library";
    homepage = http://trac.osgeo.org/proj/;
    license = licenses.mit;
    platforms = platforms.linux;
    maintainers = with maintainers; [ vbgl ];
  };
}

Add platforms.darwin and enable doCheck.

{ stdenv, fetchurl }:

stdenv.mkDerivation {
  name = "proj-4.9.2";

  src = fetchurl {
    url = http://download.osgeo.org/proj/proj-4.9.2.tar.gz;
    sha256 = "15kpcmz3qjxfrs6vq48mgyvb4vxscmwgkzrdcn71a60wxp8rmgv0";
  };

  doCheck = true;

  meta = with stdenv.lib; {
    description = "Cartographic Projections Library";
    homepage = http://trac.osgeo.org/proj/;
    license = licenses.mit;
    platforms = platforms.linux ++ platforms.darwin;
    maintainers = with maintainers; [ vbgl ];
  };
}