{ config, pkgs, ... }:

with pkgs.lib;

{
  options = {

    time = {

      timeZone = mkOption {
        default = "CET";
        type = with types; uniq string;
        example = "America/New_York";
        description = "The time zone used when displaying times and dates.";
      };

      hardwareClockInLocalTime = mkOption {
        default = false;
        description = "If set, keep the hardware clock in local time instead of UTC.";
      };

    };
  };

  config = {

    environment.shellInit =
      ''
        export TZDIR=/etc/zoneinfo
      '';

    environment.etc.localtime.source = "${pkgs.tzdata}/share/zoneinfo/${config.time.timeZone}";

    environment.etc.zoneinfo.source = "${pkgs.tzdata}/share/zoneinfo";

  };

}

Set the TZ environment variable, which is used by Java.

{ config, pkgs, ... }:

with pkgs.lib;

{
  options = {

    time = {

      timeZone = mkOption {
        default = "CET";
        type = with types; uniq string;
        example = "America/New_York";
        description = "The time zone used when displaying times and dates.";
      };

      hardwareClockInLocalTime = mkOption {
        default = false;
        description = "If set, keep the hardware clock in local time instead of UTC.";
      };

    };
  };

  config = {

    environment.shellInit =
      ''
        export TZDIR=/etc/zoneinfo
        export TZ=${config.time.timeZone}
      '';

    environment.etc.localtime.source = "${pkgs.tzdata}/share/zoneinfo/${config.time.timeZone}";

    environment.etc.zoneinfo.source = "${pkgs.tzdata}/share/zoneinfo";

  };

}


{ stdenv, fetchurl, perl, texinfo }:

let version = "0.9.24"; in
  stdenv.mkDerivation {
    name = "tinycc-${version}";

    src = fetchurl {
      url = "mirror://savannah/tinycc/tcc-${version}.tar.bz2";
      sha256 = "0yafz627ky0lhppa6g1mfmisnis745m39l15aixmmv5n383x9bi7";
    };

    buildInputs = [ perl texinfo ];

    patchPhase = ''
      substituteInPlace "texi2pod.pl" \
        --replace "/usr/bin/perl" "${perl}/bin/perl"
    '';

    postInstall = ''
      makeinfo --force tcc-doc.texi || true

      ensureDir "$out/share/info"
      mv tcc-doc.info* "$out/share/info"
    '';

    meta = {
      description = "TinyCC, a small, fast, and embeddable C compiler and interpreter";
      homepage = http://www.tinycc.org/;
      license = "LGPLv2+";
    };
  }

Fix crt and loader paths.

{ stdenv, fetchurl, perl, texinfo }:

let version = "0.9.24"; in
  stdenv.mkDerivation {
    name = "tinycc-${version}";

    src = fetchurl {
      url = "mirror://savannah/tinycc/tcc-${version}.tar.bz2";
      sha256 = "0yafz627ky0lhppa6g1mfmisnis745m39l15aixmmv5n383x9bi7";
    };

    buildInputs = [ perl texinfo ];

    patchPhase = ''
      substituteInPlace "texi2pod.pl" \
        --replace "/usr/bin/perl" "${perl}/bin/perl"

      # To produce executables, `tcc' needs to know where `crt*.o' are.
      sed -i "tcc.c" \
        -e's|define CONFIG_TCC_CRT_PREFIX.*$|define CONFIG_TCC_CRT_PREFIX "${stdenv.glibc}/lib"|g ;
           s|tcc_add_library_path(s, "/usr/lib");|tcc_add_library_path(s, "${stdenv.glibc}/lib");|g'

      # Tell it about the loader's location.
      sed -i "tccelf.c" \
        -e's|".*/ld-linux\([^"]\+\)"|"${stdenv.glibc}/lib/ld-linux\1"|g'
    '';

    postInstall = ''
      makeinfo --force tcc-doc.texi || true

      ensureDir "$out/share/info"
      mv tcc-doc.info* "$out/share/info"
    '';

    meta = {
      description = "TinyCC, a small, fast, and embeddable C compiler and interpreter";
      homepage = http://www.tinycc.org/;
      license = "LGPLv2+";
    };
  }


{ fetchurl, buildPythonPackage }:

buildPythonPackage {
  name = "offlineimap-6.2.0.2";

  src = fetchurl {
    url = "http://ftp.de.debian.org/debian/pool/main/o/offlineimap/offlineimap_6.2.0.2.orig.tar.gz";
    sha256 = "1w69qv1dm37m53k8cd068lk5z3qjlscnjxr397gs8kdsfds67v7c";
  };

  doCheck = false;

  meta = {
    description = "IMAP to local files bridge";
    homepage = "http://software.complete.org/software/projects/show/offlineimap";
    license = "GPLv2+";
  };
}

Update offlineimap to 6.5.3. Patch by garbas.

{ fetchurl, buildPythonPackage }:

buildPythonPackage rec {
  version = "6.5.3";
  name = "offlineimap-${version}";

  src = fetchurl {
    url = "https://github.com/spaetz/offlineimap/tarball/v${version}";
    name = "${name}.tar.bz";
    sha256 = "8717a56e6244b47b908b23b598efb3470d74450ecd881b6d3573d8aec4a5db38";
  };

  doCheck = false;

  meta = {
    description = "OfflineImap synchronizes emails between two repositories, so that you can read the same mailbox from multiple computers.";
    homepage = "http://offlineimap.org";
    license = "GPLv2+";
  };
}


{ cabal, alex, exceptionMtl, exceptionTransformers, filepath, happy
, haskellSrcMeta, mainlandPretty, mtl, srcloc, syb, symbol
}:

cabal.mkDerivation (self: {
  pname = "language-c-quote";
  version = "0.4.0";
  sha256 = "1qbl81c8fw2gz96n8505yxhw1d3zhxq436ikv173x1zz0b4z26g1";
  buildDepends = [
    exceptionMtl exceptionTransformers filepath haskellSrcMeta
    mainlandPretty mtl srcloc syb symbol
  ];
  buildTools = [ alex happy ];
  meta = {
    homepage = "http://www.eecs.harvard.edu/~mainland/";
    description = "C/CUDA/OpenCL quasiquoting library";
    license = self.stdenv.lib.licenses.bsd3;
    platforms = self.ghc.meta.platforms;
    maintainers = [ self.stdenv.lib.maintainers.andres ];
  };
})

Revert "haskell-language-c-quote: update to version 0.4.0"

{ cabal, alex, exceptionMtl, exceptionTransformers, filepath, happy
, haskellSrcMeta, mainlandPretty, mtl, srcloc, syb, symbol
}:

cabal.mkDerivation (self: {
  pname = "language-c-quote";
  version = "0.3.2";
  sha256 = "1pxrag9ws93rsqrsxcyxg07pvp2qw0f19yj2b40ynwzk112nkd16";
  buildDepends = [
    exceptionMtl exceptionTransformers filepath haskellSrcMeta
    mainlandPretty mtl srcloc syb symbol
  ];
  buildTools = [ alex happy ];
  meta = {
    homepage = "http://www.eecs.harvard.edu/~mainland/";
    description = "C/CUDA/OpenCL quasiquoting library";
    license = self.stdenv.lib.licenses.bsd3;
    platforms = self.ghc.meta.platforms;
    maintainers = [ self.stdenv.lib.maintainers.andres ];
  };
})


{ nixpkgs ? import <nixpkgs> {}
, ghc ? nixpkgs.haskell.compiler.ghc7103   # Default needed for Docker build.
}:

with nixpkgs;

let
  spark = nixpkgs.spark.override { mesosSupport = false; };
  openjdk = openjdk8;
  jvmlibdir =
    if stdenv.isLinux
    then "${openjdk}/lib/openjdk/jre/lib/amd64/server"
    else "${openjdk}/jre/lib/server";
in
haskell.lib.buildStackProject {
  name = "sparkle";
  buildInputs =
    [ git
      gradle
      ncurses5 # For intero
      openjdk
      spark
      which
      zlib
      zip
    ];
  inherit ghc;
  extraArgs = ["--extra-lib-dirs=${jvmlibdir}"];
  # XXX Workaround https://ghc.haskell.org/trac/ghc/ticket/11042.
  LD_LIBRARY_PATH = [jvmlibdir];
  # XXX By default recent Nixpkgs passes hardening flags to the
  # linker. The bindnow hardening flag is problematic, because it
  # makes objects fail to load in GHCi, with strange errors about
  # undefined symbols. See
  # https://ghc.haskell.org/trac/ghc/ticket/12684. As a workaround,
  # disable bindnow for now.
  hardeningDisable = [ "bindnow" ];
  LANG = "en_US.utf8";
}

Make Wercker use GHC 8.0.2 too.

{ nixpkgs ? import <nixpkgs> {}
, ghc ? nixpkgs.haskell.compiler.ghc802 # Default needed for Docker build.
}:

with nixpkgs;

let
  spark = nixpkgs.spark.override { mesosSupport = false; };
  openjdk = openjdk8;
  jvmlibdir =
    if stdenv.isLinux
    then "${openjdk}/lib/openjdk/jre/lib/amd64/server"
    else "${openjdk}/jre/lib/server";
in
haskell.lib.buildStackProject {
  name = "sparkle";
  buildInputs =
    [ git
      gradle
      ncurses5 # For intero
      openjdk
      spark
      which
      zlib
      zip
    ];
  inherit ghc;
  extraArgs = ["--extra-lib-dirs=${jvmlibdir}"];
  # XXX Workaround https://ghc.haskell.org/trac/ghc/ticket/11042.
  LD_LIBRARY_PATH = [jvmlibdir];
  # XXX By default recent Nixpkgs passes hardening flags to the
  # linker. The bindnow hardening flag is problematic, because it
  # makes objects fail to load in GHCi, with strange errors about
  # undefined symbols. See
  # https://ghc.haskell.org/trac/ghc/ticket/12684. As a workaround,
  # disable bindnow for now.
  hardeningDisable = [ "bindnow" ];
  LANG = "en_US.utf8";
}


{ cabal, fuse }:

cabal.mkDerivation (self: {
  pname = "HFuse";
  version = "0.2.4.1";
  sha256 = "12k04dvh92kk2i68bcb70xnk378qxmh46f241k06di5rkcgwyg1k";
  extraLibraries = [ fuse ];

  preConfigure = ''
    sed -i -e "s@  Extra-Lib-Dirs:         /usr/local/lib@  Extra-Lib-Dirs:         ${fuse}/lib@" HFuse.cabal
  '';

  meta = {
    homepage = "https://github.com/toothbrush/hfuse";
    description = "HFuse is a binding for the Linux FUSE library";
    license = self.stdenv.lib.licenses.bsd3;
    platforms = self.ghc.meta.platforms;
    maintainers = [
      self.stdenv.lib.maintainers.andres
    ];
  };
})

Fix HFuse compilation with GHC 7.6.3

{ cabal, fuse }:

cabal.mkDerivation (self: {
  pname = "HFuse";
  version = "0.2.4.1";
  sha256 = "12k04dvh92kk2i68bcb70xnk378qxmh46f241k06di5rkcgwyg1k";
  extraLibraries = [ fuse ];

  preConfigure = ''
    sed -i -e "s@  Extra-Lib-Dirs:         /usr/local/lib@  Extra-Lib-Dirs:         ${fuse}/lib@" HFuse.cabal
    sed -i -e "s/LANGUAGE FlexibleContexts/LANGUAGE FlexibleContexts, RankNTypes/" System/Fuse.hsc
    sed -i -e "s/E(Exception/E(catch, Exception, IOException/" System/Fuse.hsc
    sed -i -e "s/IO(catch,/IO(/" System/Fuse.hsc
    sed -i -e "s/IO.catch/ E.catch/" System/Fuse.hsc
    sed -i -e "s/const exitFailure/\\\\(_ :: IOException) -> exitFailure/" System/Fuse.hsc
  '';

  meta = {
    homepage = "https://github.com/toothbrush/hfuse";
    description = "HFuse is a binding for the Linux FUSE library";
    license = self.stdenv.lib.licenses.bsd3;
    platforms = self.ghc.meta.platforms;
    maintainers = [
      self.stdenv.lib.maintainers.andres
    ];
  };
})


{ stdenv
, buildPythonPackage
, fetchPypi
, six
, requests
, setuptools
, pytest
, mock
}:

buildPythonPackage rec {
  pname = "google-resumable-media";
  version = "0.5.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "0aldswz9lsw05a2gx26yjal6lcxhfqpn085zk1czvjz1my4d33ra";
  };

  checkInputs = [ pytest mock ];
  propagatedBuildInputs = [ requests setuptools six ];

  checkPhase = ''
    py.test tests/unit
  '';

  meta = with stdenv.lib; {
    description = "Utilities for Google Media Downloads and Resumable Uploads";
    homepage = https://github.com/GoogleCloudPlatform/google-resumable-media-python;
    license = licenses.asl20;
    maintainers = [ maintainers.costrouc ];
  };
}

Revert "python38Packages.google_resumable_media: 0.4.1 -> 0.5.0"

{ stdenv
, buildPythonPackage
, fetchPypi
, six
, requests
, setuptools
, pytest
, mock
}:

