x@{builderDefsPackage
  , ...}:
builderDefsPackage
(a :
let
  helperArgNames = ["stdenv" "fetchurl" "builderDefsPackage"] ++
    [];

  buildInputs = map (n: builtins.getAttr n x)
    (builtins.attrNames (builtins.removeAttrs x helperArgNames));
  sourceInfo = rec {
    baseName="mtr";
    version="0.80";
    name="${baseName}-${version}";
    url="ftp://ftp.bitwizard.nl/${baseName}/${name}.tar.gz";
    hash="1h0fzxy5cwml3p2nq749sq8mk2dsvm4qb1ah7a9hbf7kzabxvfvn";
  };
in
rec {
  src = a.fetchurl {
    url = sourceInfo.url;
    sha256 = sourceInfo.hash;
  };

  inherit (sourceInfo) name version;
  inherit buildInputs;

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

  meta = {
    description = "A network diagnostics tool";
    maintainers = with a.lib.maintainers;
    [
      raskin
    ];
    platforms = with a.lib.platforms;
      linux;
    license = a.lib.licenses.gpl2;
  };
  passthru = {
    updateInfo = {
      downloadPage = "ftp://ftp.bitwizard.nl/mtr/";
    };
  };
}) x

Update to new upstream version 0.82.

x@{builderDefsPackage
  , ...}:
builderDefsPackage
(a :
let
  helperArgNames = ["stdenv" "fetchurl" "builderDefsPackage"] ++
    [];

  buildInputs = map (n: builtins.getAttr n x)
    (builtins.attrNames (builtins.removeAttrs x helperArgNames));
  sourceInfo = rec {
    baseName="mtr";
    version="0.82";
    name="${baseName}-${version}";
    url="ftp://ftp.bitwizard.nl/${baseName}/${name}.tar.gz";
    hash="185nx4y6xn7vv6l3pbyc0ljmwfl4si4zszwad1jkbq1scb4mgd7k";
  };
in
rec {
  src = a.fetchurl {
    url = sourceInfo.url;
    sha256 = sourceInfo.hash;
  };

  inherit (sourceInfo) name version;
  inherit buildInputs;

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

  meta = {
    description = "A network diagnostics tool";
    maintainers = with a.lib.maintainers;
    [
      raskin
    ];
    platforms = with a.lib.platforms;
      linux;
    license = a.lib.licenses.gpl2;
  };
  passthru = {
    updateInfo = {
      downloadPage = "ftp://ftp.bitwizard.nl/mtr/";
    };
  };
}) x


{ callPackage, openssl, icu, enableNpm ? true }:

let
  buildNodejs = callPackage ./nodejs.nix { inherit openssl icu; };
in
  buildNodejs {
    inherit enableNpm;
    version = "12.6.0";
    sha256 = "12ghr9xy857zpfbgk3ck64rg279gbr1figdfk6lpcvn6vfr4n2ly";
  }

Revert "nodejs-12_x: 12.5.0 -> 12.6.0"

{ callPackage, openssl, icu, enableNpm ? true }:

let
  buildNodejs = callPackage ./nodejs.nix { inherit openssl icu; };
in
  buildNodejs {
    inherit enableNpm;
    version = "12.5.0";
    sha256 = "08haqs104lw44l92bxfii18sdn7y1k07cz3p0ni9bhw7kh4vf5c7";
  }


let
  _pkgs = import <nixpkgs> {};
in
{ pkgs ? import (_pkgs.fetchFromGitHub { owner = "NixOS";
                                         repo = "nixpkgs-channels";
                                         rev = "759620505595d72879d1d8c74a59c0868cce8f71";
                                         sha256 = "05x9szam0yqjdiz69px165krzsycsa419yq0zsv6s5lczmbl7cvn";
                                       }) {}
}:

pkgs.stdenv.mkDerivation rec {
  name = "junit5-docker";
  env = pkgs.buildEnv { name = name; paths = buildInputs; };
  buildInputs = [
      pkgs.openjdk
      pkgs.maven
      pkgs.docker
  ];
}

Add maven opts variable for maven to use the right jvm when forking

let
  _pkgs = import <nixpkgs> {};
in
{ pkgs ? import (_pkgs.fetchFromGitHub { owner = "NixOS";
                                         repo = "nixpkgs-channels";
                                         rev = "759620505595d72879d1d8c74a59c0868cce8f71";
                                         sha256 = "05x9szam0yqjdiz69px165krzsycsa419yq0zsv6s5lczmbl7cvn";
                                       }) {}
}:

pkgs.stdenv.mkDerivation rec {
  name = "junit5-docker";
  env = pkgs.buildEnv { name = name; paths = buildInputs; };
  buildInputs = [
      pkgs.openjdk
      pkgs.maven
      pkgs.docker
  ];
  MAVEN_OPTS = "-Djvm=${pkgs.openjdk}/bin/java";
}