buildPythonPackage rec {
  pname = "google-resumable-media";
  version = "0.4.1";

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

  checkInputs = [ pytest mock ];
  propagatedBuildInputs = [ requests setuptools six ];

  checkPhase = ''
    py.test tests/unit
  '';

  meta = with stdenv.lib; {
    description = "Utilities for Google Media Downloads and Resumable Uploads";
    homepage = https://github.com/GoogleCloudPlatform/google-resumable-media-python;
    license = licenses.asl20;
    maintainers = [ maintainers.costrouc ];
  };
}


{
  test1 = import ../configurations/test-vm1.nix;
  test2 = import ../configurations/test-vm2-mysql.nix;
  #test3 = import ../configurations/test-vm3-client.nix;
}

Enable client machine by default

{
  test1 = import ../configurations/test-vm1.nix;
  test2 = import ../configurations/test-vm2-mysql.nix;
  test3 = import ../configurations/test-vm3-client.nix;
}


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

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

Add patch to fix tests.

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

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

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

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


{ stdenv, fetchFromGitHub, libav, libkeyfinder }:

stdenv.mkDerivation rec {
  version = "20150125";
  name = "keyfinder-cli-${version}";

  src = fetchFromGitHub {
    repo = "keyfinder-cli";
    owner = "EvanPurkhiser";
    rev = "3a6f598b3661fdba73ada81cd200a6e56c23ddca";
    sha256 = "05k4g9zdzi4q81p8lax9b2j4bcg1bpp04sdbza5i5pfz2fng2cf7";
  };

  meta = with stdenv.lib; {
    description = "Musical key detection for digital audio (command-line tool)";
    longDescription = ''
      This small utility is the automation-oriented DJ's best friend. By making
      use of Ibrahim Sha'ath's high quality libKeyFinder library, it can be
      used to estimate the musical key of many different audio formats.
    '';
    homepage = https://github.com/EvanPurkhiser/keyfinder-cli;
    license = with licenses; gpl3Plus;
    platforms = with platforms; linux;
    maintainers = with maintainers; [ nckx ];
  };

  buildInputs = [ libav libkeyfinder ];

  makeFlagsArray = "PREFIX=$(out)";

  enableParallelBuilding = true;
}

Update keyfinder-cli 20150125 -> 20150130

{ stdenv, fetchFromGitHub, libav, libkeyfinder }:

let version = "20150130"; in
stdenv.mkDerivation rec {
  name = "keyfinder-cli-${version}";

  src = fetchFromGitHub {
    repo = "keyfinder-cli";
    owner = "EvanPurkhiser";
    rev = "e8a20e73f8a465a6c3c9e71dabf4b636244a9b0c";
    sha256 = "0x198ijr6wgzq24642s4pz5zxn4gvcc7dxmb6d1bfn3dwzi3j8lp";
  };

  meta = with stdenv.lib; {
    description = "Musical key detection for digital audio (command-line tool)";
    longDescription = ''
      This small utility is the automation-oriented DJ's best friend. By making
      use of Ibrahim Sha'ath's high quality libKeyFinder library, it can be
      used to estimate the musical key of many different audio formats.
    '';
    homepage = https://github.com/EvanPurkhiser/keyfinder-cli;
    license = with licenses; gpl3Plus;
    platforms = with platforms; linux;
    maintainers = with maintainers; [ nckx ];
  };

  buildInputs = [ libav libkeyfinder ];

  makeFlagsArray = "PREFIX=$(out)";

  enableParallelBuilding = true;
}


{ lib, stdenv, buildPackages, fetchurl, pciutils }:

with lib;

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

  src = fetchurl {
    url = "mirror://sourceforge/gnu-efi/${pname}-${version}.tar.bz2";
    sha256 = "sha256-L8z3FSecRu5pxIWRhq+BUNB6E/TRmHblRZzWW+gtO30=";
  };

  buildInputs = [ pciutils ];

  hardeningDisable = [ "stackprotector" ];

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

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

Revert "gnu-efi: 3.0.11 -> 3.0.13"

{ lib, stdenv, buildPackages, fetchurl, fetchpatch, pciutils }:

with lib;

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

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

  patches = [
    # Fix build on armv6l
    (fetchpatch {
      url = "https://sourceforge.net/p/gnu-efi/patches/_discuss/thread/25bb273a18/9c4d/attachment/0001-Fix-ARCH-on-armv6-and-other-32-bit-ARM-platforms.patch";
      sha256 = "0pj03h20g2bbz6fr753bj1scry6919h57l1h86z3b6q7hqfj0b4r";
    })
  ];

  buildInputs = [ pciutils ];

  hardeningDisable = [ "stackprotector" ];

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

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


{stdenv, fetchgit, which, cryptopp, ocaml, findlib, ocaml_react, ocaml_ssl, libev, pkgconfig, ncurses, ocaml_oasis, ocaml_text, glib}:

let
  version = "2.4.5";
in

stdenv.mkDerivation {

  name = "ocaml-lwt-${version}";

  src = fetchgit {
    url = git://github.com/ocsigen/lwt;
    rev = "refs/tags/${version}";
    sha256 = "2bbf4f216dd62eeb765a89413f3b2b6d417a9c289ca49d595bb4d7a0545e343e";
  };

  buildInputs = [ocaml_oasis pkgconfig which cryptopp ocaml findlib ocaml_react ocaml_ssl libev ncurses ocaml_text glib];

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

  createFindlibDestdir = true;

  meta = {
    homepage = http://ocsigen.org/lwt;
    description = "Lightweight thread library for Objective Caml";
    license = "LGPL";
    platforms = ocaml.meta.platforms;
    maintainers = [
      stdenv.lib.maintainers.z77z stdenv.lib.maintainers.gal_bolle
    ];
  };
}

Use propagated inputs in lwt

{stdenv, fetchgit, which, cryptopp, ocaml, findlib, ocaml_react, ocaml_ssl, libev, pkgconfig, ncurses, ocaml_oasis, ocaml_text, glib}:

let
  version = "2.4.5";
in

stdenv.mkDerivation {

  name = "ocaml-lwt-${version}";

  src = fetchgit {
    url = git://github.com/ocsigen/lwt;
    rev = "refs/tags/${version}";
    sha256 = "2bbf4f216dd62eeb765a89413f3b2b6d417a9c289ca49d595bb4d7a0545e343e";
  };

  buildInputs = [ocaml_oasis pkgconfig which cryptopp ocaml findlib glib libev ncurses];

  propagatedBuildInputs = [ ocaml_react ocaml_ssl ocaml_text ];

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

  createFindlibDestdir = true;

  meta = {
    homepage = http://ocsigen.org/lwt;
    description = "Lightweight thread library for Objective Caml";
    license = "LGPL";
    platforms = ocaml.meta.platforms;
    maintainers = [
      stdenv.lib.maintainers.z77z stdenv.lib.maintainers.gal_bolle
    ];
  };
}


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

let
  cfg = config.disnixInfrastructure;
in
{
  options = {
    disnixInfrastructure = {
      enable = lib.mkOption {
        default = false;
        description = "Whether to enable infrastructure publishing";
      };

      enableAuthentication = lib.mkOption {
        default = false;
        description = "Whether to publish authentication credentials through the infrastructure attribute (not recommended in combination with Avahi)";
      };

      infrastructure = lib.mkOption {
        default = {};
        description = "An attribute set containing infrastructure model properties";
      };

      properties = lib.mkOption {
        default = {};
        description = "An attribute set container arbitary machine properties";
      };

      generateContainersExpr = lib.mkOption {
        description = "The path to the expression generating the container properties";
        type = lib.types.path;
      };
    };
  };

  config = lib.mkIf cfg.enable {
    disnixInfrastructure.infrastructure = {
      properties = {
        hostname = config.networking.hostName;
      } // cfg.properties;

      system = if config.nixpkgs.system == "" then builtins.currentSystem else config.nixpkgs.system;

      containers = import cfg.generateContainersExpr {
        inherit (cfg) enableAuthentication;
        inherit config lib;
      };
    };
  };
}

Use the extraContainerProperties if possible

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

let
  cfg = config.disnixInfrastructure;
in
{
  options = {
    disnixInfrastructure = {
      enable = lib.mkOption {
        default = false;
        description = "Whether to enable infrastructure publishing";
      };

      enableAuthentication = lib.mkOption {
        default = false;
        description = "Whether to publish authentication credentials through the infrastructure attribute (not recommended in combination with Avahi)";
      };

      infrastructure = lib.mkOption {
        default = {};
        description = "An attribute set containing infrastructure model properties";
      };

      properties = lib.mkOption {
        default = {};
        description = "An attribute set container arbitary machine properties";
      };

      generateContainersExpr = lib.mkOption {
        description = "The path to the expression generating the container properties";
        type = lib.types.path;
      };
    };
  };

  config = lib.mkIf cfg.enable {
    disnixInfrastructure.infrastructure = {
      properties = {
        hostname = config.networking.hostName;
      } // cfg.properties;

      system = if config.nixpkgs.system == "" then builtins.currentSystem else config.nixpkgs.system;

      containers = lib.recursiveUpdate (import cfg.generateContainersExpr {
        inherit (cfg) enableAuthentication;
        inherit config lib;
      }) (config.dysnomia.extraContainerProperties or {});
    };
  };
}


{system, pkgs}:

rec {
### Databases

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

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

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

### Web services + Clients

  GeolocationService = import ../pkgs/webservices/GeolocationService {
    inherit (pkgs) dotnetenv;
  };

  RoomService = import ../pkgs/webservices/RoomService {
    inherit (pkgs) dotnetenv;
  };

  StaffService = import ../pkgs/webservices/StaffService {
    inherit (pkgs) dotnetenv;
  };

  ZipcodeService = import ../pkgs/webservices/ZipcodeService {
    inherit (pkgs) dotnetenv;
  };

### Web applications

  StaffTracker = import ../pkgs/webapplications/StaffTracker {
    inherit (pkgs) dotnetenv;
  };
}

Use callPackage for the top-level composition expression

{system, pkgs}:

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

  self = {
    ### Databases

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

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

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

    ### Web services + Clients

    GeolocationService = callPackage ../pkgs/webservices/GeolocationService { };

    RoomService = callPackage ../pkgs/webservices/RoomService { };

    StaffService = callPackage ../pkgs/webservices/StaffService { };

    ZipcodeService = callPackage ../pkgs/webservices/ZipcodeService { };

    ### Web applications

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


fetchTarball {
  url = "https://github.com/NixOS/nixpkgs/archive/3140fa89c51233397f496f49014f6b23216667c2.tar.gz";
  sha256 = "18p0d5lnfvzsyfah02mf6bi249990pfwnylwhqdh8qi70ncrk3f8";
}

Upgrade to latest commit in nixos-unstable channel

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


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "libsodium-1.0.17";

  src = fetchurl {
    url = "https://download.libsodium.org/libsodium/releases/${name}.tar.gz";
    sha256 = "1cf2d9v1gylz1qcy2zappbf526qfmph6gd6fnn3w2b347vixmhqc";
  };

  outputs = [ "out" "dev" ];
  separateDebugInfo = stdenv.isLinux;

  enableParallelBuilding = true;

  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; [ raskin ];
    platforms = platforms.all;
  };
}

Revert "libsodium: 1.0.16 -> 1.0.17"

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "libsodium-1.0.16";

  src = fetchurl {
    url = "https://download.libsodium.org/libsodium/releases/${name}.tar.gz";
    sha256 = "0cq5pn7qcib7q70mm1lgjwj75xdxix27v0xl1xl0kvxww7hwgbgf";
  };

  outputs = [ "out" "dev" ];
  separateDebugInfo = stdenv.isLinux;

  enableParallelBuilding = true;

  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; [ raskin ];
    platforms = platforms.all;
  };
}


{ stdenv, fetchurl, unzip }:

stdenv.mkDerivation rec {
  name = "fira-mono-3.2";

  src = fetchurl {
    url = http://www.carrois.com/downloads/fira_mono_3_2/FiraMonoFonts3200.zip;
    sha256 = "0g3i54q8czf3vylgasj62w2n7l1a2yrbyibjlx1qk3awh7fr1r7p";
  };

  buildInputs = [ unzip ];
  phases = [ "unpackPhase" "installPhase" ];
  sourceRoot = "FiraMonoFonts3200";

  installPhase = ''
    mkdir -p $out/share/fonts/opentype
    find . -name "*.otf" -exec cp -v {} $out/share/fonts/opentype \;
  '';

  meta = with stdenv.lib; {
    homepage = http://www.carrois.com/fira-4-1/;
    description = "Monospace font for Firefox OS";
    longDescription = ''
      Fira Mono is a monospace font designed by Erik Spiekermann,
      Ralph du Carrois, Anja Meiners and Botio Nikoltchev of Carrois
      Type Design for Mozilla Firefox OS. Available in Regular,
      Medium, and Bold.
    '';
    license = licenses.ofl;
    maintainers = [ maintainers.rycee ];
    platforms = platforms.all;
  };
}

Update package 'fira-mono' to version 3.203.

{ stdenv, fetchurl, unzip }:

stdenv.mkDerivation rec {
  name = "fira-mono-3.203";

  src = fetchurl {
    url = http://www.carrois.com/downloads/fira_mono_3_2/FiraMonoFonts3203.zip;
    sha256 = "0qaplpmsqys42a49x8d15ca2gqw1v6a6k2d56ja1j38dmr2qmpv4";
  };

  buildInputs = [ unzip ];
  phases = [ "unpackPhase" "installPhase" ];
  sourceRoot = "FiraMonoFonts3203";

  installPhase = ''
    mkdir -p $out/share/fonts/opentype
    find . -name "*.otf" -exec cp -v {} $out/share/fonts/opentype \;
  '';

  meta = with stdenv.lib; {
    homepage = http://www.carrois.com/fira-4-1/;
    description = "Monospace font for Firefox OS";
    longDescription = ''
      Fira Mono is a monospace font designed by Erik Spiekermann,
      Ralph du Carrois, Anja Meiners and Botio Nikoltchev of Carrois
      Type Design for Mozilla Firefox OS. Available in Regular,
      Medium, and Bold.
    '';
    license = licenses.ofl;
    maintainers = [ maintainers.rycee ];
    platforms = platforms.all;
  };
}


let
  lists = import ./lists.nix;
in
rec {
  linux = ["i686-linux" "x86_64-linux" "powerpc-linux"];
  darwin = ["i686-darwin" "powerpc-darwin"];
  freebsd = ["i686-freebsd" "x86_64-freebsd" "powerpc-freebsd"];
  cygwin = ["i686-cygwin"];
  all = linux ++ darwin ++ cygwin ++ freebsd;
  allBut = platform: lists.filter (x: platform != x) all;
}

Add `gnu' as an alias for `linux'.

let
  lists = import ./lists.nix;
in
rec {
  gnu = linux;  /* ++ hurd ++ kfreebsd ++ ... */
  linux = ["i686-linux" "x86_64-linux" "powerpc-linux"];
  darwin = ["i686-darwin" "powerpc-darwin"];
  freebsd = ["i686-freebsd" "x86_64-freebsd" "powerpc-freebsd"];
  cygwin = ["i686-cygwin"];
  all = linux ++ darwin ++ cygwin ++ freebsd;
  allBut = platform: lists.filter (x: platform != x) all;
}


let
  pkgs = import <nixpkgs> {};
in
pkgs.mkShell {
  buildInputs = with pkgs; [
    nodejs
    poetry
    rsync
  ];
  shellHook = ''
    export SOURCE_DATE_EPOCH=315532800
  '';
}

Add libffi, needed for building keyring

let
  pkgs = import <nixpkgs> {};
in
pkgs.mkShell {
  buildInputs = with pkgs; [
    libffi
    nodejs
    poetry
    rsync
  ];
  shellHook = ''
    export SOURCE_DATE_EPOCH=315532800
  '';
}


{ lib, stdenv, fetchFromGitHub
, meson, ninja, pkg-config, scdoc, wayland-scanner
, wayland, wayland-protocols, ffmpeg, x264, libpulseaudio, ocl-icd, opencl-headers
}:

stdenv.mkDerivation rec {
  pname = "wf-recorder";
  version = "0.2.1";

  src = fetchFromGitHub {
    owner = "ammen99";
    repo = pname;
    rev = "v${version}";
    sha256 = "1cw6kpcbl33wh95pvy32xrsrm6kkk1awccr3phyh885xjs3b3iim";
  };

  nativeBuildInputs = [ meson ninja pkg-config wayland-scanner scdoc ];
  buildInputs = [
    wayland wayland-protocols ffmpeg x264 libpulseaudio ocl-icd opencl-headers
  ];

  meta = with lib; {
    description = "Utility program for screen recording of wlroots-based compositors";
    inherit (src.meta) homepage;
    changelog = "https://github.com/ammen99/wf-recorder/releases/tag/v${version}";
    license = licenses.mit;
    maintainers = with maintainers; [ primeos CrazedProgrammer ];
    platforms = platforms.linux;
  };
}

Remove myself and CrazedProgrammer as maintainers

{ lib, stdenv, fetchFromGitHub
, meson, ninja, pkg-config, scdoc, wayland-scanner
, wayland, wayland-protocols, ffmpeg, x264, libpulseaudio, ocl-icd, opencl-headers
}:

stdenv.mkDerivation rec {
  pname = "wf-recorder";
  version = "0.2.1";

  src = fetchFromGitHub {
    owner = "ammen99";
    repo = pname;
    rev = "v${version}";
    sha256 = "1cw6kpcbl33wh95pvy32xrsrm6kkk1awccr3phyh885xjs3b3iim";
  };

  nativeBuildInputs = [ meson ninja pkg-config wayland-scanner scdoc ];
  buildInputs = [
    wayland wayland-protocols ffmpeg x264 libpulseaudio ocl-icd opencl-headers
  ];

  meta = with lib; {
    description = "Utility program for screen recording of wlroots-based compositors";
    inherit (src.meta) homepage;
    changelog = "https://github.com/ammen99/wf-recorder/releases/tag/v${version}";
    license = licenses.mit;
    maintainers = with maintainers; [ ];
    platforms = platforms.linux;
  };
}


{ fetchFromGitHub
, cargo
, lib
, rustPlatform

}:

rustPlatform.buildRustPackage rec {
  pname = "ptags";
  version = "0.3.2";

  src = fetchFromGitHub {
    owner = "dalance";
    repo = "ptags";
    rev = "v${version}";
    sha256 = "1xr1szh4dfrcmi6s6dj791k1ix2zbv75rqkqbyb1lmh5548kywkg";
  };

  cargoSha256 = "1pz5hvn1iq26i8c2cmqavhnri8h0sn40khrxvcdkj9q47nsj5wcx";

  # Sanity check.
  checkPhase = ''
    $releaseDir/ptags --help > /dev/null
  '';

  meta = with lib; {
    description = "A parallel universal-ctags wrapper for git repository";
    homepage = "https://github.com/dalance/ptags";
    maintainers = with maintainers; [ pamplemousse ];
    license = licenses.mit;
  };
}

Add `ctags` to the PATH

{ fetchFromGitHub
, cargo
, ctags
, lib
, makeWrapper
, rustPlatform
}:

rustPlatform.buildRustPackage rec {
  pname = "ptags";
  version = "0.3.2";

  src = fetchFromGitHub {
    owner = "dalance";
    repo = "ptags";
    rev = "v${version}";
    sha256 = "1xr1szh4dfrcmi6s6dj791k1ix2zbv75rqkqbyb1lmh5548kywkg";
  };

  cargoSha256 = "1pz5hvn1iq26i8c2cmqavhnri8h0sn40khrxvcdkj9q47nsj5wcx";

  nativeBuildInputs = [ makeWrapper ];

  postInstall = ''
    # `ctags` must be accessible in `PATH` for `ptags` to work.
    wrapProgram "$out/bin/ptags" \
      --prefix PATH : "${lib.makeBinPath [ ctags ]}"
  '';

  # Sanity check.
  checkPhase = ''
    $releaseDir/ptags --help > /dev/null
  '';

  meta = with lib; {
    description = "A parallel universal-ctags wrapper for git repository";
    homepage = "https://github.com/dalance/ptags";
    maintainers = with maintainers; [ pamplemousse ];
    license = licenses.mit;
  };
}


{ fetchurl, stdenv }:

stdenv.mkDerivation rec {
  name = "lightning-1.2c";

  src = fetchurl {
    url = "ftp://alpha.gnu.org/gnu/lightning/${name}.tar.gz";
    sha256 = "00ss2b75msj4skkda9fs5df3bfpi8bwbckci8g0pwd3syppb3qdl";
  };

  doCheck = true;

  meta = {
    homepage = http://www.gnu.org/software/lightning/;
    description = "GNU lightning, a run-time code generation library";

    longDescription = ''
      GNU lightning is a library that generates assembly language code
      at run-time; it is very fast, making it ideal for Just-In-Time
      compilers, and it abstracts over the target CPU, as it exposes
      to the clients a standardized RISC instruction set inspired by
      the MIPS and SPARC chips.
    '';

    license = "LGPLv3+";
  };
}

Update GNU lightning to 2.0.4

{ fetchurl, stdenv, binutils }:

stdenv.mkDerivation rec {
  name = "lightning-2.0.4";

  src = fetchurl {
    url = "ftp://alpha.gnu.org/gnu/lightning/${name}.tar.gz";
    sha256 = "1lrckrx51d5hrv66bc99fd4b7g2wwn4vr304hwq3glfzhb8jqcdy";
  };

  # Needs libopcodes.so  from binutils for 'make check'
  buildInputs = [ binutils ];

  doCheck = true;

  meta = {
    homepage = http://www.gnu.org/software/lightning/;
    description = "GNU lightning, a run-time code generation library";

    longDescription = ''
      GNU lightning is a library that generates assembly language code
      at run-time; it is very fast, making it ideal for Just-In-Time
      compilers, and it abstracts over the target CPU, as it exposes
      to the clients a standardized RISC instruction set inspired by
      the MIPS and SPARC chips.
    '';

    license = "LGPLv3+";
  };
}


{ stdenv, buildPythonPackage, fetchPypi, python
, gfortran, glibcLocales, joblib, pythonOlder
, numpy, scipy, pytest, pillow, cython
}:

buildPythonPackage rec {
  pname = "scikit-learn";
  version = "0.21.2";
  # UnboundLocalError: local variable 'message' referenced before assignment
  disabled = stdenv.isi686 || (pythonOlder "3.5");  # https://github.com/scikit-learn/scikit-learn/issues/5534

  src = fetchPypi {
    inherit pname version;
    sha256 = "0aafc312a55ebf58073151b9308761a5fcfa45b7f7730cea4b1f066f824c72db";
  };

  buildInputs = [ pillow gfortran glibcLocales ];
  propagatedBuildInputs = [ numpy scipy numpy.blas joblib ];
  checkInputs = [ pytest ];
  nativeBuildInputs = [ cython ];

  LC_ALL="en_US.UTF-8";

  doCheck = !stdenv.isAarch64;
  # Skip test_feature_importance_regression - does web fetch
  checkPhase = ''
    cd $TMPDIR
    HOME=$TMPDIR OMP_NUM_THREADS=1 pytest -k "not test_feature_importance_regression" --pyargs sklearn
  '';

  meta = with stdenv.lib; {
    description = "A set of python modules for machine learning and data mining";
    homepage = http://scikit-learn.org;
    license = licenses.bsd3;
    maintainers = with maintainers; [ ];
  };
}

Revert "python: scikit-learn: 0.20.3 -> 0.21.2"

{ stdenv, buildPythonPackage, fetchPypi
, gfortran, glibcLocales
, numpy, scipy, pytest, pillow
}:

buildPythonPackage rec {
  pname = "scikit-learn";
  version = "0.20.3";
  # UnboundLocalError: local variable 'message' referenced before assignment
  disabled = stdenv.isi686;  # https://github.com/scikit-learn/scikit-learn/issues/5534

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

  buildInputs = [ pillow gfortran glibcLocales ];
  propagatedBuildInputs = [ numpy scipy numpy.blas ];
  checkInputs = [ pytest ];

  LC_ALL="en_US.UTF-8";

  doCheck = !stdenv.isAarch64;
  # Skip test_feature_importance_regression - does web fetch
  checkPhase = ''
    cd $TMPDIR
    HOME=$TMPDIR OMP_NUM_THREADS=1 pytest -k "not test_feature_importance_regression" --pyargs sklearn
  '';

  meta = with stdenv.lib; {
    description = "A set of python modules for machine learning and data mining";
    homepage = http://scikit-learn.org;
    license = licenses.bsd3;
    maintainers = with maintainers; [ ];
  };
}


{ lib, writeShellScriptBin, fish }:

with lib;