{ stdenv
, fetchurl
}:

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

  src = fetchurl {
    urls = [
      "https://download.libsodium.org/libsodium/releases/libsodium-${version}.tar.gz"
      "mirror://gentoo/distfiles/libsodium-${version}.tar.gz"
    ];
    sha256 = "71b786a96dd03693672b0ca3eb77f4fb08430df307051c0d45df5353d22bc4be";
  };

  doCheck = true;

  meta = with stdenv.lib; {
    description = "A modern and easy-to-use crypto library";
    homepage = http://doc.libsodium.org/;
    license = licenses.isc;
    maintainers = with maintainers; [
      codyopel
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}

Revert "libsodium: 1.0.9 -> 1.0.10"

{ stdenv, fetchurl }:

let
  genUrls = version: [
    "https://download.libsodium.org/libsodium/releases/libsodium-${version}.tar.gz"
    "mirror://gentoo/distfiles/libsodium-${version}.tar.gz"
  ];
in
stdenv.mkDerivation rec {
  name = "libsodium-${version}";
  version = "1.0.9";

  src = fetchurl {
    urls = genUrls version;
    allowHashOutput = false;
    sha256 = "611418db78c36b2e20e50363d30e9c002a98dea9322f305b5bde56a26cdfe756";
  };

  doCheck = true;

  passthru = rec {
    newVersion = "1.0.9";

    sourceTarball = fetchurl rec {
      failEarly = true;
      urls = genUrls newVersion;
      minisignUrls = map (n: "${n}.minisig") urls;
      minisignPub = "RWQf6LRCGA9i53mlYecO4IzT51TGPpvWucNSCh1CBM0QTaLn73Y7GFO3";
      sha256 = "611418db78c36b2e20e50363d30e9c002a98dea9322f305b5bde56a26cdfe756";
    };
  };

  meta = with stdenv.lib; {
    description = "A modern and easy-to-use crypto library";
    homepage = http://doc.libsodium.org/;
    license = licenses.isc;
    maintainers = with maintainers; [
      codyopel
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}


{ stdenv, fetchurl, autoreconfHook, libcap ? null }:

assert stdenv.isLinux -> libcap != null;

stdenv.mkDerivation rec {
  name = "ntp-4.2.8p2";

  src = fetchurl {
    url = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/${name}.tar.gz";
    sha256 = "0ccv9kh5asxpk7bjn73vwrqimbkbfl743bgx0km47bfajl7bqs8d";
  };

  configureFlags = stdenv.lib.optional (libcap != null) "--enable-linuxcaps";

  buildInputs = [ autoreconfHook libcap ];

  postInstall = "rm -rf $out/share/doc";

  meta = {
    homepage = http://www.ntp.org/;
    description = "An implementation of the Network Time Protocol";
    maintainers = [ stdenv.lib.maintainers.eelco ];
    platforms = stdenv.lib.platforms.linux;
  };
}

Refactor and add signing support

{ stdenv, fetchurl, autoreconfHook, libcap ? null, openssl ? null }:

assert stdenv.isLinux -> libcap != null;

stdenv.mkDerivation rec {
  name = "ntp-4.2.8p2";

  src = fetchurl {
    url = "http://www.eecis.udel.edu/~ntp/ntp_spool/ntp4/ntp-4.2/${name}.tar.gz";
    sha256 = "0ccv9kh5asxpk7bjn73vwrqimbkbfl743bgx0km47bfajl7bqs8d";
  };

  configureFlags = [
    "--sysconfdir=/etc"
    "--localstatedir=/var"
    "--enable-ignore-dns-errors"
  ] ++ stdenv.lib.optional (libcap != null) "--enable-linuxcaps";

  nativeBuildInputs = [ autoreconfHook ];
  buildInputs = [ libcap openssl ];

  postInstall = ''
    rm -rf $out/share/doc
  '';

  meta = {
    homepage = http://www.ntp.org/;
    description = "An implementation of the Network Time Protocol";
    maintainers = [ stdenv.lib.maintainers.eelco ];
    platforms = stdenv.lib.platforms.linux;
  };
}


{ stdenv, fetchurl, pciutils }: with stdenv.lib;

stdenv.mkDerivation rec {
  pname = "gnu-efi";
  version = "3.0.9";

  src = fetchurl {
    url = "mirror://sourceforge/gnu-efi/${pname}-${version}.tar.bz2";
    sha256 = "1w3p4aqlc5j93q44la7dc8cr3hky20zvsd0h0k2lyzhwmrzfl5b7";
  };

  buildInputs = [ pciutils ];

  hardeningDisable = [ "stackprotector" ];

  makeFlags = [
    "PREFIX=\${out}"
    "CC=${stdenv.cc.targetPrefix}gcc"
    "AS=${stdenv.cc.targetPrefix}as"
    "LD=${stdenv.cc.targetPrefix}ld"
    "AR=${stdenv.cc.targetPrefix}ar"
    "RANLIB=${stdenv.cc.targetPrefix}ranlib"
    "OBJCOPY=${stdenv.cc.targetPrefix}objcopy"
  ] ++ stdenv.lib.optional stdenv.isAarch32 "ARCH=arm"
    ++ stdenv.lib.optional stdenv.isAarch64 "ARCH=aarch64";

  meta = with stdenv.lib; {
    description = "GNU EFI development toolchain";
    homepage = https://sourceforge.net/projects/gnu-efi/;
    license = licenses.bsd3;
    platforms = platforms.linux;
  };
}

Use their crosscompilation support correctly

{ stdenv, buildPackages, fetchurl, pciutils }:

with stdenv.lib;

stdenv.mkDerivation rec {
  pname = "gnu-efi";
  version = "3.0.9";

  src = fetchurl {
    url = "mirror://sourceforge/gnu-efi/${pname}-${version}.tar.bz2";
    sha256 = "1w3p4aqlc5j93q44la7dc8cr3hky20zvsd0h0k2lyzhwmrzfl5b7";
  };

  buildInputs = [ pciutils ];

  hardeningDisable = [ "stackprotector" ];

  makeFlags = [
    "PREFIX=\${out}"
    "HOSTCC=${buildPackages.stdenv.cc.targetPrefix}cc"
    "CROSS_COMPILE=${stdenv.cc.targetPrefix}"
  ];

  meta = with stdenv.lib; {
    description = "GNU EFI development toolchain";
    homepage = https://sourceforge.net/projects/gnu-efi/;
    license = licenses.bsd3;
    platforms = platforms.linux;
  };
}


{ stdenv, fetchurl }:
let
  version = "0.1.6";
in
stdenv.mkDerivation {
  name = "libyaml-${version}";

  src = fetchurl {
    url = "http://pyyaml.org/download/libyaml/yaml-${version}.tar.gz";
    sha256 = "0j9731s5zjb8mjx7wzf6vh7bsqi38ay564x6s9nri2nh9cdrg9kx";
  };

  meta = with stdenv.lib; {
    homepage = http://pyyaml.org/;
    description = "A YAML 1.1 parser and emitter written in C";
    license = licenses.mit;
  };
}

Add myself as a maintainer and add platforms meta

{ stdenv, fetchurl }:
let
  version = "0.1.6";
in
stdenv.mkDerivation {
  name = "libyaml-${version}";

  src = fetchurl {
    url = "http://pyyaml.org/download/libyaml/yaml-${version}.tar.gz";
    sha256 = "0j9731s5zjb8mjx7wzf6vh7bsqi38ay564x6s9nri2nh9cdrg9kx";
  };

  meta = with stdenv.lib; {
    homepage = http://pyyaml.org/;
    description = "A YAML 1.1 parser and emitter written in C";
    license = licenses.mit;
    platforms = platforms.unix;
    maintainers = with maintainers; [ wkennington ];
  };
}


{stdenv, fetchurl, pkgconfig, curl, gpgme}:

stdenv.mkDerivation {
  name = "opkg-0.1.8";
  src = fetchurl {
    url = http://opkg.googlecode.com/files/opkg-0.1.8.tar.gz;
    sha256 = "0q0w7hmc6zk7pnddamd5v8d76qnh3043lzh5np24jbb6plqbz57z";
  };
  buildInputs = [ pkgconfig curl gpgme ];
}

Update opkg to latest version, adpot it and add meta-information.

{ stdenv, fetchurl, pkgconfig, curl, gpgme }:

stdenv.mkDerivation rec {
  version = "0.2.2";
  name = "opkg-${version}";
  src = fetchurl {
    url = "http://downloads.yoctoproject.org/releases/opkg/opkg-${version}.tar.gz";
    sha256 = "0ax10crp2grrpl20gl5iqfw37d5qz6h790lyyv2ali45agklqmda";
  };

  buildInputs = [ pkgconfig curl gpgme ];

  meta = with stdenv.lib; {
    description = "A lightweight package management system based upon ipkg";
    homepage = http://code.google.com/p/opkg/;
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = with maintainers; [ pSub ];
  };
}


{ pkgs, ... }:

let
  pkgs-unstable = import <nixpkgs-unstable> { config = { allowUnfree = true; }; };
in
{
  environment.systemPackages = with pkgs; [
    pkgs-unstable.cargo
    pkgs-unstable.rustc
    pkgs-unstable.rls
  ];
  my-config.vscodeExtensions = with (import ../vscode-extensions.nix); [
    rust
    better-toml
  ];
}

Use Rust packages from standard nixpkgs

{ pkgs, ... }:

{
  environment.systemPackages = with pkgs; [
    cargo
    rustc
    rls
  ];
  my-config.vscodeExtensions = with (import ../vscode-extensions.nix); [
    rust
    better-toml
  ];
}


# From an end-user configuration file (`configuration'), build a NixOS
# configuration object (`config') from which we can retrieve option
# values.

{ configuration
, system ? builtins.currentSystem
, nixpkgs ? import ./from-env.nix "NIXPKGS" /etc/nixos/nixpkgs
, pkgs ? import nixpkgs {inherit system;}
}:

rec {
  inherit nixpkgs pkgs;

  configComponents = [
    configuration
    {
      require = import ../modules/module-list.nix;
      environment.checkConfigurationOptions = pkgs.lib.mkOption {
        default = true;
        example = false;
        description = ''
          Whether to check the validity of the entire configuration.
        '';
      };
    }
  ];

  config_ =
    pkgs.lib.fixOptionSets
      pkgs.lib.mergeOptionSets
      pkgs configComponents;

  optionDeclarations =
    pkgs.lib.fixOptionSetsFun
      pkgs.lib.filterOptionSets
      pkgs configComponents
      config_;

  # Optionally check wether all config values have corresponding
  # option declarations.
  config = pkgs.checker config_
    config_.environment.checkConfigurationOptions
    optionDeclarations config_;
}

Update function arguments to follow nixpkgs modification.

# From an end-user configuration file (`configuration'), build a NixOS
# configuration object (`config') from which we can retrieve option
# values.

{ configuration
, system ? builtins.currentSystem
, nixpkgs ? import ./from-env.nix "NIXPKGS" /etc/nixos/nixpkgs
, pkgs ? import nixpkgs {inherit system;}
}:

rec {
  inherit nixpkgs pkgs;

  configComponents = [
    configuration
    {
      require = import ../modules/module-list.nix;
      environment.checkConfigurationOptions = pkgs.lib.mkOption {
        default = true;
        example = false;
        description = ''
          Whether to check the validity of the entire configuration.
        '';
      };
    }
  ];

  config_ =
    pkgs.lib.fixOptionSets
      pkgs.lib.mergeOptionSets
      { inherit pkgs; } configComponents;

  optionDeclarations =
    pkgs.lib.fixOptionSetsFun
      pkgs.lib.filterOptionSets
      { inherit pkgs; } configComponents
      config_;

  # Optionally check wether all config values have corresponding
  # option declarations.
  config = pkgs.checker config_
    config_.environment.checkConfigurationOptions
    optionDeclarations config_;
}


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

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

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

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

Add szip as an optional dependency

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

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

  configureFlags = if szip != null then "--with-szlib=${szip}" else "";

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

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


{
  imports = [
    ../.
  ];
  # Give TLP service more control over battery
  boot = {
    extraModulePackages = with config.boot.kernelPackages; [
      acpi_call
    ];
    kernelModules = [
      "acpi_call"
    ];
  };

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

Add the temporary fix for the cpu-throttling issue

{ config, pkgs, ... }:
{
  imports = [
    ../.
  ];
  # Give TLP service more control over battery
  boot = {
    extraModulePackages = with config.boot.kernelPackages; [
      acpi_call
    ];
    kernelModules = [
      "acpi_call"
    ];
  };

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

  # Temporary fix for cpu throttling issues visible in the kernel log
  # (journalctl -k) by setting the same temperature limits used by
  # Window$
  # See https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Power_management.2FThrottling_issues
  systemd.services.cpu-throttling = {
    enable = true;
    description = "Sets the offset to 3 °C, so the new trip point is 97 °C";
    documentation = [
      "https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Power_management.2FThrottling_issues"
    ];
    path = [ pkgs.msr-tools ];
    script = "wrmsr -a 0x1a2 0x3000000";
    serviceConfig = {
      Type = "oneshot";
    };
    wantedBy = [
      "timers.target"
    ];
  };

  systemd.timers.cpu-throttling = {
    enable = true;
    description = "Set cpu heating limit to 97 °C";
    documentation = [
      "https://wiki.archlinux.org/index.php/Lenovo_ThinkPad_X1_Carbon_(Gen_6)#Power_management.2FThrottling_issues"
    ];
    timerConfig = {
      OnActiveSec = 60;
      OnUnitActiveSec = 60;
      Unit = "cpu-throttling.service";
    };
    wantedBy = [
      "timers.target"
    ];
  };

}


with import <nixpkgs> {};

stdenv.mkDerivation rec {
  name = "urn";
  version = "0.3.1";
  src = ./.; # oh nix
  buildInputs = [ lua makeWrapper ];

  installPhase = ''
  install -Dm755 bin/urn.lua $out/bin/urn
  mkdir -p $out/lib/
  cp -r lib $out/lib/urn
  wrapProgram $out/bin/urn \
    --add-flags "-i $out/lib/urn --prelude $out/lib/urn/prelude.lisp" \
    --prefix PATH : ${lua}/bin/
  '';

  meta = with stdenv.lib; {
    homepage = https://squiddev.github.io/urn;
    description = "A lean lisp implementation for Lua";
    license = licenses.bsd3;
  };
}

Allow the user to specify which Lua derivation to use

{ nixpkgs ? import <nixpkgs> {}
, lua ? nixpkgs.pkgs.lua
}:

let
  inherit (nixpkgs) stdenv;
in
stdenv.mkDerivation rec {
  name = "urn";
  version = "0.3.1";
  src = ./.; # oh nix
  buildInputs = [ lua nixpkgs.pkgs.makeWrapper ];

  installPhase = ''
  install -Dm755 bin/urn.lua $out/bin/urn
  mkdir -p $out/lib/
  cp -r lib $out/lib/urn
  wrapProgram $out/bin/urn \
    --add-flags "-i $out/lib/urn --prelude $out/lib/urn/prelude.lisp" \
    --prefix PATH : ${lua}/bin/
  '';

  meta = with stdenv.lib; {
    homepage = https://squiddev.github.io/urn;
    description = "A lean lisp implementation for Lua";
    license = licenses.bsd3;
  };
}


{stdenv, fetchurl, eventlog, pkgconfig, libestr, libee, json_c, libuuid, zlib, gnutls}:

stdenv.mkDerivation {
  name = "rsyslog-7.2.7";

  src = fetchurl {
    url = http://www.rsyslog.com/files/download/rsyslog/rsyslog-7.2.7.tar.gz;
    sha256 = "0vgrbbklsvnwcy0m0kbxcj5lhpn2k9bsv0lh0vnyn6hc2hx56cs8";
  };

  buildInputs = [pkgconfig libestr libee json_c libuuid zlib gnutls];

  configureFlags = "--enable-gnutls";

  meta = {
    homepage = "http://www.rsyslog.com/";
    description = "Enhanced syslog implementation";
    license = "GPLv3";
    platforms = stdenv.lib.platforms.linux;
  };
}

Upgrade rsyslog to latest stable, 7.4.7. Include systemd journal support.

{stdenv, fetchurl, eventlog, pkgconfig, libestr, libee, json_c, libuuid, zlib, gnutls, libgcrypt, systemd}:

stdenv.mkDerivation {
  name = "rsyslog-7.4.7";

  src = fetchurl {
    url = http://www.rsyslog.com/files/download/rsyslog/rsyslog-7.4.7.tar.gz;
    sha256 = "5fc7f930fa748bb6a9d86a3fc831eb1a14107db81b67d79ba8f113cf2776fa21";
  };

  buildInputs = [pkgconfig libestr libee json_c libuuid zlib gnutls libgcrypt systemd];

  preConfigure = ''
     export configureFlags="$configureFlags --enable-gnutls --enable-cached-man-pages --enable-imjournal --with-systemdsystemunitdir=$out/etc/systemd/system"
  '';

  meta = {
    homepage = "http://www.rsyslog.com/";
    description = "Enhanced syslog implementation";
    license = "GPLv3";
    platforms = stdenv.lib.platforms.linux;
  };
}


{ stdenv, fetchurl, pcre }:

stdenv.mkDerivation rec {
  name = "leafnode-2.0.0.alpha20121101a.12";

  src = fetchurl {
    url = "http://home.pages.de/~mandree/leafnode/beta/leafnode-2.0.0.alpha20121101a.tar.bz2";
    sha256 = "096w4gxj08m3vwmyv4sxpmbl8dn6mzqfmrhc32jgyca6qzlrdin8";
  };

  configureFlags = "--enable-runas-user=nobody";

  postConfigure = ''
      # The is_validfqdn is far too restrictive, and only allows
      # Internet-facing servers to run.  In order to run leafnode via
      # localhost only, we need to disable this check.
      sed -i validatefqdn.c -e 's/int is_validfqdn(const char \*f) {/int is_validfqdn(const char *f) { return 1;/;'
  '';

  buildInputs = [ pcre];

  meta = {
    homepage = "http://leafnode.sourceforge.net/";
    description = "Leafnode implements a store & forward NNTP proxy";
    license = stdenv.lib.licenses.mit;
    platforms = stdenv.lib.platforms.unix;
    broken = true; # The user check in the configure does not work in a chroot
  };
}

Fix leafnode by working around the check

{ stdenv, fetchurl, pcre }:

stdenv.mkDerivation rec {
  name = "leafnode-2.0.0.alpha20121101a.12";

  src = fetchurl {
    url = "http://home.pages.de/~mandree/leafnode/beta/leafnode-2.0.0.alpha20121101a.tar.bz2";
    sha256 = "096w4gxj08m3vwmyv4sxpmbl8dn6mzqfmrhc32jgyca6qzlrdin8";
  };

  configureFlags = "--enable-runas-user=nobody";

  preConfigure = ''
    # configure uses id to check environment; we don't want this check
    sed -re 's/^ID[=].*/ID="echo whatever"/' -i configure
  '';

  postConfigure = ''
      # The is_validfqdn is far too restrictive, and only allows
      # Internet-facing servers to run.  In order to run leafnode via
      # localhost only, we need to disable this check.
      sed -i validatefqdn.c -e 's/int is_validfqdn(const char \*f) {/int is_validfqdn(const char *f) { return 1;/;'
  '';

  buildInputs = [ pcre];

  meta = {
    homepage = "http://leafnode.sourceforge.net/";
    description = "Leafnode implements a store & forward NNTP proxy";
    license = stdenv.lib.licenses.mit;
    platforms = stdenv.lib.platforms.unix;
  };
}


with (import <nixpkgs> {});

stdenv.mkDerivation {
  name = "cassava-streams";

  buildInputs = [
    # GHC:
    haskell.packages.lts-6_7.ghc

    # Non-Haskell Dependencies:
    zlib
  ];
}

Add gpg for signing releases

with (import <nixpkgs> {});

stdenv.mkDerivation {
  name = "cassava-streams";

  buildInputs = [
    # GHC:
    haskell.packages.lts-6_7.ghc

    # Non-Haskell Dependencies:
    gnupg     # For signing packages.
    zlib
  ];
}


/*
 * This Nix expression composes all the packages of the Hello World example.
 * Essentially this model captures all the intra-dependencies of a distributed system.
 */

{ distribution ? null # Take distribution model as optional input argument, which is needed by the lookup services
, services ? null # Take services model as optional input argument, which is needed by the lookup services
, system ? builtins.currentSystem
, pkgs
}:

rec {
  HelloService = import ../pkgs/HelloService {
    inherit (pkgs) stdenv apacheAnt jdk axis2;
  };

  HelloWorldService = import ../pkgs/HelloWorldService {
    inherit (pkgs) stdenv apacheAnt jdk axis2;
  };

  HelloWorld = import ../pkgs/HelloWorld {
    inherit (pkgs) stdenv apacheAnt jdk axis2;
  };

  LookupConfig = if distribution == null || services == null then null else import ../pkgs/LookupConfig {
    inherit (pkgs) stdenv libxslt;
    inherit distribution services;
  };

  LookupService = import ../pkgs/LookupService {
    inherit (pkgs) stdenv apacheAnt jdk axis2;
    inherit LookupConfig;
  };

  HelloWorldService2 = import ../pkgs/HelloWorldService2 {
    inherit (pkgs) stdenv apacheAnt jdk axis2;
  };

  HelloWorld2 = import ../pkgs/HelloWorld2 {
    inherit (pkgs) stdenv apacheAnt jdk axis2;
  };

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

  HelloDBService = import ../pkgs/HelloDBService {
    inherit (pkgs) stdenv apacheAnt jdk axis2;
  };

  HelloDBServiceWrapper = import ../pkgs/HelloDBService/wrapper.nix {
    inherit (pkgs) stdenv;
    inherit HelloDBService;
  };

  LookupService2 = import ../pkgs/LookupService2 {
    inherit (pkgs) stdenv apacheAnt jdk axis2;
    inherit LookupConfig;
  };
}

Use callPackage for the top-level composition expression

/*
 * This Nix expression composes all the packages of the Hello World example.
 * Essentially this model captures all the intra-dependencies of a distributed system.
 */

{ distribution ? null # Take distribution model as optional input argument, which is needed by the lookup services
, services ? null # Take services model as optional input argument, which is needed by the lookup services
, system ? builtins.currentSystem
, pkgs
}:

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

  self = {
    HelloService = callPackage ../pkgs/HelloService { };

    HelloWorldService = callPackage ../pkgs/HelloWorldService { };

    HelloWorld = callPackage ../pkgs/HelloWorld { };

    LookupConfig = if distribution == null || services == null then null else callPackage ../pkgs/LookupConfig { };

    LookupService = callPackage ../pkgs/LookupService { };

    HelloWorldService2 = callPackage ../pkgs/HelloWorldService2 { };

    HelloWorld2 = callPackage ../pkgs/HelloWorld2 { };

    HelloMySQLDB = callPackage ../pkgs/HelloMySQLDB { };

    HelloDBService = callPackage ../pkgs/HelloDBService { };

    HelloDBServiceWrapper = callPackage ../pkgs/HelloDBService/wrapper.nix { };

    LookupService2 = callPackage ../pkgs/LookupService2 { };
  };
in
self


{ config, pkgs, nixpkgs, lib, ... }:
{
  imports =
    [
      ../programs/zsh/zsh.nix
      ../programs/neovim/neovim.nix
      ../programs/git.nix
      ../programs/emacs/emacs.nix
    ];

  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "vscode"
    "vscode-with-extensions"
  ];

  home = {
    stateVersion = "21.05";
    packages = with pkgs; [
      pandoc
      cabal-install
      ghc
      haskell-language-server
      stack
      pyright
      ripgrep
      tree
      zathura
      sqlite
      mypy
    ];
  };

  programs.fzf.enable = true;
  programs.bat = {
    enable = true;
    config.theme = "ansi-dark";
  };

  xdg.configFile."alacritty/alacritty.yml".source = ../programs/alacritty.yml;
  xdg.configFile."oh-my-zsh/plugins/nix-shell".source = pkgs.fetchFromGitHub {
    owner = "chisui";
    repo = "zsh-nix-shell";
    rev = "f8574f27e1d7772629c9509b2116d504798fe30a";
    sha256 = "0svskd09vvbzqk2ziw6iaz1md25xrva6s6dhjfb471nqb13brmjq";
  };
}

Add direnv and lorri to all hosts

{ config, pkgs, nixpkgs, lib, ... }:
{
  imports =
    [
      ../programs/zsh/zsh.nix
      ../programs/neovim/neovim.nix
      ../programs/git.nix
      ../programs/emacs/emacs.nix
    ];

  nixpkgs.config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
    "vscode"
    "vscode-with-extensions"
  ];

  home = {
    stateVersion = "21.05";
    packages = with pkgs; [
      lorri
      pandoc
      cabal-install
      ghc
      haskell-language-server
      stack
      pyright
      ripgrep
      tree
      zathura
      sqlite
      mypy
    ];
  };

  programs.direnv = {
    enable = true;
    nix-direnv.enable = true;
  };

  programs.fzf.enable = true;
  programs.bat = {
    enable = true;
    config.theme = "ansi-dark";
  };

  xdg.configFile."alacritty/alacritty.yml".source = ../programs/alacritty.yml;
  xdg.configFile."oh-my-zsh/plugins/nix-shell".source = pkgs.fetchFromGitHub {
    owner = "chisui";
    repo = "zsh-nix-shell";
    rev = "f8574f27e1d7772629c9509b2116d504798fe30a";
    sha256 = "0svskd09vvbzqk2ziw6iaz1md25xrva6s6dhjfb471nqb13brmjq";
  };
}


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

assert enablePython -> python != null;

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

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

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

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

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

Revert "audit: Update to 2.4.2"

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

assert enablePython -> python != null;

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

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

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

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

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


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

with lib;

let
  cfg = config.services.nylas-mail;
  defaultUser = "nylas-mail";
in {
  ###### interface
  options = {
    services.nylas-mail = {

      enable = mkEnableOption ''
        nylas-mail - Open-source mail client built on the modern web with Electron, React, and Flux
      '';

      gnome3-keyring = mkOption {
        type = types.bool;
        default = true;
        description = "Enable gnome3 keyring for nylas-mail.";
      };

      package = mkOption {
        type = types.package;
        default = pkgs.nylas-mail;
        defaultText = "pkgs.nylas-mail";
        example = literalExample "pkgs.nylas-mail";
        description = ''
          nylas-mail package to use.
        '';
      };
    };
  };

  ###### implementation

  config = mkIf cfg.enable {

  };
}

Add keyring enable option and add Nylas to systemPackages

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

with lib;

let
  cfg = config.services.nylas-mail;
  defaultUser = "nylas-mail";
in {
  ###### interface
  options = {
    services.nylas-mail = {

      enable = mkEnableOption ''
        nylas-mail - Open-source mail client built on the modern web with Electron, React, and Flux
      '';

      gnome3-keyring = mkOption {
        type = types.bool;
        default = true;
        description = "Enable gnome3 keyring for nylas-mail.";
      };
    };
  };

  ###### implementation

  config = mkIf cfg.enable {

    environment.systemPackages = [pkgs.nylas-mail];

    services.gnome3.gnome-keyring = mkIf cfg.gnome3-keyring {
      enable = true;
    };

  };
}


{ stdenv, fetchurl, python, zlib, pkgconfig, glib, SDL, ncurses, perl, pixman
, attr, libcap }:

stdenv.mkDerivation rec {
  name = "qemu-1.4.0";

  src = fetchurl {
    url = "http://wiki.qemu.org/download/${name}.tar.bz2";
    sha256 = "1a7d11vjs1p6i1ck2ff9annmkhpkbjl73hl9i1cbg3s0fznrfqh6";
  };

  buildInputs = [
    python zlib pkgconfig glib SDL ncurses perl pixman attr libcap
  ];

  enableParallelBuilding = true;

  configureFlags = [
    "--enable-virtfs"
  ];

  meta = {
    description = "QEmu processor emulator";
    license = "GPLv2+";
    maintainers = with stdenv.lib.maintainers; [ viric shlevy ];
    platforms = with stdenv.lib.platforms; linux;
  };
}

Enable support for VDE networking

{ stdenv, fetchurl, python, zlib, pkgconfig, glib, SDL, ncurses, perl, pixman
, attr, libcap, vde2 }:

stdenv.mkDerivation rec {
  name = "qemu-1.4.0";

  src = fetchurl {
    url = "http://wiki.qemu.org/download/${name}.tar.bz2";
    sha256 = "1a7d11vjs1p6i1ck2ff9annmkhpkbjl73hl9i1cbg3s0fznrfqh6";
  };

  buildInputs = [
    python zlib pkgconfig glib SDL ncurses perl pixman attr libcap
    vde2
  ];

  enableParallelBuilding = true;

  configureFlags = [
    "--enable-virtfs"
    "--enable-vde"
  ];

  meta = {
    description = "QEmu processor emulator";
    license = "GPLv2+";
    maintainers = with stdenv.lib.maintainers; [ viric shlevy ];
    platforms = with stdenv.lib.platforms; linux;
  };
}


{ pkgs, ... }:
{
  programs.emacs = {
    enable = true;
    package = pkgs.emacsPgtkGcc;
  };
}

Use Emacs with native compilation only

{ pkgs, ... }:
{
  programs.emacs = {
    enable = true;
    package = pkgs.emacsGcc;
  };
}


{ cabal, ansiTerminal, async, deepseq, doctest, filepath, ghcPaths
, hspecExpectations, hspecMeta, HUnit, ioMemoize, QuickCheck
, quickcheckIo, random, setenv, silently, tfRandom, time
, transformers
}:

cabal.mkDerivation (self: {
  pname = "hspec2";
  version = "0.3.0";
  sha256 = "0ia19jraz2di31c48lh0kswkb2573jxm7msf33i8d5a5yq8y9wwp";
  isLibrary = true;
  isExecutable = true;
  buildDepends = [
    ansiTerminal async deepseq filepath hspecExpectations HUnit
    ioMemoize QuickCheck quickcheckIo random setenv tfRandom time
    transformers
  ];
  testDepends = [
    ansiTerminal async deepseq doctest filepath ghcPaths
    hspecExpectations hspecMeta HUnit ioMemoize QuickCheck quickcheckIo
    random setenv silently tfRandom time transformers
  ];
  meta = {
    homepage = "http://hspec.github.io/";
    description = "Alpha version of Hspec 2.0";
    license = self.stdenv.lib.licenses.mit;
    platforms = self.ghc.meta.platforms;
  };
})

Update haskell-hspec2 to version 0.3.1

{ cabal, ansiTerminal, async, deepseq, doctest, filepath, ghcPaths
, hspecExpectations, hspecMeta, HUnit, QuickCheck, quickcheckIo
, random, setenv, silently, tfRandom, time, transformers
}:

cabal.mkDerivation (self: {
  pname = "hspec2";
  version = "0.3.1";
  sha256 = "09zzlq3gy10y2bdsmmbdylkscfa3vlwgbc0h0g113rk6zs1l1qs6";
  isLibrary = true;
  isExecutable = true;
  buildDepends = [
    ansiTerminal async deepseq filepath hspecExpectations HUnit
    QuickCheck quickcheckIo random setenv tfRandom time transformers
  ];
  testDepends = [
    ansiTerminal async deepseq doctest filepath ghcPaths
    hspecExpectations hspecMeta HUnit QuickCheck quickcheckIo random
    setenv silently tfRandom time transformers
  ];
  meta = {
    homepage = "http://hspec.github.io/";
    description = "Alpha version of Hspec 2.0";
    license = self.stdenv.lib.licenses.mit;
    platforms = self.ghc.meta.platforms;
  };
})


{ config, pkgs, ... }:

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

  environment.systemPackages = with pkgs;
    [ # Shells
      zsh

      # Editors
      vim
      # emacs # in user config, due to customization

      # Browser
      firefoxWrapper

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

      # Desktop Env
      dmenu

      # Bits of Gnome
      # gnome3.gnome_terminal
      evince

      # Terminal emulator
      termite

      # Admin
      acpi
      file
      gparted
      htop
      tree
      wget

      # Nix
      nix-repl
      nix-prefetch-scripts
    ];

  nix.binaryCaches = [
    "http://cache.nixos.org/"
  ];
  nix.trustedBinaryCaches = [
    "https://hydra.nixos.org/"
    "http://hydra.cryp.to"
    "https://ryantrinkle.com:5443"
  ];
}

Add pub key for Ryan Trinkle's cache

{ config, pkgs, ... }:

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

  environment.systemPackages = with pkgs;
    [ # Shells
      zsh

      # Editors
      vim
      # emacs # in user config, due to customization

      # Browser
      firefoxWrapper

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

      # Desktop Env
      dmenu

      # Bits of Gnome
      # gnome3.gnome_terminal
      evince

      # Terminal emulator
      termite

      # Admin
      acpi
      file
      gparted
      htop
      tree
      wget

      # Nix
      nix-repl
      nix-prefetch-scripts
    ];

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


{ pkgs }:

let
  nodePackages = import <nixpkgs/pkgs/top-level/node-packages.nix> {
    inherit pkgs;
    inherit (pkgs) stdenv nodejs fetchurl fetchgit;
    neededNatives = [ pkgs.python ] ++ pkgs.lib.optional pkgs.stdenv.isLinux pkgs.utillinux;
    self = nodePackages;
    generated = ./package.nix;
  };

in rec {

  build = nodePackages.buildNodePackage {
    name = "sloc-0.1.6";
    src = [
      (pkgs.fetchgit {
         url = "https://github.com/flosse/sloc.git";
         sha256 = "0064va0cd4604vqp8y8ggm33klp2xgqmgrwk9ilp7230x27wykyf";
         rev = "refs/tags/v0.1.6";
      })
    ];
    buildInputs = [ pkgs.nodePackages.coffee-script ];
    postInstall = ''
        ${nodePackages.coffee-script}/bin/coffee -o $out/lib/node_modules/sloc/lib/ -c $src/src/
      '';
    deps = [ nodePackages.commander nodePackages.async nodePackages.cli-table nodePackages.readdirp ];
    passthru.names = [ "sloc" ];
  };
}

Remove strange reference to coffee-script with two versions

{ pkgs }:

let
  nodePackages = import <nixpkgs/pkgs/top-level/node-packages.nix> {
    inherit pkgs;
    inherit (pkgs) stdenv nodejs fetchurl fetchgit;
    neededNatives = [ pkgs.python ] ++ pkgs.lib.optional pkgs.stdenv.isLinux pkgs.utillinux;
    self = nodePackages;
    generated = ./package.nix;
  };

in rec {

  build = nodePackages.buildNodePackage {
    name = "sloc-0.1.6";
    src = [
      (pkgs.fetchgit {
         url = "https://github.com/flosse/sloc.git";
         sha256 = "0064va0cd4604vqp8y8ggm33klp2xgqmgrwk9ilp7230x27wykyf";
         rev = "refs/tags/v0.1.6";
      })
    ];
    buildInputs = [ nodePackages.coffee-script ];
    postInstall = ''
        coffee -o $out/lib/node_modules/sloc/lib/ -c $src/src/
      '';
    deps = [ nodePackages.commander nodePackages.async nodePackages.cli-table nodePackages.readdirp ];
    passthru.names = [ "sloc" ];
  };
}


{ stdenv, fetchFromGitHub, pkgconfig, autoreconfHook, cppunit, libgcrypt
, c-ares, openssl, libxml2, sqlite, zlib }:

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

  src = fetchFromGitHub {
    owner = "tatsuhiro-t";
    repo = "aria2";
    rev = "release-${version}";
    sha256 = "1k4b8jfg4wjsvybb7hysplp6h831allhiqdy9jwsyy0m0zmgk00a";
  };

  buildInputs = [
    pkgconfig autoreconfHook cppunit libgcrypt c-ares openssl libxml2
    sqlite zlib
  ];

  configureFlags = [ "--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt" ];

  meta = with stdenv.lib; {
    homepage = https://github.com/tatsuhiro-t/aria2;
    description = "A lightweight, multi-protocol, multi-source, command-line download utility";
    maintainers = [ maintainers.koral ];
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
  };
}

Add myself as a maintainer

{ stdenv, fetchFromGitHub, pkgconfig, autoreconfHook, cppunit, libgcrypt
, c-ares, openssl, libxml2, sqlite, zlib }:

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

  src = fetchFromGitHub {
    owner = "tatsuhiro-t";
    repo = "aria2";
    rev = "release-${version}";
    sha256 = "1k4b8jfg4wjsvybb7hysplp6h831allhiqdy9jwsyy0m0zmgk00a";
  };

  buildInputs = [
    pkgconfig autoreconfHook cppunit libgcrypt c-ares openssl libxml2
    sqlite zlib
  ];

  configureFlags = [ "--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt" ];

  meta = with stdenv.lib; {
    homepage = https://github.com/tatsuhiro-t/aria2;
    description = "A lightweight, multi-protocol, multi-source, command-line download utility";
    maintainers = with maintainers; [ koral jgeerds ];
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
  };
}


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

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

  version = "3.6.1";

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

  buildInputs = [ eventlog pkgconfig glib python systemd perl riemann_c_client protobufc yacc ];

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

Update from 3.6.1 to 3.6.2

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

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

  version = "3.6.2";

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

  buildInputs = [ eventlog pkgconfig glib python systemd perl riemann_c_client protobufc yacc ];

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