makeOverridable ({
  completionDirs ? [],
  functionDirs ? [],
  confDirs ? [],
  pluginPkgs ? []
}:

let
  vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d";
  complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs;
  funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs;
  confPath = confDirs ++ map (vendorDir "conf") pluginPkgs;

in writeShellScriptBin "fish" ''
  ${fish}/bin/fish --init-command "
    set --prepend fish_complete_path ${escapeShellArgs complPath}
    set --prepend fish_function_path ${escapeShellArgs funcPath}
    set --local fish_conf_source_path ${escapeShellArgs confPath}
    for c in \$fish_conf_source_path/*; source \$c; end
  " "$@"
'')

Add `localConfig` and `shellAliases` parameters.

{ lib, writeShellScriptBin, fish, writeTextFile }:

lib.makeOverridable ({
  completionDirs ? [],
  functionDirs ? [],
  confDirs ? [],
  pluginPkgs ? [],
  localConfig ? "",
  shellAliases ? {}
}:

let
  aliasesStr = builtins.concatStringsSep "\n"
      (lib.mapAttrsToList (k: v: "alias ${k} ${lib.escapeShellArg v}") shellAliases);

  shellAliasesFishConfig = writeTextFile {
    name = "wrapfish.aliases.fish";
    destination = "/share/fish/vendor_conf.d/aliases.fish";
    text = ''
      status --is-interactive; and begin
        # Aliases
        ${aliasesStr}
      end
    '';
  };

  localFishConfig = writeTextFile {
    name = "wrapfish.local.fish";
    destination = "/share/fish/vendor_conf.d/config.local.fish";
    text = localConfig;
  };

  vendorDir = kind: plugin: "${plugin}/share/fish/vendor_${kind}.d";
  complPath = completionDirs ++ map (vendorDir "completions") pluginPkgs;
  funcPath = functionDirs ++ map (vendorDir "functions") pluginPkgs;
  confPath = confDirs
    ++ (map (vendorDir "conf") pluginPkgs)
    ++ (map (vendorDir "conf") [ localFishConfig shellAliasesFishConfig ]);

in writeShellScriptBin "fish" ''
  ${fish}/bin/fish --init-command "
    set --prepend fish_complete_path ${lib.escapeShellArgs complPath}
    set --prepend fish_function_path ${lib.escapeShellArgs funcPath}
    set --local fish_conf_source_path ${lib.escapeShellArgs confPath}
    for c in \$fish_conf_source_path/*; source \$c; end
  " "$@"
'')


{stdenv, fetchurl}:

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

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

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

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

Upgrade PolyML to version 5.4.1

{stdenv, fetchurl}:

let
  version = "5.4.1";
in

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

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

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


{ stdenv,
  fetchFromGitHub,
  which,
  autoreconfHook,
  autoconf,
  automake,
  libtool,
  yacc,
  bison,
  flex,
  glib,
  pkgconfig,
  json_c,
  xen,
  libvirt }:

with stdenv.lib;

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

  src = fetchFromGitHub {
    owner = "libvmi";
    repo = "libvmi";
    rev = "6934e8a4758018983ec53ec791dd14a7d6ac31a9";
    sha256 = "0wbi2nasb1gbci6cq23g6kq7i10rwi1y7r44rl03icr5prqjpdyv";
  };

  buildInputs = [ glib which libvirt json_c xen ];
  nativeBuildInputs = [ autoreconfHook yacc bison flex libtool autoconf automake pkgconfig ];

  meta = with stdenv.lib; {
    homepage = "http://libvmi.com/";
    description = "A C library for virtual machine introspection";
    longDescription = ''
      LibVMI is a C library with Python bindings that makes it easy to monitor the low-level
      details of a running virtual machine by viewing its memory, trapping on hardware events,
      and accessing the vCPU registers.
    '';
    license = [ licenses.lgpl3 ];
    maintainers = with maintainers; [ lschuermann ];
  };
}

Add option to disable xen support

{ stdenv,
  fetchFromGitHub,
  which,
  autoreconfHook,
  autoconf,
  automake,
  libtool,
  yacc,
  bison,
  flex,
  glib,
  pkgconfig,
  json_c,
  xen,
  libvirt,
  xenSupport ? true }:

with stdenv.lib;

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

  src = fetchFromGitHub {
    owner = "libvmi";
    repo = "libvmi";
    rev = "6934e8a4758018983ec53ec791dd14a7d6ac31a9";
    sha256 = "0wbi2nasb1gbci6cq23g6kq7i10rwi1y7r44rl03icr5prqjpdyv";
  };

  buildInputs = [ glib which libvirt json_c ] ++ (optional xenSupport xen);
  nativeBuildInputs = [ autoreconfHook yacc bison flex libtool autoconf automake pkgconfig ];

  configureFlags = optional (!xenSupport) "--disable-xen";

  meta = with stdenv.lib; {
    homepage = "http://libvmi.com/";
    description = "A C library for virtual machine introspection";
    longDescription = ''
      LibVMI is a C library with Python bindings that makes it easy to monitor the low-level
      details of a running virtual machine by viewing its memory, trapping on hardware events,
      and accessing the vCPU registers.
    '';
    license = [ licenses.lgpl3 ];
    maintainers = with maintainers; [ lschuermann ];
  };
}


{ config, pkgs, ... }:

{
  environment.systemPackages = with pkgs; [
    # utils
    autojump
    exfat-utils
    fzf
    gist
    git
    gnumake
    htop
    neofetch
    neovim
    python27Packages.neovim
    python36Packages.neovim
    neovim-remote
    nix-prefetch-scripts
    peru
    psmisc
    ripgrep
    rsync
    stow
    usbutils
    weechat
    wget
    zip
    unzip
  ];
}

Add smlnj + rlwrap, thefuck

{ config, pkgs, ... }:

{
  environment.systemPackages = with pkgs; [
    # utils
    autojump
    exfat-utils
    fzf
    gist
    git
    gnumake
    htop
    neofetch
    neovim
    python27Packages.neovim
    python36Packages.neovim
    neovim-remote
    nix-prefetch-scripts
    peru
    psmisc
    ripgrep
    rlwrap
    rsync
    stow
    thefuck
    usbutils
    weechat
    wget
    zip
    unzip

    # languages
    smlnj
  ];
}


{ stdenv, fetchurl, pkgconfig, dbus-glib, glib, ORBit2, libxml2
, polkit, intltool }:

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

  src = fetchurl {
    url = "mirror://gnome/sources/GConf/${stdenv.lib.versions.majorMinor version}/GConf-${version}.tar.xz";
    sha256 = "0k3q9nh53yhc9qxf1zaicz4sk8p3kzq4ndjdsgpaa2db0ccbj4hr";
  };

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

  buildInputs = [ ORBit2 libxml2 ]
    # polkit requires pam, which requires shadow.h, which is not available on
    # darwin
    ++ stdenv.lib.optional (!stdenv.isDarwin) polkit;

  propagatedBuildInputs = [ glib dbus-glib ];

  nativeBuildInputs = [ pkgconfig intltool ];

  configureFlags =
    # fixes the "libgconfbackend-oldxml.so is not portable" error on darwin
    stdenv.lib.optional stdenv.isDarwin [ "--enable-static" ];

  meta = with stdenv.lib; {
    homepage = https://projects.gnome.org/gconf/;
    description = "Deprecated system for storing application preferences";
    platforms = platforms.linux;
  };
}

Add python2 dependency for gsettings-schema-convert

{ stdenv, fetchurl, pkgconfig, dbus-glib, glib, ORBit2, libxml2, polkit, python2, intltool }:

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

  src = fetchurl {
    url = "mirror://gnome/sources/GConf/${stdenv.lib.versions.majorMinor version}/GConf-${version}.tar.xz";
    sha256 = "0k3q9nh53yhc9qxf1zaicz4sk8p3kzq4ndjdsgpaa2db0ccbj4hr";
  };

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

  buildInputs = [ ORBit2 libxml2 python2 ]
    # polkit requires pam, which requires shadow.h, which is not available on
    # darwin
    ++ stdenv.lib.optional (!stdenv.isDarwin) polkit;

  propagatedBuildInputs = [ glib dbus-glib ];

  nativeBuildInputs = [ pkgconfig intltool ];

  configureFlags =
    # fixes the "libgconfbackend-oldxml.so is not portable" error on darwin
    stdenv.lib.optional stdenv.isDarwin [ "--enable-static" ];

  meta = with stdenv.lib; {
    homepage = https://projects.gnome.org/gconf/;
    description = "Deprecated system for storing application preferences";
    platforms = platforms.linux;
  };
}


{
  allowUnfreePredicate =
  let nixpkgs = import <nixpkgs> {};
  in pkg: builtins.elem (nixpkgs.lib.getName pkg) [
    "slack"
    "spotify"
  ];
  pulseaudio = true;
}

Allow Nix to install `spotify-unwrapped`

{
  allowUnfreePredicate =
  let nixpkgs = import <nixpkgs> {};
  in pkg: builtins.elem (nixpkgs.lib.getName pkg) [
    "slack"
    "spotify"
    "spotify-unwrapped"
  ];
  pulseaudio = true;
}


{ lib
, buildPythonPackage
, fetchPypi
, attrs
, pyrsistent
, setuptools
, six
, functools32
, setuptools_scm
, perf
, twisted
, python
}:

buildPythonPackage rec {
  pname = "jsonschema";
  version = "3.0.1";

  src = fetchPypi {
    inherit pname version;
    sha256 = "03g20i1xfg4qdlk4475pl4pp7y0h37g1fbgs5qhy678q9xb822hc";
  };

  nativeBuildInputs = [
    setuptools_scm
  ];

  propagatedBuildInputs = [
    attrs
    pyrsistent
    setuptools
    six
    functools32
  ];

  checkInputs = [
    twisted
    perf
  ];

  checkPhase = ''
    ${python.interpreter} setup.py test --test-suite=jsonschema.tests
  '';

  meta = with lib; {
    description = "An implementation of JSON Schema validation for Python";
    homepage = https://github.com/Julian/jsonschema;
    license = licenses.mit;
    maintainers = with maintainers; [ costrouc domenkozar ];
  };
}

Revert "pythonPackages.jsonschema: 2.6.0 -> 3.0.1"

{ stdenv, buildPythonPackage, fetchPypi, python
, nose, mock, vcversioner, functools32 }:

buildPythonPackage rec {
  pname = "jsonschema";
  version = "2.6.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "00kf3zmpp9ya4sydffpifn0j0mzm342a2vzh82p6r0vh10cg7xbg";
  };

  checkInputs = [ nose mock vcversioner ];
  propagatedBuildInputs = [ functools32 ];

  postPatch = ''
    substituteInPlace jsonschema/tests/test_jsonschema_test_suite.py \
      --replace "python" "${python.pythonForBuild.interpreter}"
  '';

  checkPhase = ''
    nosetests
  '';

  meta = with stdenv.lib; {
    homepage = https://github.com/Julian/jsonschema;
    description = "An implementation of JSON Schema validation for Python";
    license = licenses.mit;
    maintainers = with maintainers; [ domenkozar ];
  };
}


{ buildPythonPackage
, fetchPypi
, dateutil
, jmespath
, docutils
, ordereddict
, simplejson
, mock
, nose
, urllib3
}:

buildPythonPackage rec {
  pname = "botocore";
  version = "1.16.23"; # N.B: if you change this, change boto3 and awscli to a matching version

  src = fetchPypi {
    inherit pname version;
    sha256 = "5831068c9b49b4c91b0733e0ec784a7733d8732359d73c67a07a0b0868433cae";
  };

  propagatedBuildInputs = [
    dateutil
    jmespath
    docutils
    ordereddict
    simplejson
    urllib3
  ];

  postPatch = ''
    substituteInPlace setup.py --replace ",<0.16" ""
  '';

  checkInputs = [ mock nose ];

  checkPhase = ''
    nosetests -v
  '';

  # Network access
  doCheck = false;

  meta = {
    homepage = "https://github.com/boto/botocore";
    license = "bsd";
    description = "A low-level interface to a growing number of Amazon Web Services";
  };
}

Revert "python: botocore: 1.16.6 -> 1.16.23"

{ buildPythonPackage
, fetchPypi
, dateutil
, jmespath
, docutils
, ordereddict
, simplejson
, mock
, nose
, urllib3
}:

buildPythonPackage rec {
  pname = "botocore";
  version = "1.16.6"; # N.B: if you change this, change boto3 and awscli to a matching version

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

  propagatedBuildInputs = [
    dateutil
    jmespath
    docutils
    ordereddict
    simplejson
    urllib3
  ];

  postPatch = ''
    substituteInPlace setup.py --replace ",<0.16" ""
  '';

  checkInputs = [ mock nose ];

  checkPhase = ''
    nosetests -v
  '';

  # Network access
  doCheck = false;

  meta = {
    homepage = "https://github.com/boto/botocore";
    license = "bsd";
    description = "A low-level interface to a growing number of Amazon Web Services";
  };
}


{ lib, stdenv, fetchurl, autoconf, automake, libtool, pkgconfig, zlib, ilmbase }:

stdenv.mkDerivation rec {
  name = "openexr-${lib.getVersion ilmbase}";

  src = fetchurl {
    url = "http://download.savannah.nongnu.org/releases/openexr/${name}.tar.gz";
    sha256 = "0ca2j526n4wlamrxb85y2jrgcv0gf21b3a19rr0gh4rjqkv1581n";
  };

  outputs = [ "out" "doc" ];

  preConfigure = ''
    ./bootstrap
  '';

  buildInputs = [ autoconf automake libtool pkgconfig ];
  propagatedBuildInputs = [ ilmbase zlib ];

  enableParallelBuilding = true;

  patches = [ ./bootstrap.patch ];

  meta = with stdenv.lib; {
    homepage = http://www.openexr.com/;
    license = licenses.bsd3;
    platforms = platforms.all;
    maintainers = with maintainers; [ wkennington ];
  };
}

Use separate dev and bin outputs

{ lib, stdenv, fetchurl, autoconf, automake, libtool, pkgconfig, zlib, ilmbase }:

stdenv.mkDerivation rec {
  name = "openexr-${lib.getVersion ilmbase}";

  src = fetchurl {
    url = "http://download.savannah.nongnu.org/releases/openexr/${name}.tar.gz";
    sha256 = "0ca2j526n4wlamrxb85y2jrgcv0gf21b3a19rr0gh4rjqkv1581n";
  };

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

  preConfigure = ''
    ./bootstrap
  '';

  buildInputs = [ autoconf automake libtool pkgconfig ];
  propagatedBuildInputs = [ ilmbase zlib ];

  enableParallelBuilding = true;

  patches = [ ./bootstrap.patch ];

  meta = with stdenv.lib; {
    homepage = http://www.openexr.com/;
    license = licenses.bsd3;
    platforms = platforms.all;
    maintainers = with maintainers; [ wkennington ];
  };
}


{ system, pkgs
, stateDir
, logDir
, runtimeDir
, tmpDir
, forceDisableUserChange
, processManager
, nix-processmgmt
}:

let
  createManagedProcess = import "${nix-processmgmt}/nixproc/create-managed-process/agnostic/create-managed-process-universal.nix" {
    inherit pkgs stateDir runtimeDir logDir tmpDir forceDisableUserChange processManager;
  };

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

  self = {
    disnix_tcp_proxy = callPackage ../pkgs/disnix-tcp-proxy {
      inherit createManagedProcess;
    };

    hello_world_server = callPackage ../pkgs/hello-world-server {
      inherit createManagedProcess;
    };

    hello_world_client = callPackage ../pkgs/hello-world-client { };
  };
in
self

Update reference to the universal process management abstraction function

{ system, pkgs
, stateDir
, logDir
, runtimeDir
, tmpDir
, forceDisableUserChange
, processManager
, nix-processmgmt
}:

let
  createManagedProcess = import "${nix-processmgmt}/nixproc/create-managed-process/universal/create-managed-process-universal.nix" {
    inherit pkgs stateDir runtimeDir logDir tmpDir forceDisableUserChange processManager;
  };

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

  self = {
    disnix_tcp_proxy = callPackage ../pkgs/disnix-tcp-proxy {
      inherit createManagedProcess;
    };

    hello_world_server = callPackage ../pkgs/hello-world-server {
      inherit createManagedProcess;
    };

    hello_world_client = callPackage ../pkgs/hello-world-client { };
  };
in
self


{ stdenv, fetchFromGitHub }:

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

  src = fetchFromGitHub {
    owner = "jlhonora";
    repo = "lsusb";
    rev = "8a6bd7084a55a58ade6584af5075c1db16afadd1";
    sha256 = "0p8pkcgvsx44dd56wgipa8pzi3298qk9h4rl9pwsw1939hjx6h0g";
  };

  installPhase = ''
    mkdir -p $out/bin
    mkdir -p $out/share/man/man8
    install -m 0755 lsusb $out/bin
    install -m 0444 man/lsusb.8 $out/share/man/man8
  '';

  meta = {
    homepage = https://github.com/jlhonora/lsusb;
    description = "lsusb command for Mac OS X";
    platforms = stdenv.lib.platforms.darwin;
    license = stdenv.lib.licenses.mit;
  };
}

Add 'varunpatro' as a maintainer.

{ stdenv, fetchFromGitHub }:

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

  src = fetchFromGitHub {
    owner = "jlhonora";
    repo = "lsusb";
    rev = "8a6bd7084a55a58ade6584af5075c1db16afadd1";
    sha256 = "0p8pkcgvsx44dd56wgipa8pzi3298qk9h4rl9pwsw1939hjx6h0g";
  };

  installPhase = ''
    mkdir -p $out/bin
    mkdir -p $out/share/man/man8
    install -m 0755 lsusb $out/bin
    install -m 0444 man/lsusb.8 $out/share/man/man8
  '';

  meta = {
    homepage = https://github.com/jlhonora/lsusb;
    description = "lsusb command for Mac OS X";
    platforms = stdenv.lib.platforms.darwin;
    license = stdenv.lib.licenses.mit;
    maintainers = [ stdenv.lib.maintainers.varunpatro ];
  };
}


{ stdenv, buildGoPackage, fetchFromGitHub }:

buildGoPackage rec {
  name = "cfssl-${version}";
  version = "1.3.2";

  goPackagePath = "github.com/cloudflare/cfssl";

  src = fetchFromGitHub {
    owner = "cloudflare";
    repo = "cfssl";
    rev = version;
    sha256 = "0j2gz2vl2pf7ir7sc7jrwmjnr67hk4qhxw09cjx132jbk337jc9x";
  };

  meta = with stdenv.lib; {
    homepage = https://cfssl.org/;
    description = "Cloudflare's PKI and TLS toolkit";
    platforms = platforms.linux;
    license = licenses.bsd2;
    maintainers = with maintainers; [ mbrgm ];
  };
}

Add patch for stripping authkey whitespaces

{ stdenv, buildGoPackage, fetchFromGitHub, fetchpatch }:

buildGoPackage rec {
  name = "cfssl-${version}";
  version = "1.3.2";

  goPackagePath = "github.com/cloudflare/cfssl";

  src = fetchFromGitHub {
    owner = "cloudflare";
    repo = "cfssl";
    rev = version;
    sha256 = "0j2gz2vl2pf7ir7sc7jrwmjnr67hk4qhxw09cjx132jbk337jc9x";
  };

  # The following patch ensures that the auth-key decoder doesn't break,
  # if the auth-key file contains leading or trailing whitespaces.
  # https://github.com/cloudflare/cfssl/pull/923 is merged
  # remove patch when it becomes part of a release.
  patches = [
    (fetchpatch {
      url    = "https://github.com/cloudflare/cfssl/commit/7e13f60773c96644db9dd8d342d42fe3a4d26f36.patch";
      sha256 = "1z2v2i8yj7qpj8zj5f2q739nhrr9s59jwzfzk52wfgssl4vv5mn5";
    })
  ];

  meta = with stdenv.lib; {
    homepage = https://cfssl.org/;
    description = "Cloudflare's PKI and TLS toolkit";
    platforms = platforms.linux;
    license = licenses.bsd2;
    maintainers = with maintainers; [ mbrgm ];
  };
}


{ lib, buildPythonPackage, fetchPypi, makeWrapper, pythonOlder
, prettytable
, setuptools
, solc
}:

buildPythonPackage rec {
  pname = "slither-analyzer";
  version = "0.6.12";

  disabled = pythonOlder "3.6";

  # No Python tests
  doCheck = false;

  src = fetchPypi {
    inherit pname version;
    sha256 = "9773cf48754341d03bb2e65c07897fc9c00a8727487ab2820ed89eb85f546506";
  };

  nativeBuildInputs = [ makeWrapper ];
  propagatedBuildInputs = [ prettytable setuptools ];

  postFixup = ''
    wrapProgram $out/bin/slither \
      --prefix PATH : "${lib.makeBinPath [ solc ]}"
  '';

  meta = with lib; {
    description = "Static Analyzer for Solidity";
    longDescription = ''
      Slither is a Solidity static analysis framework written in Python 3. It
      runs a suite of vulnerability detectors, prints visual information about
      contract details, and provides an API to easily write custom analyses.
    '';
    homepage = "https://github.com/trailofbits/slither";
    license = licenses.agpl3;
    maintainers = [ maintainers.asymmetric ];
  };
}

Fix missing dependency on crytic-compile

{ lib, buildPythonPackage, fetchPypi, makeWrapper, pythonOlder
, crytic-compile, prettytable, setuptools, solc
}:

buildPythonPackage rec {
  pname = "slither-analyzer";
  version = "0.6.12";

  disabled = pythonOlder "3.6";

  # No Python tests
  doCheck = false;

  src = fetchPypi {
    inherit pname version;
    sha256 = "9773cf48754341d03bb2e65c07897fc9c00a8727487ab2820ed89eb85f546506";
  };

  nativeBuildInputs = [ makeWrapper ];
  propagatedBuildInputs = [ crytic-compile prettytable setuptools ];

  postFixup = ''
    wrapProgram $out/bin/slither \
      --prefix PATH : "${lib.makeBinPath [ solc ]}"
  '';

  meta = with lib; {
    description = "Static Analyzer for Solidity";
    longDescription = ''
      Slither is a Solidity static analysis framework written in Python 3. It
      runs a suite of vulnerability detectors, prints visual information about
      contract details, and provides an API to easily write custom analyses.
    '';
    homepage = "https://github.com/trailofbits/slither";
    license = licenses.agpl3;
    maintainers = [ maintainers.asymmetric ];
  };
}


{ stdenv, fetchurl, perl, texinfo }:

stdenv.mkDerivation rec {
  name = "libtasn1-4.6";

  src = fetchurl {
    url = "mirror://gnu/libtasn1/${name}.tar.gz";
    sha256 = "12shiqjmck2g0rg57vr73dhy58kbwgsjb24sqdw6hlyjw8jzqqil";
  };

  buildInputs = [ perl texinfo ];

  doCheck = true;

  meta = {
    homepage = http://www.gnu.org/software/libtasn1/;
    description = "An ASN.1 library";

    longDescription =
      '' Libtasn1 is the ASN.1 library used by GnuTLS, GNU Shishi and some
         other packages.  The goal of this implementation is to be highly
         portable, and only require an ANSI C89 platform.
      '';

    license = stdenv.lib.licenses.lgpl2Plus;

    maintainers = with stdenv.lib.maintainers; [ wkennington ];
    platforms = stdenv.lib.platforms.all;
  };
}

Revert "libtasn1: 4.5 -> 4.6"

{ stdenv, fetchurl, perl, texinfo }:

stdenv.mkDerivation rec {
  name = "libtasn1-4.5";

  src = fetchurl {
    url = "mirror://gnu/libtasn1/${name}.tar.gz";
    sha256 = "1nhvnznhg2aqfrfjxc8v008hjlzkh5831jsfahqk89qrw7fbbcw9";
  };

  buildInputs = [ perl texinfo ];

  doCheck = true;

  meta = {
    homepage = http://www.gnu.org/software/libtasn1/;
    description = "An ASN.1 library";

    longDescription =
      '' Libtasn1 is the ASN.1 library used by GnuTLS, GNU Shishi and some
         other packages.  The goal of this implementation is to be highly
         portable, and only require an ANSI C89 platform.
      '';

    license = stdenv.lib.licenses.lgpl2Plus;

    maintainers = with stdenv.lib.maintainers; [ wkennington ];
    platforms = stdenv.lib.platforms.all;
  };
}


{ config, pkgs, ... }:

let
  dotfiles_repo = import ./dotfiles.nix;
  utils = "${dotfiles_repo.outPath}/utils";
in {
  imports = [
    ./nvim.nix
    ./zsh.nix
    ./git.nix
    ./configuration.nix
  ];

  home.username = "britt";
  home.homeDirectory = "/home/britt";
  home.stateVersion = "22.05";

  home.sessionPath = [
    utils
  ];
  home.sessionVariables = {
    EDITOR = "nvim";
  };

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;

  programs.direnv.enable = true;

  home.packages = with pkgs; [
    htop
    tree
    fzf
    silver-searcher
    jq
    yq
    dig
    gnupg
    python310
    go
    tmux
    git
    nix
    direnv
  ];
}

Use Go 1.18 instead of an older version

{ config, pkgs, ... }:

let
  dotfiles_repo = import ./dotfiles.nix;
  utils = "${dotfiles_repo.outPath}/utils";
in {
  imports = [
    ./nvim.nix
    ./zsh.nix
    ./git.nix
    ./configuration.nix
  ];

  home.username = "britt";
  home.homeDirectory = "/home/britt";
  home.stateVersion = "22.05";

  home.sessionPath = [
    utils
  ];
  home.sessionVariables = {
    EDITOR = "nvim";
  };

  # Let Home Manager install and manage itself.
  programs.home-manager.enable = true;

  programs.direnv.enable = true;

  home.packages = with pkgs; [
    htop
    tree
    fzf
    silver-searcher
    jq
    yq
    dig
    gnupg
    python310
    go_1_18
    tmux
    git
    nix
    direnv
  ];
}


let
  packages = epkgs: with epkgs; [
    ace-window
    alchemist
    beacon
    consult
    corfu
    dap-mode
    dired-single
    dockerfile-mode
    editorconfig
    elfeed
    elixir-mode
    elm-mode
    embark
    embark-consult
    envrc
    evil
    evil-collection
    evil-nerd-commenter
    flycheck
    forge
    git-gutter
    haskell-mode
    helpful
    hide-mode-line
    js2-mode
    jsonnet-mode
    lsp-haskell
    lsp-mode
    lsp-pyright
    lsp-treemacs
    lsp-ui
    magit
    marginalia
    minions
    nix-mode
    no-littering
    orderless
    org
    org-roam
    org-superstar
    org-tree-slide
    pdf-tools
    persp-projectile
    perspective
    po-mode
    popper
    projectile
    python-black
    python-isort
    python-mode
    rainbow-delimiters
    restclient
    ripgrep
    smartparens
    swiper
    terraform-mode
    tree-sitter
    tree-sitter-langs
    typescript-mode
    undo-tree
    use-package
    use-package-ensure-system-package
    vertico
    visual-fill-column
    vterm
    web-mode
    which-key
    yaml-mode
    yasnippet
    zeal-at-point
  ];
in
prev: final: {
  emacsNativeCompSebastiant = (final.emacsPackagesFor final.emacsNativeComp).emacsWithPackages packages;
}

Use Emacs emil packages from melpaStable due to introduced bug

let
  packages = epkgs: (with epkgs; [
    ace-window
    alchemist
    beacon
    consult
    corfu
    dap-mode
    dired-single
    dockerfile-mode
    editorconfig
    elfeed
    elixir-mode
    elm-mode
    embark
    embark-consult
    envrc
    flycheck
    forge
    git-gutter
    haskell-mode
    helpful
    hide-mode-line
    js2-mode
    jsonnet-mode
    lsp-haskell
    lsp-mode
    lsp-pyright
    lsp-treemacs
    lsp-ui
    magit
    marginalia
    minions
    nix-mode
    no-littering
    orderless
    org
    org-roam
    org-superstar
    org-tree-slide
    pdf-tools
    persp-projectile
    perspective
    po-mode
    popper
    projectile
    python-black
    python-isort
    python-mode
    rainbow-delimiters
    restclient
    ripgrep
    smartparens
    swiper
    terraform-mode
    tree-sitter
    tree-sitter-langs
    typescript-mode
    undo-tree
    use-package
    use-package-ensure-system-package
    vertico
    visual-fill-column
    vterm
    web-mode
    which-key
    yaml-mode
    yasnippet
    zeal-at-point
  ]) ++ (with epkgs.melpaStablePackages; [
    evil
    evil-collection
    evil-nerd-commenter
  ]);
in
prev: final: {
  emacsNativeCompSebastiant = (final.emacsPackagesFor final.emacsNativeComp).emacsWithPackages packages;
}


{ stdenv, fetchgit, cmake, ninja, boost, gmp, mpfr, libedit, python
, texinfo, doxygen, gnused, lcov }:

let
  rev = "20160111";
in

stdenv.mkDerivation {
  name = "ledger-3.1.1.${rev}";
  src = builtins.filterSource (path: type: type != "unknown") ./.;

  buildInputs = [ cmake ninja doxygen lcov boost gmp mpfr libedit
                  python texinfo gnused ];

  enableParallelBuilding = true;

  # Skip byte-compiling of emacs-lisp files because this is currently
  # broken in ledger...
  postInstall = ''
    mkdir -p $out/share/emacs/site-lisp/
    cp -v "$src/lisp/"*.el $out/share/emacs/site-lisp/
  '';

  meta = {
    homepage = "http://ledger-cli.org/";
    description = "A double-entry accounting system with a command-line reporting interface";
    license = "BSD";

    longDescription = ''
      Ledger is a powerful, double-entry accounting system that is accessed
      from the UNIX command-line. This may put off some users, as there is
      no flashy UI, but for those who want unparalleled reporting access to
      their data, there really is no alternative.
    '';

    platforms = stdenv.lib.platforms.all;
    maintainers = with stdenv.lib.maintainers; [ simons the-kenny jwiegley ];
  };
}

Remove compilation of ledger-mode lisp files

{ stdenv, fetchgit, cmake, ninja, boost, gmp, mpfr, libedit, python
, texinfo, doxygen, gnused, lcov }:

let
  rev = "20160111";
in

stdenv.mkDerivation {
  name = "ledger-3.1.1.${rev}";
  src = builtins.filterSource (path: type: type != "unknown") ./.;

  buildInputs = [ cmake ninja doxygen lcov boost gmp mpfr libedit
                  python texinfo gnused ];

  enableParallelBuilding = true;

  meta = {
    homepage = "http://ledger-cli.org/";
    description = "A double-entry accounting system with a command-line reporting interface";
    license = "BSD";

    longDescription = ''
      Ledger is a powerful, double-entry accounting system that is accessed
      from the UNIX command-line. This may put off some users, as there is
      no flashy UI, but for those who want unparalleled reporting access to
      their data, there really is no alternative.
    '';

    platforms = stdenv.lib.platforms.all;
    maintainers = with stdenv.lib.maintainers; [ simons the-kenny jwiegley ];
  };
}


{ pkgs, ... }:

{
  nodes = {

    server =
      { config, pkgs, ... }:

      {
        services.openssh.enable = true;
      };

    client =
      { config, pkgs, ... }: { };

  };

  testScript = ''
    startAll;

    my $key=`${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`;

    $server->waitForUnit("sshd");

    $server->succeed("mkdir -m 700 /root/.ssh");
    $server->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");

    $client->succeed("mkdir -m 700 /root/.ssh");
    $client->copyFileFromHost("key", "/root/.ssh/id_dsa");
    $client->succeed("chmod 600 /root/.ssh/id_dsa");

    $client->waitForUnit("network.target");
    $client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'echo hello world' >&2");
  '';
}

Test whether PAM resource limits work

{ pkgs, ... }:

{
  nodes = {

    server =
      { config, pkgs, ... }:

      {
        services.openssh.enable = true;
        security.pam.services.sshd.limits =
          [ { domain = "*"; item = "memlock"; type = "-"; value = 1024; } ];
      };

    client =
      { config, pkgs, ... }: { };

  };

  testScript = ''
    startAll;

    my $key=`${pkgs.openssh}/bin/ssh-keygen -t dsa -f key -N ""`;

    $server->waitForUnit("sshd");

    $server->succeed("mkdir -m 700 /root/.ssh");
    $server->copyFileFromHost("key.pub", "/root/.ssh/authorized_keys");

    $client->succeed("mkdir -m 700 /root/.ssh");
    $client->copyFileFromHost("key", "/root/.ssh/id_dsa");
    $client->succeed("chmod 600 /root/.ssh/id_dsa");

    $client->waitForUnit("network.target");
    $client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'echo hello world' >&2");
    $client->succeed("ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no server 'ulimit -l' | grep 1024");
  '';
}


{ pkgs
, buildPythonPackage
, fetchPypi
, python
, azure-mgmt-common
}:

buildPythonPackage rec {
  version = "3.0.0";
  pname = "azure-mgmt-storage";

  src = fetchPypi {
    inherit pname version;
    extension = "zip";
    sha256 = "24c52b9dcb5e224ca9572d6ec39b53d332bdfe01818e85ec1cc1b5bedf16ce07";
  };

  preConfigure = ''
    # Patch to make this package work on requests >= 2.11.x
    # CAN BE REMOVED ON NEXT PACKAGE UPDATE
    sed -i 's|len(request_content)|str(len(request_content))|' azure/mgmt/storage/storagemanagement.py
  '';

  postInstall = ''
    echo "__import__('pkg_resources').declare_namespace(__name__)" >> "$out/lib/${python.libPrefix}"/site-packages/azure/__init__.py
    echo "__import__('pkg_resources').declare_namespace(__name__)" >> "$out/lib/${python.libPrefix}"/site-packages/azure/mgmt/__init__.py
  '';

  propagatedBuildInputs = [ azure-mgmt-common ];

  meta = with pkgs.lib; {
    description = "Microsoft Azure SDK for Python";
    homepage = "https://azure.microsoft.com/en-us/develop/python/";
    license = licenses.asl20;
    maintainers = with maintainers; [ olcai ];
  };
}

Revert "python: azure-mgmt-storage: 0.20.0 -> 3.0.0"

{ pkgs
, buildPythonPackage
, fetchPypi
, python
, azure-mgmt-common
}:

buildPythonPackage rec {
  version = "0.20.0";
  pname = "azure-mgmt-storage";

  src = fetchPypi {
    inherit pname version;
    extension = "zip";
    sha256 = "16iw7hqhq97vlzfwixarfnirc60l5mz951p57brpcwyylphl3yim";
  };

  preConfigure = ''
    # Patch to make this package work on requests >= 2.11.x
    # CAN BE REMOVED ON NEXT PACKAGE UPDATE
    sed -i 's|len(request_content)|str(len(request_content))|' azure/mgmt/storage/storagemanagement.py
  '';

  postInstall = ''
    echo "__import__('pkg_resources').declare_namespace(__name__)" >> "$out/lib/${python.libPrefix}"/site-packages/azure/__init__.py
    echo "__import__('pkg_resources').declare_namespace(__name__)" >> "$out/lib/${python.libPrefix}"/site-packages/azure/mgmt/__init__.py
  '';

  propagatedBuildInputs = [ azure-mgmt-common ];

  meta = with pkgs.lib; {
    description = "Microsoft Azure SDK for Python";
    homepage = "https://azure.microsoft.com/en-us/develop/python/";
    license = licenses.asl20;
    maintainers = with maintainers; [ olcai ];
  };
}


{ config, pkgs, ... }:

{
  environment.systemPackages = with pkgs; [
    # Shells / Terminal
    bash
    fish
    tmux

    # Source control
    git

    # Web
    wget
    curl
    lynx

    # SSH
    mosh

    # Email
    isync

    # Interpreters
    python
  ];
}

Add neovim with nixpkgs pinning

{ config, pkgs, ... }:

let
  neopkgs = import (
    pkgs.fetchFromGitHub {
      owner = "NixOS";
      repo = "nixpkgs";
      rev = "8f793ce6bb050252e92a987cc3c5bd48d5423a42";
      sha256 = "0fydxirp79s4svr2gadp3hsx2vrank904n8c5kprqh3jrzid90cg";
    }
  ) {};
in
{
  environment.systemPackages = [
    # Shells / Terminal
    pkgs.bash
    pkgs.fish
    pkgs.tmux

    # Editor
    neopkgs.neovim

    # Source control
    pkgs.git

    # Web
    pkgs.wget
    pkgs.curl
    pkgs.lynx

    # SSH
    pkgs.mosh

    # Email
    pkgs.isync

    # Interpreters
    pkgs.python
  ];
}


{
  stdenv, lib, mkDerivation, fetchpatch,
  extra-cmake-modules, kdoctools, qttools,
  acl, attr, libkrb5, util-linux ? null,
  karchive, kbookmarks, kcompletion, kconfig, kconfigwidgets, kcoreaddons,
  kdbusaddons, ki18n, kiconthemes, kitemviews, kjobwidgets, knotifications,
  kservice, ktextwidgets, kwallet, kwidgetsaddons, kwindowsystem, kxmlgui,
  qtbase, qtscript, qtx11extras, solid, kcrash, kded
}:

mkDerivation {
  name = "kio";
  nativeBuildInputs = [ extra-cmake-modules kdoctools ];
  buildInputs = [
    karchive kconfigwidgets kdbusaddons ki18n kiconthemes knotifications
    ktextwidgets kwallet kwidgetsaddons kwindowsystem qtscript qtx11extras
    kcrash libkrb5
  ] ++ lib.lists.optionals stdenv.isLinux [
    acl attr # both are needed for ACL support
    util-linux # provides libmount
  ];
  propagatedBuildInputs = [
    kbookmarks kcompletion kconfig kcoreaddons kitemviews kjobwidgets kservice
    kxmlgui qtbase qttools solid kded
  ];
  outputs = [ "out" "dev" ];
  patches = [
    ./0001-Remove-impure-smbd-search-path.patch
    ./0002-Debug-module-loader.patch
 ];
}

Remove optional null on util-linux dependency for kio

{
  stdenv, lib, mkDerivation, fetchpatch,
  extra-cmake-modules, kdoctools, qttools,
  acl, attr, libkrb5, util-linux,
  karchive, kbookmarks, kcompletion, kconfig, kconfigwidgets, kcoreaddons,
  kdbusaddons, ki18n, kiconthemes, kitemviews, kjobwidgets, knotifications,
  kservice, ktextwidgets, kwallet, kwidgetsaddons, kwindowsystem, kxmlgui,
  qtbase, qtscript, qtx11extras, solid, kcrash, kded
}:

mkDerivation {
  name = "kio";
  nativeBuildInputs = [ extra-cmake-modules kdoctools ];
  buildInputs = [
    karchive kconfigwidgets kdbusaddons ki18n kiconthemes knotifications
    ktextwidgets kwallet kwidgetsaddons kwindowsystem qtscript qtx11extras
    kcrash libkrb5
  ] ++ lib.lists.optionals stdenv.isLinux [
    acl attr # both are needed for ACL support
    util-linux # provides libmount
  ];
  propagatedBuildInputs = [
    kbookmarks kcompletion kconfig kcoreaddons kitemviews kjobwidgets kservice
    kxmlgui qtbase qttools solid kded
  ];
  outputs = [ "out" "dev" ];
  patches = [
    ./0001-Remove-impure-smbd-search-path.patch
    ./0002-Debug-module-loader.patch
 ];
}


{stdenv, fetchurl, gmp, cmake, python}:

let version = "0.1.3";
in

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

  src = fetchurl {
    url = "https://github.com/SRI-CSL/libpoly/archive/v${version}.tar.gz";
    sha256 = "0nd90585imnznyp04vg6a5ixxkd3bavhv1437397aj2k3dfc0y2k";
  };

  buildInputs = [ cmake gmp python ];

  meta = with stdenv.lib; {
    homepage = https://github.com/SRI-CSL/libpoly;
    description = "C library for manipulating polynomials";
    license = licenses.gplv3;
    platforms = platforms.all;
  };
}

Fix license reference for added libpoly library.

{stdenv, fetchurl, gmp, cmake, python}:

let version = "0.1.3";
in

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

  src = fetchurl {
    url = "https://github.com/SRI-CSL/libpoly/archive/v${version}.tar.gz";
    sha256 = "0nd90585imnznyp04vg6a5ixxkd3bavhv1437397aj2k3dfc0y2k";
  };

  buildInputs = [ cmake gmp python ];

  meta = with stdenv.lib; {
    homepage = https://github.com/SRI-CSL/libpoly;
    description = "C library for manipulating polynomials";
    license = licenses.lgpl3;
    platforms = platforms.all;
  };
}


# This file is autogenerated from update.sh in the same directory.
{
  beta = {
    sha256 = "1270xv2ykn9q0sva26w75vkb7rd79filzvrpnrlkw34zpfprbqbm";
    version = "54.0.2840.34";
  };
  dev = {
    sha256 = "1lbpj1wm35l2qf4fxfivd9drwwdrylv3knh8db889dyz5hrh3j5y";
    sha256bin64 = "0rkvrrcr1j9662v00kf7x7qmdps1pd4hq818x7crkilczybd05pr";
    version = "55.0.2868.3";
  };
  stable = {
    sha256 = "0qk0y457l91yzxradpinayzw3947s5s4axd75h968vrl0jan51vs";
    sha256bin64 = "0sz4dfwxvkffcj4rrqh3vn2xxp2vvjzdjsy0s9wcvam01igmy261";
    version = "53.0.2785.116";
  };
}

Fix wrong/missing hash for beta channel

# This file is autogenerated from update.sh in the same directory.
{
  beta = {
    sha256 = "1wpcl6cgiv02s3zgxvgsmrws454g81lnvyfjmhhcdckkwyljcv5l";
    sha256bin64 = "0snr5rd2r5jfjqhqwkxcw26j53fivmf60g3qfnp5xz5b6nlsab9g";
    version = "54.0.2840.34";
  };
  dev = {
    sha256 = "1lbpj1wm35l2qf4fxfivd9drwwdrylv3knh8db889dyz5hrh3j5y";
    sha256bin64 = "0rkvrrcr1j9662v00kf7x7qmdps1pd4hq818x7crkilczybd05pr";
    version = "55.0.2868.3";
  };
  stable = {
    sha256 = "0qk0y457l91yzxradpinayzw3947s5s4axd75h968vrl0jan51vs";
    sha256bin64 = "0sz4dfwxvkffcj4rrqh3vn2xxp2vvjzdjsy0s9wcvam01igmy261";
    version = "53.0.2785.116";
  };
}


{ stdenv
, buildPythonPackage
, fetchPypi
, pytest_3
, setuptools_scm
, apipkg
}:

buildPythonPackage rec {
  pname = "execnet";
  version = "1.5.0";

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

  checkInputs = [ pytest_3  ];
  nativeBuildInputs = [ setuptools_scm ];
  propagatedBuildInputs = [ apipkg ];

  # remove vbox tests
  postPatch = ''
    rm -v testing/test_termination.py
    rm -v testing/test_channel.py
    rm -v testing/test_xspec.py
    rm -v testing/test_gateway.py
  '';

  checkPhase = ''
    py.test testing
  '';

  # not yet compatible with pytest 4
  doCheck = false;

  __darwinAllowLocalNetworking = true;

  meta = with stdenv.lib; {
    description = "Rapid multi-Python deployment";
    license = licenses.gpl2;
    homepage = "http://codespeak.net/execnet";
    maintainers = with maintainers; [ nand0p ];
  };

}

Remove flaky test on PyPy.

{ stdenv
, lib
, buildPythonPackage
, isPyPy
, fetchPypi
, pytest_3
, setuptools_scm
, apipkg
}:

buildPythonPackage rec {
  pname = "execnet";
  version = "1.5.0";

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

  checkInputs = [ pytest_3 ];
  nativeBuildInputs = [ setuptools_scm ];
  propagatedBuildInputs = [ apipkg ];

  # remove vbox tests
  postPatch = ''
    rm -v testing/test_termination.py
    rm -v testing/test_channel.py
    rm -v testing/test_xspec.py
    rm -v testing/test_gateway.py
    ${lib.optionalString isPyPy "rm -v testing/test_multi.py"}
  '';

  checkPhase = ''
    py.test testing
  '';

  # not yet compatible with pytest 4
  doCheck = false;

  __darwinAllowLocalNetworking = true;

  meta = with stdenv.lib; {
    description = "Rapid multi-Python deployment";
    license = licenses.gpl2;
    homepage = "http://codespeak.net/execnet";
    maintainers = with maintainers; [ nand0p ];
  };

}


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

stdenv.mkDerivation rec {
  name = "lm-sensors-3.4.0";

  src = fetchurl {
    url = "http://pkgs.fedoraproject.org/repo/pkgs/lm_sensors/lm_sensors-3.4.0.tar.bz2/c03675ae9d43d60322110c679416901a/lm_sensors-3.4.0.tar.bz2";
    sha256 = "07q6811l4pp0f7pxr8bk3s97ippb84mx5qdg7v92s9hs10b90mz0";
  };

  nativeBuildInputs = [
    bison
    flex
    which
  ];

  preBuild = ''
    makeFlagsArray+=("PREFIX=$out")
    buildFlagsArray+=("ETCDIR=/etc")
    installFlagsArray+=("ETCDIR=$out/etc")
  '';

  meta = with stdenv.lib; {
    homepage = http://www.lm-sensors.org/;
    description = "Tools for reading hardware sensors";
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}

Fix install by disabling parallel

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

stdenv.mkDerivation rec {
  name = "lm-sensors-3.4.0";

  src = fetchurl {
    url = "http://pkgs.fedoraproject.org/repo/pkgs/lm_sensors/lm_sensors-3.4.0.tar.bz2/c03675ae9d43d60322110c679416901a/lm_sensors-3.4.0.tar.bz2";
    sha256 = "07q6811l4pp0f7pxr8bk3s97ippb84mx5qdg7v92s9hs10b90mz0";
  };

  nativeBuildInputs = [
    bison
    flex
    which
  ];

  preBuild = ''
    makeFlagsArray+=("PREFIX=$out")
    buildFlagsArray+=("ETCDIR=/etc")
    installFlagsArray+=("ETCDIR=$out/etc")
  '';

  parallelInstall = false;

  meta = with stdenv.lib; {
    homepage = http://www.lm-sensors.org/;
    description = "Tools for reading hardware sensors";
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      x86_64-linux;
  };
}


# https://phabricator.haskell.org/D4159 to fix non-determinism in
# cached abi-depends fields in package databases, modified to only
# contain hunks that exist in distribution tarballs.
{ fetchpatch, runCommand }: let
  base = fetchpatch { # Non-determinism in cached abi-depends fields
    url = https://phabricator-files.haskell.org/file/data/4pqrbo5b62sifktfbrls/PHID-FILE-4g4zjiqlfxmmlaos7lz7/D4159.diff;
    sha256 = "0b8a08sisf1swmarm6nh9rgw7cpzi2rwdzvrd6ny49c7wk0f7x4b";
  };
in runCommand base.name {}
  "sed -n '/utils\\/ghc-pkg/,$p' ${base} >$out"

Use persistent URL for abi-depends determinism patch.

# https://phabricator.haskell.org/D4159 to fix non-determinism in
# cached abi-depends fields in package databases, modified to only
# contain hunks that exist in distribution tarballs.
{ fetchpatch, runCommand }: let
  base = fetchpatch rec { # Non-determinism in cached abi-depends fields
    # Originally https://phabricator-files.haskell.org/file/data/4pqrbo5b62sifktfbrls/PHID-FILE-4g4zjiqlfxmmlaos7lz7/D4159.diff
    url = "http://tarballs.nixos.org/sha256/${sha256}";
    name = "D4159.diff";
    sha256 = "0b8a08sisf1swmarm6nh9rgw7cpzi2rwdzvrd6ny49c7wk0f7x4b";
  };
in runCommand base.name {}
  "sed -n '/utils\\/ghc-pkg/,$p' ${base} >$out"


{ stdenv
, bison
, fetchurl
, m4
}:

let
  version = "2.6.3";
in
stdenv.mkDerivation rec {
  name = "flex-${version}";

  src = fetchurl {
    url = "https://github.com/westes/flex/releases/download/v${version}/${name}.tar.gz";
    sha256 = "68b2742233e747c462f781462a2a1e299dc6207401dac8f0bbb316f48565c2aa";
  };

  nativeBuildInputs = [
    bison
    m4
  ];

  # Using static libraries fixes issues with references to
  # yylex in flex 2.6.0
  # This can be tested by building glusterfs
  configureFlags = [
    "--disable-shared"
  ];

  dontDisableStatic = true;

  meta = with stdenv.lib; {
    description = "A fast lexical analyser generator";
    homepage = http://flex.sourceforge.net/;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      i686-linux
      ++ x86_64-linux;
  };
}

Revert "flex: 2.6.1 -> 2.6.3"

{ stdenv
, bison
, fetchurl
, m4
}:

let
  # Flex 2.6.2 and 2.6.3 break grub2_efi so wait for 2.6.4
  version = "2.6.1";
in
stdenv.mkDerivation rec {
  name = "flex-${version}";

  src = fetchurl {
    url = "https://github.com/westes/flex/releases/download/v${version}/${name}.tar.xz";
    sha256 = "2c7a412c1640e094cb058d9b2fe39d450186e09574bebb7aa28f783e3799103f";
  };

  nativeBuildInputs = [
    bison
    m4
  ];

  # Using static libraries fixes issues with references to
  # yylex in flex 2.6.0
  # This can be tested by building glusterfs
  configureFlags = [
    "--disable-shared"
  ];

  dontDisableStatic = true;

  meta = with stdenv.lib; {
    description = "A fast lexical analyser generator";
    homepage = http://flex.sourceforge.net/;
    maintainers = with maintainers; [
      wkennington
    ];
    platforms = with platforms;
      i686-linux
      ++ x86_64-linux;
  };
}


{stdenv, fetchurl, ocaml, findlib, camomile, ounit}:

let
  ocaml_version = (builtins.parseDrvName ocaml.name).version;
in

stdenv.mkDerivation {
  name = "ocaml-batteries-1.3.0";

  src = fetchurl {
    url = "http://forge.ocamlcore.org/frs/download.php/560/batteries-1.3.0.tar.gz";
    sha256 = "1kf8dyivigavi89lpsz7hzdv48as10yck7gkmqmnsnn1dps3m7an";
  };

  buildInputs = [ocaml findlib camomile ounit];

  # This option is not correctly detected on Darwin
  # It should be fixed in the svn
  BATTERIES_NATIVE_SHLIB = if stdenv.isDarwin then "no" else "yes";

  # Ditto
  patchPhase = ''
    substituteInPlace Makefile --replace 'echo -n' echo
  '';

  configurePhase = "true"; 	# Skip configure

  preInstall = ''
    ensureDir "$out/lib/ocaml/${ocaml_version}/site-lib"
  '';

  doCheck = true;

  checkTarget = "test";

  meta = {
    homepage = http://batteries.forge.ocamlcore.org/;
    description = "OCaml Batteries Included";
    longDescription = ''
      A community-driven effort to standardize on an consistent, documented,
      and comprehensive development platform for the OCaml programming
      language.
    '';
    license = "LGPL";
    platforms = ocaml.meta.platforms;
    maintainers = [
      stdenv.lib.maintainers.z77z
    ];
  };
}

Update OCaml Batteries to 1.4.0

{stdenv, fetchurl, ocaml, findlib, camomile, ounit}:

let
  ocaml_version = (builtins.parseDrvName ocaml.name).version;
in

stdenv.mkDerivation {
  name = "ocaml-batteries-1.3.0";

  src = fetchurl {
    url = https://forge.ocamlcore.org/frs/download.php/643/batteries-1.4.0.tar.gz;
    sha256 = "1qyhiyanlhpbj0dv0vyqak87qfadjzg2pb8q93iybmg59akaxl15";
  };

  buildInputs = [ocaml findlib camomile ounit];

  patchPhase = ''
    substituteInPlace Makefile --replace '/bin/echo -n' echo
  '';

  configurePhase = "true"; 	# Skip configure

  preInstall = ''
    ensureDir "$out/lib/ocaml/${ocaml_version}/site-lib"
  '';

  doCheck = true;

  checkTarget = "test";

  meta = {
    homepage = http://batteries.forge.ocamlcore.org/;
    description = "OCaml Batteries Included";
    longDescription = ''
      A community-driven effort to standardize on an consistent, documented,
      and comprehensive development platform for the OCaml programming
      language.
    '';
    license = "LGPL";
    platforms = ocaml.meta.platforms;
    maintainers = [
      stdenv.lib.maintainers.z77z
    ];
  };
}


{ pkgs }:

{
  allowBroken = false;
  allowUnfree = true;

  packageOverrides = pkgs : rec {

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

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

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

Add commented snippet to enable when testing pkgs

{ pkgs }:

{
  allowBroken = false;
  allowUnfree = true;

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

  packageOverrides = pkgs : rec {

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

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

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


{stdenv, fetchurl, lib, qt4, qca2, openssl}:

stdenv.mkDerivation rec {
  name = "qca-ossl-2.0.0-beta3";
  src = fetchurl {
    url = "http://delta.affinix.com/download/qca/2.0/plugins/${name}.tar.bz2";
    sha256 = "0yy68racvx3clybry2i1bw5bz9yhxr40p3xqagxxb15ihvsrzq08";
  };
  buildInputs = [ qt4 qca2 openssl ];
  dontAddPrefix = true;
  configureFlags="--no-separate-debug-info --with-qca=${qca2}
    --with-openssl-inc=${openssl}/include --with-openssl-lib=${openssl}/lib";
  preConfigure=''
    configureFlags="$configureFlags --plugins-path=$out/plugins"
  '';
  patches = [ ./ossl-remove-whirlpool.patch ];
  meta = {
    description = "Qt Cryptographic Architecture OpenSSL plugin";
    license = "LGPL";
    homepage = http://delta.affinix.com/qca;
    maintainers = [ lib.maintainers.urkud ];
  };
}

Adjust plugin install dir to changes in qt

{stdenv, fetchurl, lib, qt4, qca2, openssl}:

stdenv.mkDerivation rec {
  name = "qca-ossl-2.0.0-beta3";
  src = fetchurl {
    url = "http://delta.affinix.com/download/qca/2.0/plugins/${name}.tar.bz2";
    sha256 = "0yy68racvx3clybry2i1bw5bz9yhxr40p3xqagxxb15ihvsrzq08";
  };
  buildInputs = [ qt4 qca2 openssl ];
  dontAddPrefix = true;
  configureFlags="--no-separate-debug-info --with-qca=${qca2}
    --with-openssl-inc=${openssl}/include --with-openssl-lib=${openssl}/lib";
  preConfigure=''
    configureFlags="$configureFlags --plugins-path=$out/lib/qt4/plugins"
  '';
  patches = [ ./ossl-remove-whirlpool.patch ];
  meta = {
    description = "Qt Cryptographic Architecture OpenSSL plugin";
    license = "LGPL";
    homepage = http://delta.affinix.com/qca;
    maintainers = [ lib.maintainers.urkud ];
  };
}


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

cabal.mkDerivation (self: {
  pname = "http-kit";
  version = "0.5.0";
  sha256 = "0djg2gg12w9sd598hx959cgr5027ghza3m6aaym9ipb43w6mds5p";
  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.5.1

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

cabal.mkDerivation (self: {
  pname = "http-kit";
  version = "0.5.1";
  sha256 = "1swnvsbaabk946pys9q9kr0bgdvalnznd59dw981sg7cywqdcz28";
  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, fetchurl, lib}:

with lib;

let version = "5.2.22";
in
fetchurl rec {
  name = "Oracle_VM_VirtualBox_Extension_Pack-${version}.vbox-extpack";
  url = "https://download.virtualbox.org/virtualbox/${version}/${name}";
  sha256 = "1vria59m7xr521hp2sakfihv8282xcfd5hl6dr1gbcjicmk514kp";

  meta = {
    description = "Oracle Extension pack for VirtualBox";
    license = licenses.virtualbox-puel;
    homepage = https://www.virtualbox.org/;
    maintainers = with maintainers; [ flokli sander cdepillabout ];
    platforms = [ "x86_64-linux" "i686-linux" ];
  };
}

Fix the sha256 to be hex.

{stdenv, fetchurl, lib}:

with lib;

let version = "5.2.22";
in
fetchurl rec {
  name = "Oracle_VM_VirtualBox_Extension_Pack-${version}.vbox-extpack";
  url = "https://download.virtualbox.org/virtualbox/${version}/${name}";
  sha256 =
    # Manually sha256sum the extensionPack file, must be hex!
    # Thus do not use `nix-prefetch-url` but instead plain old `sha256sum`.
    let value = "779250666551b2f5426e86c2d21ceb0209b46174536971611025f753535131ef";
    in assert (builtins.stringLength value) == 64; value;

  meta = {
    description = "Oracle Extension pack for VirtualBox";
    license = licenses.virtualbox-puel;
    homepage = https://www.virtualbox.org/;
    maintainers = with maintainers; [ flokli sander cdepillabout ];
    platforms = [ "x86_64-linux" "i686-linux" ];
  };
}


{ fetchurl, stdenv, guile, ncurses, libffi }:

stdenv.mkDerivation rec {
  name = "guile-ncurses-1.7";

  src = fetchurl {
    url = "mirror://gnu/guile-ncurses/${name}.tar.gz";
    sha256 = "153vv75gb7l62sp3666rc97i63rnaqbx2rjar7d9b5w81fhwv4r5";
  };

  buildInputs = [ guile ncurses libffi ];

  preConfigure =
    '' configureFlags="$configureFlags --with-guilesitedir=$out/share/guile/site" '';

  doCheck = false;  # XXX: 1 of 65 tests failed

  meta = {
    description = "GNU Guile-Ncurses, Scheme interface to the NCurses libraries";

    longDescription =
      '' GNU Guile-Ncurses is a library for the Guile Scheme interpreter that
         provides functions for creating text user interfaces.  The text user
         interface functionality is built on the ncurses libraries: curses,
         form, panel, and menu.
      '';

    license = stdenv.lib.licenses.lgpl3Plus;

    maintainers = [ ];
    platforms = stdenv.lib.platforms.gnu;  # arbitrary choice
  };
}

Use absolute path to load libguile-ncurses

{ fetchurl, stdenv, guile, ncurses, libffi }:

stdenv.mkDerivation rec {
  name = "guile-ncurses-1.7";

  src = fetchurl {
    url = "mirror://gnu/guile-ncurses/${name}.tar.gz";
    sha256 = "153vv75gb7l62sp3666rc97i63rnaqbx2rjar7d9b5w81fhwv4r5";
  };

  buildInputs = [ guile ncurses libffi ];

  preConfigure =
    '' configureFlags="$configureFlags --with-guilesitedir=$out/share/guile/site" '';

  postFixup =
    '' for f in $out/share/guile/site/ncurses/**.scm; do \
           substituteInPlace $f \
             --replace "libguile-ncurses" "$out/lib/libguile-ncurses"; \
       done
    '';

  doCheck = false;  # XXX: 1 of 65 tests failed

  meta = {
    description = "GNU Guile-Ncurses, Scheme interface to the NCurses libraries";

    longDescription =
      '' GNU Guile-Ncurses is a library for the Guile Scheme interpreter that
         provides functions for creating text user interfaces.  The text user
         interface functionality is built on the ncurses libraries: curses,
         form, panel, and menu.
      '';

    license = stdenv.lib.licenses.lgpl3Plus;

    maintainers = [ ];
    platforms = stdenv.lib.platforms.gnu;  # arbitrary choice
  };
}


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

with lib;

{
  options = {

    time = {

      timeZone = mkOption {
        default = "CET";
        type = types.str;
        example = "America/New_York";
        description = "The time zone used when displaying times and dates.";
      };

      hardwareClockInLocalTime = mkOption {
        default = false;
        description = "If set, keep the hardware clock in local time instead of UTC.";
      };

    };
  };

  config = {

    environment.variables.TZDIR = "/etc/zoneinfo";

    environment.etc.localtime =
      { source = "${pkgs.tzdata}/share/zoneinfo/${config.time.timeZone}";
        mode = "direct-symlink";
      };

    environment.etc.zoneinfo.source = "${pkgs.tzdata}/share/zoneinfo";

  };

}

Set TZDIR for all systemd services

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

with lib;

let

  tzdir = "${pkgs.tzdata}/share/zoneinfo";

in

{
  options = {

    time = {

      timeZone = mkOption {
        default = "CET";
        type = types.str;
        example = "America/New_York";
        description = "The time zone used when displaying times and dates.";
      };

      hardwareClockInLocalTime = mkOption {
        default = false;
        description = "If set, keep the hardware clock in local time instead of UTC.";
      };

    };
  };

  config = {

    environment.variables.TZDIR = "/etc/zoneinfo";

    systemd.globalEnvironment.TZDIR = tzdir;

    environment.etc.localtime =
      { source = "${tzdir}/${config.time.timeZone}";
        mode = "direct-symlink";
      };

    environment.etc.zoneinfo.source = "${pkgs.tzdata}/share/zoneinfo";

  };

}


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

buildPythonPackage rec {
  pname = "pkgconfig";
  version = "1.4.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "048c3b457da7b6f686b647ab10bf09e2250e4c50acfe6f215398a8b5e6fcdb52";
  };

  checkInputs = [ nose ];

  # Apparently many our expressions get pythonPackages.pkgconfig and expect
  # to have the pkg-config executable on $PATH
  # For some reason, propagatedNativeBuildInputs don't seem enough.
  propagatedBuildInputs = [ pkgconfig ];

  checkPhase = ''
    nosetests
  '';

  patches = [ ./executable.patch ];
  postPatch = ''
    substituteInPlace pkgconfig/pkgconfig.py --replace 'PKG_CONFIG_EXE = "pkg-config"' 'PKG_CONFIG_EXE = "${pkgconfig}/bin/pkg-config"'
  '';

  meta = with lib; {
    description = "Interface Python with pkg-config";
    homepage = https://github.com/matze/pkgconfig;
    license = licenses.mit;
  };
}

Revert "python*Packages.pkgconfig: try avoiding multiple breakages"

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

buildPythonPackage rec {
  pname = "pkgconfig";
  version = "1.4.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "048c3b457da7b6f686b647ab10bf09e2250e4c50acfe6f215398a8b5e6fcdb52";
  };

  checkInputs = [ nose ];

  nativeBuildInputs = [ pkgconfig ];

  checkPhase = ''
    nosetests
  '';

  patches = [ ./executable.patch ];
  postPatch = ''
    substituteInPlace pkgconfig/pkgconfig.py --replace 'PKG_CONFIG_EXE = "pkg-config"' 'PKG_CONFIG_EXE = "${pkgconfig}/bin/pkg-config"'
  '';

  meta = with lib; {
    description = "Interface Python with pkg-config";
    homepage = https://github.com/matze/pkgconfig;
    license = licenses.mit;
  };
}


{
  pkgs ? import <nixpkgs> {}
}:

with pkgs;

let
  sources = import nix/sources.nix;
  alpinocorpus = callPackage sources.alpinocorpus {};
in qt5.mkDerivation {
  name = "dact";

  src = nix-gitignore.gitignoreSource [] ./.;

  nativeBuildInputs = [
    git
    meson
    ninja
    pkgconfig
  ];

  buildInputs = [
    alpinocorpus
    boost
    libxml2
    libxslt
    qt5.qtbase
    xercesc
    xqilla
    zlib
  ];
}

Make alpinocorpus a derivation argument

{
  pkgs ? import <nixpkgs> {}
, alpinocorpus ? pkgs.callPackage (import nix/sources.nix).alpinocorpus {}
}:

with pkgs;

qt5.mkDerivation {
  name = "dact";

  src = nix-gitignore.gitignoreSource [ ".git" "*.nix" "flake.lock" ] ./.;

  nativeBuildInputs = [
    git
    meson
    ninja
    pkgconfig
  ];

  buildInputs = [
    alpinocorpus
    boost
    libxml2
    libxslt
    qt5.qtbase
    xercesc
    xqilla
    zlib
  ];
}


{ lib, buildPythonPackage, fetchPypi, debtcollector, oslotest, stestr, pbr }:

buildPythonPackage rec {
  pname = "oslo.context";
  version = "4.0.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "sha256-VarKqPrvz10M9mVJPVtqLCCKVl3Ft1y/CaBIypmagsw=";
  };

  postPatch = ''
    # only a small portion of the listed packages are actually needed for running the tests
    # so instead of removing them one by one remove everything
    rm test-requirements.txt
  '';

  propagatedBuildInputs = [
    debtcollector
    pbr
  ];

  checkInputs = [
    oslotest
    stestr
  ];

  checkPhase = ''
    stestr run
  '';

  pythonImportsCheck = [ "oslo_context" ];

  meta = with lib; {
    description = "Oslo Context library";
    homepage = "https://github.com/openstack/oslo.context";
    license = licenses.asl20;
    maintainers = teams.openstack.members;
  };
}

Revert "python310Packages.oslo-context: 3.4.0 -> 4.0.0"

{ lib, buildPythonPackage, fetchPypi, debtcollector, oslotest, stestr, pbr }:

buildPythonPackage rec {
  pname = "oslo.context";
  version = "3.4.0";

  src = fetchPypi {
    inherit pname version;
    sha256 = "970f96361c5de9a5dc86d48a648289d77118180ca13ba5eeb307137736ffa953";
  };

  postPatch = ''
    # only a small portion of the listed packages are actually needed for running the tests
    # so instead of removing them one by one remove everything
    rm test-requirements.txt
  '';

  propagatedBuildInputs = [
    debtcollector
    pbr
  ];

  checkInputs = [
    oslotest
    stestr
  ];

  checkPhase = ''
    stestr run
  '';

  pythonImportsCheck = [ "oslo_context" ];

  meta = with lib; {
    description = "Oslo Context library";
    homepage = "https://github.com/openstack/oslo.context";
    license = licenses.asl20;
    maintainers = teams.openstack.members;
  };
}