stdenv.mkDerivation rec {
  name = "cppunit-1.14.0";

  src = fetchurl {
    url = "https://dev-www.libreoffice.org/src/${name}.tar.gz";
    multihash = "QmUdPCbTGq4fuyXUV7MoMBPQuW2shm4W9cWvMxfJe47koq";
    sha256 = "3d569869d27b48860210c758c4f313082103a5e58219a7669b52bfd29d674780";
  };

  doCheck = true;

  meta = with stdenv.lib; {
    homepage = "http://sourceforge.net/apps/mediawiki/cppunit/";
    description = "C++ unit testing framework";
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}

Add patch for compatibility with GCC 9.1

{ stdenv
, fetchTritonPatch
, fetchurl
}:

stdenv.mkDerivation rec {
  name = "cppunit-1.14.0";

  src = fetchurl {
    url = "https://dev-www.libreoffice.org/src/${name}.tar.gz";
    multihash = "QmUdPCbTGq4fuyXUV7MoMBPQuW2shm4W9cWvMxfJe47koq";
    sha256 = "3d569869d27b48860210c758c4f313082103a5e58219a7669b52bfd29d674780";
  };

  patches = [
    # Fix compat with GCC 9.1, remove for 1.15+
    (fetchTritonPatch {
      rev = "e8619d4113073eb9ecf0a4adac7e65243d2a86dd";
      file = "c/cppunit/cppunit-fix.gcc.9.1.patch";
      sha256 = "a87312d818ba28e6a9a0d5294ebafde7df9de5096276b32905e9404700dd1020";
    })
  ];

  doCheck = true;

  meta = with stdenv.lib; {
    homepage = "http://sourceforge.net/apps/mediawiki/cppunit/";
    description = "C++ unit testing framework";
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}


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

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

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

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

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

Add harmonics and xtide to shell environment, for TestTides

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

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

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

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

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


{ stdenv, lib, fetchFromGitHub, buildGoModule }:
buildGoModule rec {
  pname = "starlark";
  version = "unstable-2022-03-02";

  src = fetchFromGitHub {
    owner = "google";
    repo = "starlark-go";
    rev = "5411bad688d12781515a91cc032645331b4fc302";
    sha256 = "sha256-JNsGyGlIVMS5w0W4jHVsrPqqNms3Xfpa4n/XcEWqt6I=";
  };

  vendorSha256 = "sha256-lgL5o3MQfZekZ++BNESwV0LeoTxwEZfziQAe99zm4RY=";

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

  meta = with lib; {
    broken = (stdenv.isLinux && stdenv.isAarch64);
    homepage = "https://github.com/google/starlark-go";
    description = "An interpreter for Starlark, implemented in Go";
    license = licenses.bsd3;
    maintainers = with maintainers; [ aaronjheng ];
  };
}

Patch tests to unbreak on aarch64

{ stdenv, lib, fetchFromGitHub, buildGoModule, fetchpatch }:
buildGoModule rec {
  pname = "starlark";
  version = "unstable-2022-03-02";

  src = fetchFromGitHub {
    owner = "google";
    repo = "starlark-go";
    rev = "5411bad688d12781515a91cc032645331b4fc302";
    sha256 = "sha256-JNsGyGlIVMS5w0W4jHVsrPqqNms3Xfpa4n/XcEWqt6I=";
  };

  vendorSha256 = "sha256-lgL5o3MQfZekZ++BNESwV0LeoTxwEZfziQAe99zm4RY=";

  patches = [
    # Fix floating point imprecision issue in the test suite.
    # https://github.com/google/starlark-go/pull/409
    (fetchpatch {
      url = "https://github.com/google/starlark-go/commit/be6ed3bfcc376e5bf6fe2257ae89ddfb00d14e2c.patch";
      sha256 = "sha256-A0tHPso6SfFn73kICcA9/5n3JHd7hMdQMGty+4L6T4k=";
    })
  ];

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

  meta = with lib; {
    homepage = "https://github.com/google/starlark-go";
    description = "An interpreter for Starlark, implemented in Go";
    license = licenses.bsd3;
    maintainers = with maintainers; [ aaronjheng ];
  };
}


{ stdenv, fetchurl, gnused, perl, libgcrypt, zlib, bzip2 }:

stdenv.mkDerivation rec {
  name = "munge-0.5.10";

  src = fetchurl {
    url = "http://munge.googlecode.com/files/${name}.tar.bz2";
    sha256 = "1imbmpd70vkcpca8d9yd9ajkhf6ik057nr3jb1app1wm51f15q00";
  };

  buildInputs = [ gnused perl libgcrypt zlib bzip2 ];

  preConfigure = ''
    # Remove the install-data stuff, since it tries to write to /var
    sed -i '434,465d' src/etc/Makefile.in
  '';

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

  meta = {
    homepage = http://code.google.com/p/munge/;
    description = ''
      An authentication service for creating and validating credentials
    '';
    maintainers = [ stdenv.lib.maintainers.rickynils ];
    platforms = stdenv.lib.platforms.linux;
  };
}

Update from 0.5.10 to 0.5.11

{ stdenv, fetchurl, gnused, perl, libgcrypt, zlib, bzip2 }:

stdenv.mkDerivation rec {
  name = "munge-0.5.11";

  src = fetchurl {
    url = "http://munge.googlecode.com/files/${name}.tar.bz2";
    sha256 = "19aijdrjij2g0xpqgl198jh131j94p4gvam047gsdc0wz0a5c1wf";
  };

  buildInputs = [ gnused perl libgcrypt zlib bzip2 ];

  preConfigure = ''
    # Remove the install-data stuff, since it tries to write to /var
    sed -i '505,511d' src/etc/Makefile.in
  '';

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

  meta = {
    homepage = http://code.google.com/p/munge/;
    description = ''
      An authentication service for creating and validating credentials
    '';
    maintainers = [ stdenv.lib.maintainers.rickynils ];
    platforms = stdenv.lib.platforms.linux;
  };
}


{ pkgs, nix, nixpkgs, config, lib, ... }:
{
  imports = [
    ../../programs/non-free.nix
  ];
  environment.systemPackages = with pkgs;
    [
      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 = {
    fontDir.enable = true;
    fonts = with pkgs; [
      fira-code
      iosevka
      aileron
    ];
  };

  programs.zsh.enable = true;

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

  nix = {
    nixPath = lib.mkForce [
      "nixpkgs=${nixpkgs}"
    ];
    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;
}

Remove irssi from darwin deps

{ pkgs, nix, nixpkgs, config, lib, ... }:
{
  imports = [
    ../../programs/non-free.nix
  ];
  environment.systemPackages = with pkgs;
    [
      alacritty
      cabal-install
      coreutils
      docker
      ffmpeg
      fswatch
      fzf
      gnupg
      home-manager
      nodejs
      openssl
      reattach-to-user-namespace
      ripgrep
      sqlite
      tig
      tree
      wget
      yarn
    ];

  fonts = {
    fontDir.enable = true;
    fonts = with pkgs; [
      fira-code
      iosevka
      aileron
    ];
  };

  programs.zsh.enable = true;

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

  nix = {
    nixPath = lib.mkForce [
      "nixpkgs=${nixpkgs}"
    ];
    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;
}


{ lib, stdenv, fetchFromGitHub, autoreconfHook, pkg-config, python3 }:

stdenv.mkDerivation rec {
  name = "libsmartcols";
  version = "v2.36.1";

  nativeBuildInputs = [ autoreconfHook pkg-config python3 ];

  src = fetchFromGitHub {
    owner = "karelzak";
    repo = "util-linux";
    rev = version;
    sha256 = "0z7nv054pqhlihqiw0vk3h40j0cxk1yxf8zzh0ddmvk6834cnyxs";
  };

  configureFlags = [ "--disable-all-programs" "--enable-libsmartcols" ];

  buildPhase = ''
    make libsmartcols.la
  '';

  installTargets = [ "install-am" "install-pkgconfigDATA" ];

  meta = {
    description = "smart column output alignment library";
    homepage = https://github.com/karelzak/util-linux/tree/master/libsmartcols;
    license = lib.licenses.gpl2Plus;
    platforms = lib.platforms.linux ++ stdenv.lib.platforms.darwin;
    maintainers = with lib.maintainers; [ rb2k ];
  };
}

Add gtk-doc to fix build.

{ lib, stdenv, fetchFromGitHub, autoreconfHook, pkg-config, python3, gtk-doc}:

stdenv.mkDerivation rec {
  name = "libsmartcols";
  version = "v2.36.1";

  nativeBuildInputs = [ autoreconfHook pkg-config python3 gtk-doc ];

  src = fetchFromGitHub {
    owner = "karelzak";
    repo = "util-linux";
    rev = version;
    sha256 = "0z7nv054pqhlihqiw0vk3h40j0cxk1yxf8zzh0ddmvk6834cnyxs";
  };

  configureFlags = [ "--disable-all-programs" "--enable-libsmartcols" ];

  buildPhase = ''
    make libsmartcols.la
  '';

  installTargets = [ "install-am" "install-pkgconfigDATA" ];

  meta = {
    description = "smart column output alignment library";
    homepage = https://github.com/karelzak/util-linux/tree/master/libsmartcols;
    license = lib.licenses.gpl2Plus;
    platforms = lib.platforms.linux ++ stdenv.lib.platforms.darwin;
    maintainers = with lib.maintainers; [ rb2k ];
  };
}


{ lib
, buildPythonPackage
, fetchFromGitHub
, systemd
, pkg-config
}:

buildPythonPackage rec {
  pname = "systemd";
  version = "234";

  src = fetchFromGitHub {
    owner = "systemd";
    repo = "python-systemd";
    rev = "v${version}";
    sha256 = "1fakw7qln44mfd6pj4kqsgyrhkc6cyr653id34kv0rdnb1bvysrz";
  };

  nativeBuildInputs = [
    pkg-config
  ];

  buildInputs = [
    systemd
  ];

  # No module named 'systemd._journal
  doCheck = false;

  pythonImportsCheck = [
    "systemd.journal"
    "systemd.id128"
    "systemd.daemon"
    "systemd.login"
  ];

  meta = with lib; {
    description = "Python module for native access to the systemd facilities";
    homepage = "http://www.freedesktop.org/software/systemd/python-systemd/";
    license = licenses.lgpl21Plus;
  };
}

Fix compatibility with Python 3.10

{ lib
, buildPythonPackage
, fetchpatch
, fetchFromGitHub
, systemd
, pkg-config
}:

buildPythonPackage rec {
  pname = "systemd";
  version = "234";

  src = fetchFromGitHub {
    owner = "systemd";
    repo = "python-systemd";
    rev = "v${version}";
    sha256 = "1fakw7qln44mfd6pj4kqsgyrhkc6cyr653id34kv0rdnb1bvysrz";
  };

  patches = [
    # Fix runtime issues on Python 3.10
    # https://github.com/systemd/python-systemd/issues/107
    (fetchpatch {
      url = "https://github.com/systemd/python-systemd/commit/c71bbac357f0ac722e1bcb2edfa925b68cca23c9.patch";
      sha256 = "22s72Wa/BCwNNvwbxEUh58jhHlbA00SNwNVchVDovcc=";
    })
  ];

  nativeBuildInputs = [
    pkg-config
  ];

  buildInputs = [
    systemd
  ];

  # No module named 'systemd._journal
  doCheck = false;

  pythonImportsCheck = [
    "systemd.journal"
    "systemd.id128"
    "systemd.daemon"
    "systemd.login"
  ];

  meta = with lib; {
    description = "Python module for native access to the systemd facilities";
    homepage = "http://www.freedesktop.org/software/systemd/python-systemd/";
    license = licenses.lgpl21Plus;
  };
}


{ stdenv, fetchFromGitHub, scons, pkgconfig, SDL, lua, fftwFloat, zlib, bzip2 }:

stdenv.mkDerivation rec {
  name = "the-powder-toy-${version}";
  version = "93.3";

  src = fetchFromGitHub {
    owner = "simtr";
    repo = "The-Powder-Toy";
    rev = "v${version}";
    sha256 = "1n15kgl4qnz55b32ddgmhrv64cl3awbds8arycn7mkf7akwdg1g6";
  };

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

  postPatch = ''
    sed -i 's,lua5.1,lua,g' SConscript
  '';

  nativeBuildInputs = [ scons pkgconfig ];

  buildInputs = [ SDL lua fftwFloat zlib bzip2 ];

  sconsFlags = "--tool=";

  installPhase = ''
    install -Dm 755 build/powder* "$out/bin/powder"
  '';

  enableParallelBuilding = true;

  meta = with stdenv.lib; {
    description = "A free 2D physics sandbox game";
    homepage = http://powdertoy.co.uk/;
    platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
    license = licenses.gpl3;
    maintainers = with maintainers; [ abbradar ];
  };
}

Fix powder toy build breaking and change source repository.

{ stdenv, fetchFromGitHub, scons, pkgconfig, SDL, lua, fftwFloat, zlib, bzip2 }:

stdenv.mkDerivation rec {
  name = "the-powder-toy-${version}";
  version = "93.3";

  src = fetchFromGitHub {
    owner = "ThePowderToy";
    repo = "The-Powder-Toy";
    rev = "v${version}";
    sha256 = "1bg1y13kpqxx4mpncxvmg8w02dyqyd9hl43rwnys3sqrjdm9k02j";
  };

  nativeBuildInputs = [ scons pkgconfig ];

  buildInputs = [ SDL lua fftwFloat zlib bzip2 ];

  sconsFlags = "--tool=";

  installPhase = ''
    install -Dm 755 build/powder* "$out/bin/powder"
  '';

  enableParallelBuilding = true;

  meta = with stdenv.lib; {
    description = "A free 2D physics sandbox game";
    homepage = http://powdertoy.co.uk/;
    platforms = [ "i686-linux" "x86_64-linux" "x86_64-darwin" ];
    license = licenses.gpl3;
    maintainers = with maintainers; [ abbradar ];
  };
}


{ fetchurl, stdenv }:

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

  src = fetchurl {
    url = "http://pax.grsecurity.net/${name}.tar.gz";
    sha256 = "107gmriq5icsk9yni5q949rnjapjkcs0823pw6zra6h1xml2f0mm";
  };

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

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

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

Update from 0.8 -> 0.9

{ fetchurl, stdenv }:

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

  src = fetchurl {
    url = "http://pax.grsecurity.net/${name}.tar.gz";
    sha256 = "0biw882fp1lmgs6kpxznp1v6758r7dg9x8iv5a06k0b82bcdsc53";
  };

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

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

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


{ lib, ... }:

with lib;

{
  hardware.trackpoint = mkDefault {
    enable = true;
    emulateWheel = true;
  };

  hardware.enableRedistributableFirmware = mkDefault true;
  services.tlp.enable = true;

  services.xserver = {
    synaptics.enable = false;
    libinput.enable = true;
  };
}

Add `pkgs.acpi` to gather battery status information

{ pkgs, lib, ... }:

with lib;

{
  hardware.trackpoint = mkDefault {
    enable = true;
    emulateWheel = true;
  };

  hardware.enableRedistributableFirmware = mkDefault true;
  services.tlp.enable = true;

  services.xserver = {
    synaptics.enable = false;
    libinput.enable = true;
  };

  environment.systemPackages = [ pkgs.acpi ];
}


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

with lib;

let
  cfg = config.programs.nix-index;
in

{
  options = {
    programs.nix-index.enable = mkOption {
      type = types.bool;
      default = false;
      description = "Whether to enable nix-index and it's command-not-found helper.";
    };

    programs.nix-index.package = mkOption {
      type = types.package;
      default = pkgs.nix-index;
      defaultText = "pkgs.nix-index";
      description = "This option specifies the nix-index package to use.";
    };
  };

  config = mkIf config.programs.nix-index.enable {

    environment.systemPackages = [ cfg.package ];

    environment.interactiveShellInit = "source ${cfg.package}/etc/profile.d/command-not-found.sh";

  };
}

Fix typo in nix-index docstring

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

with lib;

let
  cfg = config.programs.nix-index;
in

{
  options = {
    programs.nix-index.enable = mkOption {
      type = types.bool;
      default = false;
      description = "Whether to enable nix-index and its command-not-found helper.";
    };

    programs.nix-index.package = mkOption {
      type = types.package;
      default = pkgs.nix-index;
      defaultText = "pkgs.nix-index";
      description = "This option specifies the nix-index package to use.";
    };
  };

  config = mkIf config.programs.nix-index.enable {

    environment.systemPackages = [ cfg.package ];

    environment.interactiveShellInit = "source ${cfg.package}/etc/profile.d/command-not-found.sh";

  };
}


{ rustPlatform, fetchFromGitHub, lib, nasm }:

rustPlatform.buildRustPackage rec {
  pname = "rav1e";
  version = "0.3.3";

  src = fetchFromGitHub {
    owner = "xiph";
    repo = "rav1e";
    rev = "v${version}";
    sha256 = "0a9dryag4x35a2c45qiq1j5xk9ydcpw1g6kici85d2yrc2z3hwrx";
  };

  cargoSha256 = "1xaincrmpicp0skf9788w5631x1hxvifvq06hh5ribdz79zclzx3";

  nativeBuildInputs = [ nasm ];

  meta = with lib; {
    description = "The fastest and safest AV1 encoder";
    longDescription = ''
      rav1e is an AV1 video encoder. It is designed to eventually cover all use
      cases, though in its current form it is most suitable for cases where
      libaom (the reference encoder) is too slow.
      Features: https://github.com/xiph/rav1e#features
    '';
    inherit (src.meta) homepage;
    changelog = "https://github.com/xiph/rav1e/releases/tag/v${version}";
    license = licenses.bsd2;
    maintainers = [ maintainers.primeos ];
    platforms = platforms.all;
  };
}

Build and install C-compatible libraries

{ rustPlatform, fetchFromGitHub, lib, nasm, cargo-c }:

rustPlatform.buildRustPackage rec {
  pname = "rav1e";
  version = "0.3.3";

  src = fetchFromGitHub {
    owner = "xiph";
    repo = "rav1e";
    rev = "v${version}";
    sha256 = "0a9dryag4x35a2c45qiq1j5xk9ydcpw1g6kici85d2yrc2z3hwrx";
  };

  cargoSha256 = "1xaincrmpicp0skf9788w5631x1hxvifvq06hh5ribdz79zclzx3";

  nativeBuildInputs = [ nasm cargo-c ];

  postBuild = ''
    cargo cbuild --release --frozen --prefix=${placeholder "out"}
  '';

  postInstall = ''
    cargo cinstall --release --frozen --prefix=${placeholder "out"}
  '';

  meta = with lib; {
    description = "The fastest and safest AV1 encoder";
    longDescription = ''
      rav1e is an AV1 video encoder. It is designed to eventually cover all use
      cases, though in its current form it is most suitable for cases where
      libaom (the reference encoder) is too slow.
      Features: https://github.com/xiph/rav1e#features
    '';
    inherit (src.meta) homepage;
    changelog = "https://github.com/xiph/rav1e/releases/tag/v${version}";
    license = licenses.bsd2;
    maintainers = [ maintainers.primeos ];
    platforms = platforms.all;
  };
}


{stdenv, fetchurl, libX11, xproto, libXt, xextproto}:

stdenv.mkDerivation {
  name = "plan9port-20090318";

  builder = ./builder.sh;

  src = fetchurl {
    url = http://swtch.com/plan9port/plan9port-20090318.tgz;
    sha256 = "1idb2l1s5j34sa1dj1wwnvj97z5z7cy73qjafrxf2bbda26axzqj";
  };

  buildInputs = [ libX11 xproto libXt xextproto ];

  meta = {
    homepage = "http://swtch.com/plan9port/";
    description = "Plan 9 from User Space";
    license="free";
  };
}

Update plan9port to make it build

{stdenv, fetchurl, libX11, xproto, libXt, xextproto, libXext}:

stdenv.mkDerivation rec {
  name = "plan9port-20110103";

  builder = ./builder.sh;

  src = fetchurl {
    url = "http://swtch.com/plan9port/${name}.tgz";
    sha256 = "12hq3k03jgva72498qa1dyndakbhbfg0sc1jhcap9cxqj04xf0dc";
  };

  buildInputs = [ libX11 xproto libXt xextproto libXext ];

  meta = {
    homepage = "http://swtch.com/plan9port/";
    description = "Plan 9 from User Space";
    license="free";
  };
}


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

assert stdenv.isLinux;

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

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

  buildInputs = [ perl makeWrapper ];

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

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

  meta = {
    description = "Berkeley Lab Checkpoint/Restart for Linux (BLCR)";
    homepage = https://ftg.lbl.gov/projects/CheckpointRestart/;
    license = "GPL2";
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [
      z77z
    ];
  };
}

Add assertion: BLCR do not build on recent kernels

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

assert stdenv.isLinux && builtins.compareVersion kernel.version "2.6.38" != 1;

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

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

  buildInputs = [ perl makeWrapper ];

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

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

  meta = {
    description = "Berkeley Lab Checkpoint/Restart for Linux (BLCR)";
    homepage = https://ftg.lbl.gov/projects/CheckpointRestart/;
    license = "GPL2";
    platforms = stdenv.lib.platforms.linux;
    maintainers = with stdenv.lib.maintainers; [
      z77z
    ];
  };
}


{
  packageOverrides = pkgs: with pkgs; {
    myPackages = pkgs.buildEnv {
      name = "my-packages";
      paths = [
        ag
        appimage-run
        augeas
        (autojump.overrideAttrs (attrs: {
          meta.priority = 3;
        }))
        bridge-utils
        curl
        dnsmasq
        docker
        docker-compose
        file
        fuse
        fzf
        git
        gnused
        gptfdisk
        grml-zsh-config
        homesick
        htop
        inetutils
        less
        lxc
        lxd
        man
        man-pages
        nodejs-11_x
        openssh
        qemu
        rclone
        readline70
        (ruby_2_6.overrideAttrs (attrs: {
          meta.priority = 3;
        }))
        socat
        tig
        tmux
        tree
        (vimHugeX.overrideAttrs (attrs: {
          meta.priority = 3;
        }))
        wget
        xorg.xset
        zsh
        zsh-autosuggestions
        zsh-syntax-highlighting
      ];
    };
  };
}

Add lots of devtools packages

{
  packageOverrides = pkgs: with pkgs; {
    myPackages = pkgs.buildEnv {
      name = "my-packages";
      paths = [
        ag
        appimage-run
        augeas
        (autojump.overrideAttrs (attrs: {
          meta.priority = 3;
        }))
        aws
        bridge-utils
        cloc
        curl
        dnsmasq
        docker
        docker-compose
        file
        fontconfig
        fuse
        fzf
        git
        git-lfs
        gnused
        go
        gptfdisk
        grml-zsh-config
        homesick
        htop
        inetutils
        less
        lxc
        lxd
        man
        man-pages
        ncurses5
        nodejs-11_x
        open-sans
        openbox
        openconnect
        openssh
        papirus-icon-theme
        python
        python3
        qemu
        rclone
        rclone-browser
        readline70
        ripgrep
        rmlint
        (ruby_2_6.overrideAttrs (attrs: {
          meta.priority = 3;
        }))
        s3cmd
        shellcheck
        socat
        sqlite
        terraform
        tig
        tigervnc
        tmux
        tree
        unzip
        vagrant
        (vimHugeX.overrideAttrs (attrs: {
          meta.priority = 3;
        }))
        wget
        xorg.xset
        zip
        zsh
        zsh-autosuggestions
        zsh-syntax-highlighting
      ];
    };
  };
}


{ stdenv
, lib
, fetchFromGitea
, pkg-config
, meson
, ninja
, scdoc
, wayland-protocols
, tllist
, fontconfig
, freetype
, pixman
, libpng
, wayland
, wlroots
, dbus
, fcft
}:

stdenv.mkDerivation rec {
  pname = "fnott";
  version = "1.3.0";

  src = fetchFromGitea {
    domain = "codeberg.org";
    owner = "dnkl";
    repo = "fnott";
    rev = version;
    sha256 = "sha256-6NMMU39v8+Ir3rf7kVwBdEOuYnZC1MqtZnim8+0A7wM=";
  };

  nativeBuildInputs = [
    pkg-config
    meson
    ninja
    scdoc
    wayland-protocols
    tllist
  ];
  buildInputs = [
    fontconfig
    freetype
    pixman
    libpng
    wayland
    wlroots
    dbus
    fcft
  ];

  meta = with lib; {
    homepage = "https://codeberg.org/dnkl/fnott";
    description = "Keyboard driven and lightweight Wayland notification daemon for wlroots-based compositors.";
    license = licenses.mit;
    maintainers = with maintainers; [ polykernel ];
    platforms = platforms.linux;
  };
}

Drop the unnecessary wlroots dependency

{ stdenv
, lib
, fetchFromGitea
, pkg-config
, meson
, ninja
, scdoc
, wayland-protocols
, tllist
, fontconfig
, freetype
, pixman
, libpng
, wayland
, dbus
, fcft
}:

stdenv.mkDerivation rec {
  pname = "fnott";
  version = "1.3.0";

  src = fetchFromGitea {
    domain = "codeberg.org";
    owner = "dnkl";
    repo = "fnott";
    rev = version;
    sha256 = "sha256-6NMMU39v8+Ir3rf7kVwBdEOuYnZC1MqtZnim8+0A7wM=";
  };

  nativeBuildInputs = [
    pkg-config
    meson
    ninja
    scdoc
    wayland-protocols
    tllist
  ];
  buildInputs = [
    fontconfig
    freetype
    pixman
    libpng
    wayland
    dbus
    fcft
  ];

  meta = with lib; {
    homepage = "https://codeberg.org/dnkl/fnott";
    description = "Keyboard driven and lightweight Wayland notification daemon for wlroots-based compositors.";
    license = licenses.mit;
    maintainers = with maintainers; [ polykernel ];
    platforms = platforms.linux;
  };
}


{ stdenv, fetchurl, libX11, pkgconfig, libXext, mesa, libdrm, libXfixes }:

stdenv.mkDerivation rec {
  name = "libva-1.2.1";

  src = fetchurl {
    url = "http://www.freedesktop.org/software/vaapi/releases/libva/${name}.tar.bz2";
    sha1 = "f716a4cadd670b14f44a2e833f96a2c509956339";
  };

  buildInputs = [ libX11 libXext pkgconfig mesa libdrm libXfixes ];

  configureFlags = [ "--enable-glx" ];

  meta = {
    homepage = http://www.freedesktop.org/wiki/Software/vaapi;
    license = "MIT";
    description = "VAAPI library: Video Acceleration API";
  };
}

Revert "libva: update (fix h264encode)"

{ stdenv, fetchurl, libX11, pkgconfig, libXext, mesa, libdrm, libXfixes }:

stdenv.mkDerivation rec {
  name = "libva-1.1.1";

  src = fetchurl {
    url = "http://www.freedesktop.org/software/vaapi/releases/libva/${name}.tar.bz2";
    sha256 = "0kfdcrzcr82g15l0vvmm6rqr0f0604d4dgrza78gn6bfx7rppby0";
  };

  buildInputs = [ libX11 libXext pkgconfig mesa libdrm libXfixes ];

  configureFlags = [ "--enable-glx" ];

  meta = {
    homepage = http://www.freedesktop.org/wiki/Software/vaapi;
    license = "MIT";
    description = "VAAPI library: Video Acceleration API";
  };
}


{ stdenv, fetchurl, cmake, extra-cmake-modules, qt5,
  ki18n, kconfig, kiconthemes, kxmlgui, kwindowsystem,
}:

stdenv.mkDerivation rec {
  pname = "kdbg";
  version = "3.0.1";
  src = fetchurl {
    url = "mirror://sourceforge/kdbg/${version}/${pname}-${version}.tar.gz";
    sha256 = "1gax6xll8svmngw0z1rzhd77xysv01zp0i68x4n5pq0xgh7gi7a4";
  };

  nativeBuildInputs = [ cmake extra-cmake-modules ];
  buildInputs = [ qt5.qtbase ki18n kconfig kiconthemes kxmlgui kwindowsystem ];

  enableParallelBuilding = true;

  meta = with stdenv.lib; {
    homepage = http://www.kdbg.org/;
    description = ''
      A graphical user interface to gdb, the GNU debugger. It provides an
      intuitive interface for setting breakpoints, inspecting variables, and
      stepping through code.
    '';
    license = licenses.gpl2;
    maintainers = [ maintainers.catern ];
  };
}

Add QT pluging path wrapper.

{ stdenv, fetchurl, cmake, extra-cmake-modules, qt5,
  ki18n, kconfig, kiconthemes, kxmlgui, kwindowsystem,
  qtbase, makeWrapper,
}:

stdenv.mkDerivation rec {
  pname = "kdbg";
  version = "3.0.1";
  src = fetchurl {
    url = "mirror://sourceforge/kdbg/${version}/${pname}-${version}.tar.gz";
    sha256 = "1gax6xll8svmngw0z1rzhd77xysv01zp0i68x4n5pq0xgh7gi7a4";
  };

  nativeBuildInputs = [ cmake extra-cmake-modules makeWrapper ];
  buildInputs = [ qt5.qtbase ki18n kconfig kiconthemes kxmlgui kwindowsystem ];

  enableParallelBuilding = true;

  postInstall = ''
    wrapProgram $out/bin/kdbg --prefix QT_PLUGIN_PATH : ${qtbase}/${qtbase.qtPluginPrefix}
  '';

  meta = with stdenv.lib; {
    homepage = http://www.kdbg.org/;
    description = ''
      A graphical user interface to gdb, the GNU debugger. It provides an
      intuitive interface for setting breakpoints, inspecting variables, and
      stepping through code.
    '';
    license = licenses.gpl2;
    maintainers = [ maintainers.catern ];
  };
}


{ stdenv, fetchurl }:

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

  src = fetchurl {
    url = "http://multidimalgorithm.googlecode.com/files/mdds_${version}.tar.bz2";
    sha256 = "1hp0472mcsgzrz1v60jpywxrrqmpb8bchfsi7ydmp6vypqnr646v";
  };

  postInstall = ''
   mkdir -p "$out/lib/pkgconfig"
   cp "$out/share/pkgconfig/"* "$out/lib/pkgconfig"
  '';

  meta = {
    inherit version;
    homepage = https://code.google.com/p/multidimalgorithm/;
    description = "A collection of multi-dimensional data structure and indexing algorithm";
    platforms = stdenv.lib.platforms.all;
  };
}

Fix download URL for mdds

{ stdenv, fetchurl }:

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

  src = fetchurl {
    url = "http://kohei.us/files/mdds/src/mdds_${version}.tar.bz2";
    sha256 = "1hp0472mcsgzrz1v60jpywxrrqmpb8bchfsi7ydmp6vypqnr646v";
  };

  postInstall = ''
   mkdir -p "$out/lib/pkgconfig"
   cp "$out/share/pkgconfig/"* "$out/lib/pkgconfig"
  '';

  meta = {
    inherit version;
    homepage = https://code.google.com/p/multidimalgorithm/;
    description = "A collection of multi-dimensional data structure and indexing algorithm";
    platforms = stdenv.lib.platforms.all;
  };
}


{stdenv, fetchurl, pkgconfig, xlibs, xineLib, libpng, readline, ncurses, curl}:

stdenv.mkDerivation {
  name = "xine-ui-0.99.5";

  src = fetchurl {
    url = mirror://sourceforge/xine/xine-ui-0.99.5.tar.gz;
    sha256 = "07jywadk6fhk3wn1j9m0cfa0zy0i17kz0nyyxwa3shvhznfals0k";
  };

  buildInputs =
    [ pkgconfig xineLib libpng readline ncurses curl
      xlibs.xlibs xlibs.libXext xlibs.libXv xlibs.libXxf86vm xlibs.libXtst xlibs.inputproto
      xlibs.libXinerama xlibs.libXi
    ];

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

  NIX_LDFLAGS = "-lXext -lgcc_s";

  meta = {
    homepage = http://www.xine-project.org/;
    description = "Xlib-based interface to Xine, a video player";
  };
}

Fix xine-ui build - curl dropped curl/types.h

{stdenv, fetchurl, pkgconfig, xlibs, xineLib, libpng, readline, ncurses, curl}:

stdenv.mkDerivation {
  name = "xine-ui-0.99.5";

  src = fetchurl {
    url = mirror://sourceforge/xine/xine-ui-0.99.5.tar.gz;
    sha256 = "07jywadk6fhk3wn1j9m0cfa0zy0i17kz0nyyxwa3shvhznfals0k";
  };

  buildInputs =
    [ pkgconfig xineLib libpng readline ncurses curl
      xlibs.xlibs xlibs.libXext xlibs.libXv xlibs.libXxf86vm xlibs.libXtst xlibs.inputproto
      xlibs.libXinerama xlibs.libXi
    ];

  preBuild = ''
    sed -e '/curl.types.h/d' -i *.c *.h */*.c */*.h */*/*.c */*/*.h
  '';

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

  NIX_LDFLAGS = "-lXext -lgcc_s";

  meta = {
    homepage = http://www.xine-project.org/;
    description = "Xlib-based interface to Xine, a video player";
  };
}


{ stdenv, fetchurl, utillinux }:

stdenv.mkDerivation rec {
  name = "rtirq";
  version = "20210309";

  src = fetchurl {
    urls = ["http://www.rncbc.org/archive/${name}-${version}.tar.gz" "https://www.rncbc.org/archive/old/${name}-${version}.tar.gz" ];
    sha256 = "1z7nfak52g5zgahsdj2iz97q9pxjk2c3xhaa67c14xvzrnxvk0cq";
  };

  phases = [ "unpackPhase" "patchPhase" "installPhase" ];

  patchPhase = ''
    patchShebangs rtirq.sh
    substituteInPlace rtirq.sh \
      --replace "/sbin /usr/sbin /bin /usr/bin /usr/local/bin" "${utillinux}/bin"
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp rtirq.sh $out/bin/rtirq
  '';

  meta = with stdenv.lib; {
    description = "IRQ thread tuning for realtime kernels";
    homepage = http://www.rncbc.org/jack/;
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = with maintainers; [ henrytill ];
  };
}

Update rtirq for building on unstable

{ stdenv, fetchurl, utillinux, lib }:

stdenv.mkDerivation rec {
  name = "rtirq";
  version = "20210309";

  src = fetchurl {
    urls = ["http://www.rncbc.org/archive/${name}-${version}.tar.gz" "https://www.rncbc.org/archive/old/${name}-${version}.tar.gz" ];
    sha256 = "1z7nfak52g5zgahsdj2iz97q9pxjk2c3xhaa67c14xvzrnxvk0cq";
  };

  phases = [ "unpackPhase" "patchPhase" "installPhase" ];

  patchPhase = ''
    patchShebangs rtirq.sh
    substituteInPlace rtirq.sh \
      --replace "/sbin /usr/sbin /bin /usr/bin /usr/local/bin" "${utillinux}/bin"
  '';

  installPhase = ''
    mkdir -p $out/bin
    cp rtirq.sh $out/bin/rtirq
  '';

  meta = with lib; {
    description = "IRQ thread tuning for realtime kernels";
    homepage = http://www.rncbc.org/jack/;
    license = licenses.gpl2;
    platforms = platforms.linux;
    maintainers = with maintainers; [ henrytill ];
  };
}


{
  stdenv, fetchFromGitHub, cmake, extra-cmake-modules,
  zlib, boost, libunwind, elfutils, sparsehash,
  qtbase, kio, kitemmodels, threadweaver, kconfigwidgets, kcoreaddons,
}:

stdenv.mkDerivation rec {
  name = "heaptrack-${version}";
  version = "2018-01-28";

  src = fetchFromGitHub {
    owner = "KDE";
    repo = "heaptrack";
    rev = "a4534d52788ab9814efca1232d402b2eb319342c";
    sha256 = "00xfv51kavvcmwgfmcixx0k5vhd06gkj5q0mm8rwxiw6215xp41a";
  };

  nativeBuildInputs = [ cmake extra-cmake-modules ];
  buildInputs = [
    zlib boost libunwind elfutils sparsehash
    qtbase kio kitemmodels threadweaver kconfigwidgets kcoreaddons
  ];

  meta = with stdenv.lib; {
    description = "Heap memory profiler for Linux";
    homepage = https://github.com/KDE/heaptrack;
    license = licenses.lgpl21Plus;
    maintainers = with maintainers; [ gebner ];
    platforms = platforms.linux;
  };
}

Add dep on kdiagram for chart goodness

{
  stdenv, fetchFromGitHub, cmake, extra-cmake-modules,
  zlib, boost, libunwind, elfutils, sparsehash,
  qtbase, kio, kitemmodels, threadweaver, kconfigwidgets, kcoreaddons, kdiagram
}:

stdenv.mkDerivation rec {
  name = "heaptrack-${version}";
  version = "2018-01-28";

  src = fetchFromGitHub {
    owner = "KDE";
    repo = "heaptrack";
    rev = "a4534d52788ab9814efca1232d402b2eb319342c";
    sha256 = "00xfv51kavvcmwgfmcixx0k5vhd06gkj5q0mm8rwxiw6215xp41a";
  };

  nativeBuildInputs = [ cmake extra-cmake-modules ];
  buildInputs = [
    zlib boost libunwind elfutils sparsehash
    qtbase kio kitemmodels threadweaver kconfigwidgets kcoreaddons kdiagram
  ];

  meta = with stdenv.lib; {
    description = "Heap memory profiler for Linux";
    homepage = https://github.com/KDE/heaptrack;
    license = licenses.lgpl21Plus;
    maintainers = with maintainers; [ gebner ];
    platforms = platforms.linux;
  };
}


{ stdenv
, fetchFromGitHub

, cmake
, ninja
, perl # Project uses Perl for scripting and testing
, python

, enableThreading ? true # Threading can be disabled to increase security https://tls.mbed.org/kb/development/thread-safety-and-multi-threading
}:

stdenv.mkDerivation rec {
  pname = "mbedtls";
  version = "2.17.0";

  src = fetchFromGitHub {
    owner = "ARMmbed";
    repo = "mbedtls";
    rev = "${pname}-${version}";
    sha256 = "1mk3xv61wvqqrzd6jnrz8csyfnwwwwpjzywj3fsfy99p51d7wqgw";
  };

  nativeBuildInputs = [ cmake ninja perl python ];

  postConfigure = stdenv.lib.optionals enableThreading ''
    perl scripts/config.pl set MBEDTLS_THREADING_C    # Threading abstraction layer
    perl scripts/config.pl set MBEDTLS_THREADING_PTHREAD    # POSIX thread wrapper layer for the threading layer.
  '';

  cmakeFlags = [ "-DUSE_SHARED_MBEDTLS_LIBRARY=on" ];

  meta = with stdenv.lib; {
    homepage = https://tls.mbed.org/;
    description = "Portable cryptographic and TLS library, formerly known as PolarSSL";
    license = licenses.asl20;
    platforms = platforms.all;
    maintainers = with maintainers; [ fpletz ];
  };
}

Revert "mbedtls: 2.16.0 -> 2.17.0"

{ stdenv
, fetchFromGitHub

, cmake
, ninja
, perl # Project uses Perl for scripting and testing
, python

, enableThreading ? true # Threading can be disabled to increase security https://tls.mbed.org/kb/development/thread-safety-and-multi-threading
}:

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

  src = fetchFromGitHub {
    owner = "ARMmbed";
    repo = "mbedtls";
    rev = "${pname}-${version}";
    sha256 = "14gw3rga9qr6j8ssfjy7k4l8spz37gamqxh9qcwas7w48303897l";
  };

  nativeBuildInputs = [ cmake ninja perl python ];

  postConfigure = stdenv.lib.optionals enableThreading ''
    perl scripts/config.pl set MBEDTLS_THREADING_C    # Threading abstraction layer
    perl scripts/config.pl set MBEDTLS_THREADING_PTHREAD    # POSIX thread wrapper layer for the threading layer.
  '';

  cmakeFlags = [ "-DUSE_SHARED_MBEDTLS_LIBRARY=on" ];

  meta = with stdenv.lib; {
    homepage = https://tls.mbed.org/;
    description = "Portable cryptographic and TLS library, formerly known as PolarSSL";
    license = licenses.asl20;
    platforms = platforms.all;
    maintainers = with maintainers; [ fpletz ];
  };
}


{ cabal, caseInsensitive, hspec, httpTypes, QuickCheck
, quickcheckInstances
}:

cabal.mkDerivation (self: {
  pname = "http-kit";
  version = "0.2.0";
  sha256 = "0pwcaf52abyjy3jknb7q18j50qd7arz7ck8xffbv9pbp0z7lfd6n";
  buildDepends = [ caseInsensitive httpTypes ];
  testDepends = [ hspec httpTypes QuickCheck quickcheckInstances ];
  meta = {
    description = "A low-level HTTP library";
    license = self.stdenv.lib.licenses.mit;
    platforms = self.ghc.meta.platforms;
  };
})

Update haskell-http-kit to version 0.2.1

{ cabal, caseInsensitive, hspec, httpTypes, QuickCheck
, quickcheckInstances
}:

cabal.mkDerivation (self: {
  pname = "http-kit";
  version = "0.2.1";
  sha256 = "1x3wqjbgs605wrl2dgvszdkvpkfrin4j9azkaa57hza6bgwpidra";
  buildDepends = [ caseInsensitive httpTypes ];
  testDepends = [ hspec httpTypes QuickCheck quickcheckInstances ];
  meta = {
    description = "A low-level HTTP library";
    license = self.stdenv.lib.licenses.mit;
    platforms = self.ghc.meta.platforms;
  };
})


{ stdenv
, buildPythonPackage
, fetchPypi
, isPy3k
, zope_interface
, zope_exceptions
, zope_testing
, six
, subunit
}:

buildPythonPackage rec {
  pname = "zope.testrunner";
  version = "4.7.0";
  name = "${pname}-${version}";

  src = fetchPypi {
    inherit pname version;
    sha256 = "8ffcb4989829544a83d27e42b2eeb28f8fc134bd847d71ce8dca54f710526ef0";
    extension = "zip";
  };

  propagatedBuildInputs = [ zope_interface zope_exceptions zope_testing six ] ++ stdenv.lib.optional (!isPy3k) subunit;

  meta = with stdenv.lib; {
    description = "A flexible test runner with layer support";
    homepage = http://pypi.python.org/pypi/zope.testrunner;
    license = licenses.zpl20;
    maintainers = [ maintainers.goibhniu ];
  };
}

Remove subunit dependency, no longer necessary since latest release

{ stdenv
, buildPythonPackage
, fetchPypi
, isPy3k
, zope_interface
, zope_exceptions
, zope_testing
, six
}:

buildPythonPackage rec {
  pname = "zope.testrunner";
  version = "4.7.0";
  name = "${pname}-${version}";

  src = fetchPypi {
    inherit pname version;
    sha256 = "8ffcb4989829544a83d27e42b2eeb28f8fc134bd847d71ce8dca54f710526ef0";
    extension = "zip";
  };

  propagatedBuildInputs = [ zope_interface zope_exceptions zope_testing six ];

  meta = with stdenv.lib; {
    description = "A flexible test runner with layer support";
    homepage = http://pypi.python.org/pypi/zope.testrunner;
    license = licenses.zpl20;
    maintainers = [ maintainers.goibhniu ];
  };
}


{
  packageOverrides = pkgs: with pkgs; rec {
    myProfile = writeText "my-profile" ''
      export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
      export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
    '';
    myPackages = pkgs.buildEnv {
      name = "my-packages";
      paths = [
        aspell
        coreutils
        jq
        skim
        bat
        xclip
        pass
        elmPackages.elm
        elmPackages.elm-format
        elmPackages.elm-test
        elmPackages.elm-analyse
        elmPackages.elm-language-server
      ];
      pathsToLink = [ "/share" "/bin" "/Applications" ];
      extraOutputsToInstall = [ "man" "doc" ];
    };
  };
}

Add more packages to nix

{
  packageOverrides = pkgs: with pkgs; rec {
    myProfile = writeText "my-profile" ''
      export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
      export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
    '';
    myPackages = pkgs.buildEnv {
      name = "my-packages";
      paths = [
        aspell
        coreutils
        gnupg
        curl
        git
        jq
        skim
        bat
        exa
        tig
        ripgrep
        fd
        tree
        neovim
        stow
        xclip
        pass
        tmux
        alacritty
        elmPackages.elm
        elmPackages.elm-format
        elmPackages.elm-test
        elmPackages.elm-analyse
        elmPackages.elm-language-server
      ];
      pathsToLink = [ "/share" "/bin" "/Applications" ];
      extraOutputsToInstall = [ "man" "doc" ];
    };
  };
}


{ lib, stdenv, fetchFromGitHub, zlib }:

stdenv.mkDerivation rec {
  pname = "simg2img";
  version = "1.1.4";

  src = fetchFromGitHub {
    owner = "anestisb";
    repo = "android-simg2img";
    rev = version;
    sha256 = "1xm9kaqs2w8c7a4psv78gv66gild88mpgjn5lj087d7jh1jxy7bf";
  };

  buildInputs = [ zlib ];

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

  meta = with lib; {
    description = "Tool to convert Android sparse images to raw images";
    homepage = "https://github.com/anestisb/android-simg2img";
    license = licenses.asl20;
    platforms = platforms.linux;
    maintainers = [ maintainers.dezgeg ];
  };
}

Add support for darwin platforms

{ lib, stdenv, fetchFromGitHub, zlib }:

stdenv.mkDerivation rec {
  pname = "simg2img";
  version = "1.1.4";

  src = fetchFromGitHub {
    owner = "anestisb";
    repo = "android-simg2img";
    rev = version;
    sha256 = "1xm9kaqs2w8c7a4psv78gv66gild88mpgjn5lj087d7jh1jxy7bf";
  };

  buildInputs = [ zlib ];

  makeFlags = [ "PREFIX=$(out)" "DEP_CXX:=$(CXX)" ];

  meta = with lib; {
    description = "Tool to convert Android sparse images to raw images";
    homepage = "https://github.com/anestisb/android-simg2img";
    license = licenses.asl20;
    platforms = platforms.unix;
    maintainers = with maintainers; [ dezgeg arkivm ];
  };
}


{ lib
, rustPlatform
, fetchFromGitHub
, nix
, fzy
, makeWrapper
, testVersion
, comma
}:

rustPlatform.buildRustPackage rec {
  pname = "comma";
  version = "1.2.3";

  src = fetchFromGitHub {
    owner = "nix-community";
    repo = "comma";
    rev = "v${version}";
    sha256 = "sha256-emhvBaicLAnu/Kn4oxHngGa5BSxOEwbkhTLO5XvauMw=";
  };

  cargoSha256 = "sha256-mQxNo4VjW2Q0MYfU+RCb4Ayl9ClpxrSV8X4EKZ7PewA=";

  nativeBuildInputs = [ makeWrapper ];

  postInstall = ''
    wrapProgram $out/bin/comma \
      --prefix PATH : ${lib.makeBinPath [ nix fzy ]}
    ln -s $out/bin/comma $out/bin/,
  '';

  passthru.tests = {
    version = testVersion { package = comma; };
  };

  meta = with lib; {
    homepage = "https://github.com/nix-community/comma";
    description = "Runs programs without installing them";
    license = licenses.mit;
    maintainers = with maintainers; [ Enzime artturin ];
    platforms = platforms.all;
  };
}

Fix panic due to missing `nix-index` in path

{ comma
, fetchFromGitHub
, fzy
, lib
, makeWrapper
, nix
, nix-index
, rustPlatform
, testVersion
}:

rustPlatform.buildRustPackage rec {
  pname = "comma";
  version = "1.2.3";

  src = fetchFromGitHub {
    owner = "nix-community";
    repo = "comma";
    rev = "v${version}";
    sha256 = "sha256-emhvBaicLAnu/Kn4oxHngGa5BSxOEwbkhTLO5XvauMw=";
  };

  cargoSha256 = "sha256-mQxNo4VjW2Q0MYfU+RCb4Ayl9ClpxrSV8X4EKZ7PewA=";

  nativeBuildInputs = [ makeWrapper ];

  postInstall = ''
    wrapProgram $out/bin/comma \
      --prefix PATH : ${lib.makeBinPath [ nix fzy nix-index ]}
    ln -s $out/bin/comma $out/bin/,
  '';

  passthru.tests = {
    version = testVersion { package = comma; };
  };

  meta = with lib; {
    homepage = "https://github.com/nix-community/comma";
    description = "Runs programs without installing them";
    license = licenses.mit;
    maintainers = with maintainers; [ Enzime artturin ];
    platforms = platforms.all;
  };
}


{ stdenv

# required for gcc plugins
, gmp, libmpc, mpfr

# the base kernel
, kernel

, grsecPatch
, kernelPatches ? []

, localver ? "-grsec"
, modDirVersion ? "${kernel.version}${localver}"
, extraConfig ? ""
, ...
} @ args:

assert (kernel.version == grsecPatch.kver);

(kernel.override {
  inherit modDirVersion;
  # TODO: unique is a work-around
  kernelPatches = stdenv.lib.unique ([ grsecPatch ] ++ kernelPatches ++ (kernel.kernelPatches or []));
  extraConfig = ''
    GRKERNSEC y
    PAX y
    ${extraConfig}
  '';

  # Enabling grsecurity/PaX deselects several other options implicitly,
  # causing the configfile checker to fail (when it finds that options
  # expected to be enabled are not).
  ignoreConfigErrors = true;
}).overrideAttrs (attrs: {
  nativeBuildInputs = (stdenv.lib.chooseDevOutputs [ gmp libmpc mpfr ]) ++ (attrs.nativeBuildInputs or []);
  preConfigure = ''
    echo ${localver} >localversion-grsec
    ${attrs.preConfigure or ""}
  '';
})

Revert "grsecurity: overrideDerivation -> overrideAttrs"

{ stdenv
, lib
, overrideDerivation

# required for gcc plugins
, gmp, libmpc, mpfr

# the base kernel
, kernel

, grsecPatch
, kernelPatches ? []

, localver ? "-grsec"
, modDirVersion ? "${kernel.version}${localver}"
, extraConfig ? ""
, ...
} @ args:

assert (kernel.version == grsecPatch.kver);

overrideDerivation (kernel.override {
  inherit modDirVersion;
  kernelPatches = lib.unique ([ grsecPatch ] ++ kernelPatches ++ (kernel.kernelPatches or []));
  extraConfig = ''
    GRKERNSEC y
    PAX y
    ${extraConfig}
  '';
  ignoreConfigErrors = true;
}) (attrs: {
  nativeBuildInputs = (lib.chooseDevOutputs [ gmp libmpc mpfr ]) ++ (attrs.nativeBuildInputs or []);
  preConfigure = ''
    echo ${localver} >localversion-grsec
    ${attrs.preConfigure or ""}
  '';
})


{ ... }:

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

Fix fish macOS PATH issue

{ pkgs, ... }:

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


{ lib, fetchFromGitHub, goPackages }:

with goPackages;

buildGoPackage rec {
  rev = "0.2.0";
  name = "bosun-${rev}";
  goPackagePath = "bosun.org";
  src = fetchFromGitHub {
    inherit rev;
    owner = "bosun-monitor";
    repo = "bosun";
    sha256 = "146k37zg4l01l10vwhnhjs6jv8d35zf5l5rljmvy9ydq2npadsjd";
  };
  subPackages = [ "cmd/bosun" ];

  meta = with lib; {
    description = "Time series alerting framework";
    longDescription = ''
      An advanced, open-source monitoring and alerting system by Stack Exchange.
    '';
    homepage = http://bosun.org;
    license = licenses.mit;
    platforms = platforms.unix;
  };
}

Update from 0.2.0 to 0.3.0

{ lib, fetchFromGitHub, goPackages }:

with goPackages;

buildGoPackage rec {
  rev = "0.3.0";
  name = "bosun-${rev}";
  goPackagePath = "bosun.org";
  src = fetchFromGitHub {
    inherit rev;
    owner = "bosun-monitor";
    repo = "bosun";
    sha256 = "05qfhm5ipdry0figa0rhmg93c45dzh2lwpia73pfxp64l1daqa3a";
  };
  subPackages = [ "cmd/bosun" ];

  meta = with lib; {
    description = "Time series alerting framework";
    longDescription = ''
      An advanced, open-source monitoring and alerting system by Stack Exchange.
    '';
    homepage = http://bosun.org;
    license = licenses.mit;
    platforms = platforms.unix;
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation {
  name = "libjpeg-8";

  src = fetchurl {
    url = http://www.ijg.org/files/jpegsrc.v8b.tar.gz;
    sha256 = "19vl6587pyhz45f14yipnsnpni4iz6j0wdzwyblbm4f5vs721rin";
  };

  meta = {
    homepage = http://www.ijg.org/;
    description = "A library that implements the JPEG image file format";
    license = "free";
  };
}

Advance version of libjpeg to 8c.

{ stdenv, fetchurl }:

stdenv.mkDerivation {
  name = "libjpeg-8";

  src = fetchurl {
    url = http://www.ijg.org/files/jpegsrc.v8c.tar.gz;
    sha256 = "16kwrjhziv81gl9fq9b7qir8khm3wfb9zj7fzs7yabsb00z0pz7d";
  };

  meta = {
    homepage = http://www.ijg.org/;
    description = "A library that implements the JPEG image file format";
    license = "free";
  };
}


{stdenv, fetchurl, openssh}:

stdenv.mkDerivation {
	name="autossh-1.4b";
	src = fetchurl {
		url = "http://www.harding.motd.ca/autossh/autossh-1.4b.tgz";
		md5 = "8f9aa006f6f69e912d3c2f504622d6f7";
	};
	buildInputs = [ openssh ];
	installPhase = ''
install -D -m755 autossh      $out/bin/autossh                          || return 1
install -D -m644 CHANGES      $out/share/doc/autossh/CHANGES            || return 1
install -D -m644 README       $out/share/doc/autossh/README             || return 1
install -D -m644 autossh.host $out/share/autossh/examples/autossh.host  || return 1
install -D -m644 rscreen      $out/share/autossh/examples/rscreen       || return 1
install -D -m644 autossh.1    $out/man/man1/autossh.1                   || return 1
	'';
	meta = {
		homepage = http://www.harding.motd.ca/autossh/;
		description = "Automatically restart SSH sessions and tunnels";
	};
}

Fix indentation and add to the channel

{stdenv, fetchurl, openssh}:

stdenv.mkDerivation {
  name = "autossh-1.4b";

  src = fetchurl {
    url = "http://www.harding.motd.ca/autossh/autossh-1.4b.tgz";
    md5 = "8f9aa006f6f69e912d3c2f504622d6f7";
  };

  buildInputs = [ openssh ];

  installPhase =
    ''
      install -D -m755 autossh      $out/bin/autossh                          || return 1
      install -D -m644 CHANGES      $out/share/doc/autossh/CHANGES            || return 1
      install -D -m644 README       $out/share/doc/autossh/README             || return 1
      install -D -m644 autossh.host $out/share/autossh/examples/autossh.host  || return 1
      install -D -m644 rscreen      $out/share/autossh/examples/rscreen       || return 1
      install -D -m644 autossh.1    $out/man/man1/autossh.1                   || return 1
    '';

  meta = {
    homepage = http://www.harding.motd.ca/autossh/;
    description = "Automatically restart SSH sessions and tunnels";
    platforms = stdenv.lib.platforms.linux;
  };
}


{ pkgs, config, ...}:
{
  networking = {
    hostName = "nixos";
    domain = "local";
    search = [ "local" ];
  };

  security.pam.services.sshd.googleAuthenticator.enable = true;

  features = {
    desktop.enable = false;
    desktop.keybase.enable = false;
    cachix.enable = true;
    nodeExporter.enable = false;

    os = {
      boot = {
        uefi = true;
        device = "/dev/sda";
      };

      networkmanager.enable = true;
      externalInterface = "eno2";

      docker.enable = false;

      adminAuthorizedKeys = [
      ];
    };

    lan.enable = false;
  };

  imports = [
    ./.
    ./kernel.nix
    ./hardware-configuration.nix
  ];

}

Add luks and yubikey stanzas

{ pkgs, config, ...}:
{
  networking = {
    hostName = "nixos";
    domain = "local";
    search = [ "local" ];
    firewall.allowedTCPPorts = [];
    firewall.extraCommands = '' '';
  };

  # boot.initrd.luks.devices = {
  #   luksroot = {
  #     device = "/dev/sda1";
  #     preLVM = true;
  #     allowDiscards = true;
  #   };
  # };
  # boot.loader.efi.canTouchEfiVariables = true;

  features = {
    desktop.enable = false;
    desktop.keybase.enable = false;
    cachix.enable = false;

    pki = {
      enable = false;
      certmgr.enable = true;
      certs = {
        foo = { hosts = [ "localhost" ]; };
      };
    };

    os = {
      boot = {
        uefi = true;
        device = "/dev/sda1";
      };

      networkmanager.enable = true;
      externalInterface = "eno2";

      docker.enable = true;

      adminAuthorizedKeys = [
      ];
    };
  };

  services.dnsmasq.enable = false;
  services.dnsmasq.extraConfig = ''
    address=/.cluster.local/10.101.0.1
  '';

  programs.singularity.enable = false;

  hardware.bluetooth.config = {
    General = {
      AutoConnct = true;
      MultiProfile = "multiple";
    };
  };

  services.pcscd.enable = false; # For Yubikey ykman

  security.pam.yubico = {
    enable = false;
    mode = "client"; # "challenge-response";
    id = "";
    control = "sufficient";
  };

  # nix = {
  #    package = pkgs.nixFlakes;
  #    extraOptions = pkgs.lib.optionalString (config.nix.package == pkgs.nixFlakes)
  #      "experimental-features = nix-command flakes";
  # };

  imports = [
    ./.
    ./kernel.nix
    ./hardware-configuration.nix
  ];

}