{ stdenv, fetchurl, jre }:

let version = "0_100"; in
stdenv.mkDerivation rec {
  name = "cfr-${version}";

  src = fetchurl {
    sha256 = "0q5kh5qdksykz339p55jz0q5cjqvxdzv3a7r4kkijgbfjm1ldr5f";
    url = "http://www.benf.org/other/cfr/cfr_${version}.jar";
  };

  meta = with stdenv.lib; {
    inherit version;
    description = "Another java decompiler";
    longDescription = ''
      CFR will decompile modern Java features - Java 8 lambdas (pre and post
      Java beta 103 changes), Java 7 String switches etc, but is written
      entirely in Java 6.
    '';
    homepage = http://www.benf.org/other/cfr/;
    license = with licenses; mit;
    platforms = with platforms; linux;
    maintainers = with maintainers; [ nckx ];
  };

  buildInputs = [ jre ];

  phases = [ "installPhase" ];

  installPhase = ''
    jar=$out/share/cfr/cfr_${version}.jar

    install -Dm644 ${src} $jar

    cat << EOF > cfr
    #!${stdenv.shell}
    exec ${jre}/bin/java -jar $jar "\''${@}"
    EOF
    install -Dm755 cfr $out/bin/cfr
  '';
}

Update to version 0_101 and remove platform restrictions

{ stdenv, fetchurl, jre }:

let version = "0_101"; in
stdenv.mkDerivation rec {
  name = "cfr-${version}";

  src = fetchurl {
    sha256 = "0zwl3whypdm2qrw3hwaqjnifkb4wcdn8fx9scrjkli54bhr6dqch";
    url = "http://www.benf.org/other/cfr/cfr_${version}.jar";
  };

  meta = with stdenv.lib; {
    inherit version;
    description = "Another java decompiler";
    longDescription = ''
      CFR will decompile modern Java features - Java 8 lambdas (pre and post
      Java beta 103 changes), Java 7 String switches etc, but is written
      entirely in Java 6.
    '';
    homepage = http://www.benf.org/other/cfr/;
    license = with licenses; mit;
    platforms = with platforms; all;
    maintainers = with maintainers; [ nckx ];
  };

  buildInputs = [ jre ];

  phases = [ "installPhase" ];

  installPhase = ''
    jar=$out/share/cfr/cfr_${version}.jar

    install -Dm644 ${src} $jar

    cat << EOF > cfr
    #!${stdenv.shell}
    exec ${jre}/bin/java -jar $jar "\''${@}"
    EOF
    install -Dm755 cfr $out/bin/cfr
  '';
}


{ stdenv, fetchurl, unzip, cmake, libtiff, expat, zlib, libpng, libjpeg }:
stdenv.mkDerivation {
  name = "vxl-1.14.0";

  src = fetchurl {
    url = mirror://sourceforge/vxl/vxl-1.14.0.zip;
    sha256 = "0434wxvxyr9baq3q5rhjcqvlaq5p9n5ax400bdrc49ff2jddq0h2";
  };

  buildInputs = [ cmake unzip libtiff expat zlib libpng libjpeg ];

  cmakeFlags = if (stdenv.system == "x86_64-linux") then
      "-DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC"
    else
      "";

  meta = {
    description = "C++ Libraries for Computer Vision Research and Implementation";
    homepage = http://vxl.sourceforge.net/;
    license = "VXL License";
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}

Revert "Version update for vxl", because: - Although the file for 1.14 is in the upstream file repository, it's not published in their web, which still talks about 1.13 for the stable release. - The cmake files comming with this vxl fail (because of some weird dependency on a doxygen.cmake file)

{ stdenv, fetchurl, unzip, cmake, libtiff, expat, zlib, libpng, libjpeg }:
stdenv.mkDerivation {
  name = "vxl-1.13.0";

  src = fetchurl {
    url = mirror://sourceforge/vxl/vxl-1.13.0.zip;
    sha256 = "05xk9dfkqsznp1dic8rcsdhgdp12bikwx1zpci0w3s20fs8q8nn1";
  };

  buildInputs = [ cmake unzip libtiff expat zlib libpng libjpeg ];

  cmakeFlags = if (stdenv.system == "x86_64-linux") then
      "-DCMAKE_CXX_FLAGS=-fPIC -DCMAKE_C_FLAGS=-fPIC"
    else
      "";

  meta = {
    description = "C++ Libraries for Computer Vision Research and Implementation";
    homepage = http://vxl.sourceforge.net/;
    license = "VXL License";
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}


{ lib, stdenv, rustPlatform, fetchFromGitHub, installShellFiles
, libiconv, Foundation }:

rustPlatform.buildRustPackage rec {
  pname = "macchina";
  version = "6.0.1";

  src = fetchFromGitHub {
    owner = "Macchina-CLI";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-CInENUTuFyHGPntU1vv7c6MWZiCPdH3Zytj191Q/vOc=";
  };

  cargoSha256 = "sha256-XbNypI0x9lkLYIAk6X0Ifx/YV5yKmP6j2Qc+qQXMgjg=";

  nativeBuildInputs = [ installShellFiles ];
  buildInputs = lib.optionals stdenv.isDarwin [ libiconv Foundation ];

  postInstall = ''
    installShellCompletion target/completions/*.{bash,fish}
  '';

  meta = with lib; {
    description = "A fast, minimal and customizable system information fetcher";
    homepage = "https://github.com/Macchina-CLI/macchina";
    changelog = "https://github.com/Macchina-CLI/macchina/releases/tag/v${version}";
    license = with licenses; [ mit ];
    maintainers = with maintainers; [ _414owen ];
  };
}

Revert "macchina: 5.0.5 -> 6.0.1"

{ lib, stdenv, rustPlatform, fetchFromGitHub, installShellFiles
, libiconv, Foundation }:

rustPlatform.buildRustPackage rec {
  pname = "macchina";
  version = "5.0.5";

  src = fetchFromGitHub {
    owner = "Macchina-CLI";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-si+5LvRUIWp48vsD1WxGWl2O/2bpaBX+ArkZPbBqtME=";
  };

  cargoSha256 = "sha256-CN7PxPUkfyDGxVaf879Sp6w0UbqwL/is15xcfH2fm1w=";

  nativeBuildInputs = [ installShellFiles ];
  buildInputs = lib.optionals stdenv.isDarwin [ libiconv Foundation ];

  postInstall = ''
    installShellCompletion target/completions/*.{bash,fish}
  '';

  meta = with lib; {
    description = "A fast, minimal and customizable system information fetcher";
    homepage = "https://github.com/Macchina-CLI/macchina";
    changelog = "https://github.com/Macchina-CLI/macchina/releases/tag/v${version}";
    license = with licenses; [ mit ];
    maintainers = with maintainers; [ _414owen ];
  };
}


{ lib, buildGoModule, fetchFromGitHub, libpcap }:

buildGoModule rec {
  pname = "goreplay";
  version = "1.3.3";

  src = fetchFromGitHub {
    owner = "buger";
    repo = "goreplay";
    rev = version;
    sha256 = "sha256-FiY9e5FgpPu+K8eoO8TsU3xSaSoPPDxYEu0oi/S8Q1w=";
  };

  vendorSha256 = "sha256-jDMAtcq3ZowFdky5BdTkVNxq4ltkhklr76nXYJgGALg=";

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

  buildInputs = [ libpcap ];

  doCheck = false;

  meta = {
    homepage = "https://github.com/buger/goreplay";
    license = lib.licenses.lgpl3Only;
    description = "Open-source tool for capturing and replaying live HTTP traffic";
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [ lovek323 ];
  };
}

Add patch to fix build on arm64-linux

{ lib, buildGoModule, fetchFromGitHub, fetchpatch, libpcap }:

buildGoModule rec {
  pname = "goreplay";
  version = "1.3.3";

  src = fetchFromGitHub {
    owner = "buger";
    repo = "goreplay";
    rev = version;
    sha256 = "sha256-FiY9e5FgpPu+K8eoO8TsU3xSaSoPPDxYEu0oi/S8Q1w=";
  };

  patches = [
    # Fix build on arm64-linux, see https://github.com/buger/goreplay/pull/1140
    (fetchpatch {
      url = "https://github.com/buger/goreplay/commit/a01afa1e322ef06f36995abc3fda3297bdaf0140.patch";
      sha256 = "sha256-w3aVe/Fucwd2OuK5Fu2jJTbmMci8ilWaIjYjsWuLRlo=";
    })
  ];

  vendorSha256 = "sha256-jDMAtcq3ZowFdky5BdTkVNxq4ltkhklr76nXYJgGALg=";

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

  buildInputs = [ libpcap ];

  doCheck = false;

  meta = {
    homepage = "https://github.com/buger/goreplay";
    license = lib.licenses.lgpl3Only;
    description = "Open-source tool for capturing and replaying live HTTP traffic";
    platforms = lib.platforms.unix;
    maintainers = with lib.maintainers; [ lovek323 ];
  };
}


{ stdenv, fetchurl, devicemapper, libgcrypt, libuuid, pkgconfig, popt
, enablePython ? false, python ? null
}:

assert enablePython -> python != null;

stdenv.mkDerivation rec {
  name = "cryptsetup-1.5.1";

  src = fetchurl {
    url = "http://cryptsetup.googlecode.com/files/${name}.tar.bz2";
    sha256 = "0dib3nw6ifd7d7hr9k4iyaha3hz0pkzairqa38l3fndkr9w3zlhn";
  };

  configureFlags = [ "--enable-cryptsetup-reencrypt" ]
                ++ stdenv.lib.optional enablePython "--enable-python";

  buildInputs = [ devicemapper libgcrypt libuuid pkgconfig popt ]
             ++ stdenv.lib.optional enablePython python;

  meta = {
    homepage = http://code.google.com/p/cryptsetup/;
    description = "LUKS for dm-crypt";
    license = "GPLv2";
    maintainers = with stdenv.lib.maintainers; [ viric chaoflow ];
    platforms = with stdenv.lib.platforms; linux;
  };
}

Upgrade cryptsetup from 1.5.1 -> 1.6.2

{ stdenv, fetchurl, devicemapper, libgcrypt, libuuid, pkgconfig, popt
, enablePython ? false, python ? null
}:

assert enablePython -> python != null;

stdenv.mkDerivation rec {
  name = "cryptsetup-1.6.2";

  src = fetchurl {
    url = "http://cryptsetup.googlecode.com/files/${name}.tar.bz2";
    sha256 = "16hh7v8bsqy0i1wlaj03kwqjv3liffkvg06lk75lng9hk00kywhm";
  };

  configureFlags = [ "--enable-cryptsetup-reencrypt" ]
                ++ stdenv.lib.optional enablePython "--enable-python";

  buildInputs = [ devicemapper libgcrypt libuuid pkgconfig popt ]
             ++ stdenv.lib.optional enablePython python;

  meta = {
    homepage = http://code.google.com/p/cryptsetup/;
    description = "LUKS for dm-crypt";
    license = "GPLv2";
    maintainers = with stdenv.lib.maintainers; [ viric chaoflow ];
    platforms = with stdenv.lib.platforms; linux;
  };
}


{ stdenv, fetchurl, qt4, poppler_qt4, zlib, pkgconfig, poppler}:

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

  src = fetchurl {
    url = "http://www.xm1math.net/texmaker/${name}.tar.bz2";
    sha256 = "1h5rxdq6f05wk3lnlw96fxwrb14k77cx1mwy648127h2c8nsgw4z";
  };

  buildInputs = [ qt4 poppler_qt4 zlib ];

  nativeBuildInputs = [ pkgconfig poppler ];

  preConfigure = ''
    export NIX_CFLAGS_COMPILE="$NIX_CFLAGS_COMPILE -I$(echo ${poppler}/include/poppler/) " # for poppler-config.h
    qmake PREFIX=$out DESKTOPDIR=$out/share/applications ICONDIR=$out/share/pixmaps texmaker.pro
  '';

  meta = with stdenv.lib; {
    description = "TeX and LaTeX editor";
    longDescription=''
	This editor is a full fledged IDE for TeX and
	LaTeX editing with completion, structure viewer, preview,
	spell checking and support of any compilation chain.
	'';
    homepage = "http://www.xm1math.net/texmaker/";
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
    maintainers = with maintainers; [ cfouche ];
  };
}

Update TexMaker from 4.1.1 to 4.4.1

{ stdenv, fetchurl, qt4, poppler_qt4, zlib, pkgconfig, poppler}:

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

  src = fetchurl {
    url = "http://www.xm1math.net/texmaker/${name}.tar.bz2";
    sha256 = "1d5lb4sibdhvzgfr0zi48j92b4acvvvdy2biqi3jzjdnzy9r94w0";
  };

  buildInputs = [ qt4 poppler_qt4 zlib ];
  nativeBuildInputs = [ pkgconfig poppler ];
  NIX_CFLAGS_COMPILE="-I${poppler}/include/poppler";

  preConfigure = ''
    qmake PREFIX=$out DESKTOPDIR=$out/share/applications ICONDIR=$out/share/pixmaps texmaker.pro
  '';

  meta = with stdenv.lib; {
    description = "TeX and LaTeX editor";
    longDescription=''
	This editor is a full fledged IDE for TeX and
	LaTeX editing with completion, structure viewer, preview,
	spell checking and support of any compilation chain.
	'';
    homepage = "http://www.xm1math.net/texmaker/";
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
    maintainers = with maintainers; [ cfouche ];
  };
}


{ stdenv, fetchFromGitHub, autoreconfHook }:

stdenv.mkDerivation rec {
  pname = "libsass";
  version = "3.6.2";

  src = fetchFromGitHub {
    owner = "sass";
    repo = pname;
    rev = version;
    sha256 = "0z09nv08vcajvv70h8355zsnqw1w8d0hwiizym3ax1zvzkdx7941";
    # Remove unicode file names which leads to different checksums on HFS+
    # vs. other filesystems because of unicode normalisation.
    extraPostFetch = ''
      rm -r $out/test/e2e/unicode-pwd
    '';
  };

  preConfigure = ''
    export LIBSASS_VERSION=${version}
  '';

  nativeBuildInputs = [ autoreconfHook ];

  meta = with stdenv.lib; {
    description = "A C/C++ implementation of a Sass compiler";
    homepage = https://github.com/sass/libsass;
    license = licenses.mit;
    maintainers = with maintainers; [ codyopel offline ];
    platforms = platforms.unix;
  };
}

Revert "libsass: 3.6.1 -> 3.6.2"

{ stdenv, fetchFromGitHub, autoreconfHook }:

stdenv.mkDerivation rec {
  pname = "libsass";
  version = "3.6.1";

  src = fetchFromGitHub {
    owner = "sass";
    repo = pname;
    rev = version;
    sha256 = "1599j2lbsygy3883x9si7rbad1pkjhl6y72aimaapcv90ga5kxkm";
    # Remove unicode file names which leads to different checksums on HFS+
    # vs. other filesystems because of unicode normalisation.
    extraPostFetch = ''
      rm -r $out/test/e2e/unicode-pwd
    '';
  };

  preConfigure = ''
    export LIBSASS_VERSION=${version}
  '';

  nativeBuildInputs = [ autoreconfHook ];

  meta = with stdenv.lib; {
    description = "A C/C++ implementation of a Sass compiler";
    homepage = https://github.com/sass/libsass;
    license = licenses.mit;
    maintainers = with maintainers; [ codyopel offline ];
    platforms = platforms.unix;
  };
}


let
  pkgs = import <nixpkgs> {};

  log_level = "info";
in
pkgs.mkShell {
  buildInputs = with pkgs; [
    rustc cargo rustfmt rust-analyzer cargo-outdated clippy

    # Needed by cargo dependencies.
    cmake gcc zlib pkgconfig openssl

    # wgpu graphics dependencies
    vulkan-loader vulkan-tools
    xorg.libXcursor xorg.libXi xorg.libXrandr

    # SPIR-V shader compiler
    shaderc

    # Linker
    lld

    # Map editor
    tiled
  ];

  shellHook = ''
    # Dynamic linking for Vulkan stuff for wgpu graphics
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${
      with pkgs; pkgs.stdenv.lib.makeLibraryPath [ vulkan-loader ]
    }"

    # Run clippy without showing stuff I don't care about.
    alias clippy="cargo clippy -- -A clippy::cast_lossless"
  '';

  RUST_BACKTRACE = "1";
  RUSTFLAGS = "-C link-arg=-fuse-ld=lld";
  RUST_LOG = "calx-ecs=${log_level},vitral=${log_level},calx=${log_level},display=${log_level},world=${log_level},magog=${log_level}";
}

Add LD_LIBRARY_PATH stuff for cargo outdated

let
  pkgs = import <nixpkgs> {};

  log_level = "info";
in
pkgs.mkShell {
  buildInputs = with pkgs; [
    rustc cargo rustfmt rust-analyzer cargo-outdated clippy

    # Needed by cargo dependencies.
    cmake gcc zlib pkgconfig openssl

    # wgpu graphics dependencies
    vulkan-loader vulkan-tools
    xorg.libXcursor xorg.libXi xorg.libXrandr

    # SPIR-V shader compiler
    shaderc

    # Linker
    lld

    # Map editor
    tiled
  ];

  shellHook = ''
    # Dynamic linking for Vulkan stuff for wgpu graphics
    export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${
      with pkgs; pkgs.stdenv.lib.makeLibraryPath [ vulkan-loader openssl zlib ]
    }"

    # Run clippy without showing stuff I don't care about.
    alias clippy="cargo clippy -- -A clippy::cast_lossless"
  '';

  RUST_BACKTRACE = "1";
  RUSTFLAGS = "-C link-arg=-fuse-ld=lld";
  RUST_LOG = "calx-ecs=${log_level},vitral=${log_level},calx=${log_level},display=${log_level},world=${log_level},magog=${log_level}";
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "libfaketime-0.9.6";

  src = fetchurl {
    url = "http://www.code-wizards.com/projects/libfaketime/${name}.tar.gz";
    sha256 = "1dw2lqsv2iqwxg51mdn25b4fjj3v357s0mc6ahxawqp210krg29s";
  };

  patches = [
    ./no-date-in-gzip-man-page.patch
  ];

  preBuild = ''
    makeFlagsArray+=(PREFIX="$out" LIBDIRNAME=/lib)
  '';

  meta = with stdenv.lib; {
    description = "Report faked system time to programs without having to change the system-wide time";
    homepage = http://www.code-wizards.com/projects/libfaketime/;
    license = licenses.gpl2;
    platforms = platforms.all;
    maintainers = [ maintainers.bjornfor ];
  };
}

Fix build on gcc 6

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "libfaketime-0.9.6";

  src = fetchurl {
    url = "http://www.code-wizards.com/projects/libfaketime/${name}.tar.gz";
    sha256 = "1dw2lqsv2iqwxg51mdn25b4fjj3v357s0mc6ahxawqp210krg29s";
  };

  patches = [
    ./no-date-in-gzip-man-page.patch
  ];

  preBuild = ''
    makeFlagsArray+=(PREFIX="$out" LIBDIRNAME=/lib)
  '';

  # Work around "libfaketime.c:513:7: error: nonnull argument 'buf' compared to NULL [-Werror=nonnull-compare]".
  NIX_CFLAGS_COMPILE = "-Wno-nonnull-compare";

  meta = with stdenv.lib; {
    description = "Report faked system time to programs without having to change the system-wide time";
    homepage = http://www.code-wizards.com/projects/libfaketime/;
    license = licenses.gpl2;
    platforms = platforms.all;
    maintainers = [ maintainers.bjornfor ];
  };
}


{stdenv, fetchurl, zlib, openssl}:
stdenv.mkDerivation rec {
  version = "0.4.17";
  name = "libre-${version}";
  src=fetchurl {
    url = "http://www.creytiv.com/pub/re-${version}.tar.gz";
    sha256 = "1630228xbsmasbmkx3s7g4r8mzkdlzila4j2f6m2mp0996v8kq1c";
  };
  buildInputs = [zlib openssl];
  makeFlags = [
    "USE_ZLIB=1" "USE_OPENSSL=1"
    ''PREFIX=$(out)''
  ]
  ++ stdenv.lib.optional (stdenv.cc.cc != null) "SYSROOT_ALT=${stdenv.cc.cc}"
  ++ stdenv.lib.optional (stdenv.cc.libc != null) "SYSROOT=${stdenv.cc.libc}"
  ;
  meta = {
    homepage = "http://www.creytiv.com/re.html";
    platforms = with stdenv.lib.platforms; linux;
    maintainers = with stdenv.lib.maintainers; [raskin];
    license = stdenv.lib.licenses.bsd3;
    inherit version;
    downloadPage = "http://www.creytiv.com/pub/";
    updateWalker = true;
    downloadURLRegexp = "/re-.*[.]tar[.].*";
  };
}

Use 'dev' output of libc

{stdenv, fetchurl, zlib, openssl}:
stdenv.mkDerivation rec {
  version = "0.4.17";
  name = "libre-${version}";
  src=fetchurl {
    url = "http://www.creytiv.com/pub/re-${version}.tar.gz";
    sha256 = "1630228xbsmasbmkx3s7g4r8mzkdlzila4j2f6m2mp0996v8kq1c";
  };
  buildInputs = [zlib openssl];
  makeFlags = [
    "USE_ZLIB=1" "USE_OPENSSL=1"
    ''PREFIX=$(out)''
  ]
  ++ stdenv.lib.optional (stdenv.cc.cc != null) "SYSROOT_ALT=${stdenv.cc.cc}"
  ++ stdenv.lib.optional (stdenv.cc.libc != null) "SYSROOT=${stdenv.lib.getDev stdenv.cc.libc}"
  ;
  meta = {
    homepage = "http://www.creytiv.com/re.html";
    platforms = with stdenv.lib.platforms; linux;
    maintainers = with stdenv.lib.maintainers; [raskin];
    license = stdenv.lib.licenses.bsd3;
    inherit version;
    downloadPage = "http://www.creytiv.com/pub/";
    updateWalker = true;
    downloadURLRegexp = "/re-.*[.]tar[.].*";
  };
}


{ stdenv, fetchurl, cmake, pkgconfig, qt }:

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

  src = fetchurl {
    url = "http://download.kde.org/stable/qca/${version}/src/qca-${version}.tar.xz";
    sha256 = "0lz3n652z208daxypdcxiybl0a9fnn6ida0q7fh5f42269mdhgq0";
  };

  nativeBuildInputs = [ cmake pkgconfig ];
  buildInputs = [ qt ];

  enableParallelBuilding = true;

  # tells CMake to use this CA bundle file if it is accessible
  preConfigure = ''export QC_CERTSTORE_PATH=/etc/ssl/certs/ca-certificates.crt'';

  # tricks CMake into using this CA bundle file if it is not accessible (in a sandbox)
  cmakeFlags = [ "-Dqca_CERTSTORE=/etc/ssl/certs/ca-certificates.crt" ];

  meta = with stdenv.lib; {
    description = "Qt Cryptographic Architecture";
    license = "LGPL";
    homepage = http://delta.affinix.com/qca;
    maintainers = [ maintainers.sander ];
    platforms = platforms.unix;
  };
}

Add additional darwin dependency for qca2

{ stdenv, fetchurl, cmake, pkgconfig, qt, darwin }:

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

  src = fetchurl {
    url = "http://download.kde.org/stable/qca/${version}/src/qca-${version}.tar.xz";
    sha256 = "0lz3n652z208daxypdcxiybl0a9fnn6ida0q7fh5f42269mdhgq0";
  };

  nativeBuildInputs = [ cmake pkgconfig ];
  buildInputs = [ (stdenv.lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.Security) qt ];

  enableParallelBuilding = true;

  # tells CMake to use this CA bundle file if it is accessible
  preConfigure = ''export QC_CERTSTORE_PATH=/etc/ssl/certs/ca-certificates.crt'';

  # tricks CMake into using this CA bundle file if it is not accessible (in a sandbox)
  cmakeFlags = [ "-Dqca_CERTSTORE=/etc/ssl/certs/ca-certificates.crt" ];

  meta = with stdenv.lib; {
    description = "Qt Cryptographic Architecture";
    license = "LGPL";
    homepage = http://delta.affinix.com/qca;
    maintainers = [ maintainers.sander ];
    platforms = platforms.unix;
  };
}


{ pkgs }:

rec {
  # likely-music haskellPackage
  likely-music-lib = likely-music-backend;
  likely-music-backend = pkgs.haskellPackages.callPackage ./likely-music-backend.nix { };

  likely-music-frontend = pkgs.callPackage ./web { };
}

Add likely-music pkg (wrapped backend with all deps resolved)

{ pkgs }:

rec {
  # likely-music haskellPackage
  likely-music-lib = likely-music-backend;
  likely-music-backend = pkgs.haskellPackages.callPackage ./likely-music-backend.nix { };

  likely-music-frontend = pkgs.callPackage ./web { };

  # executable wrapper around everything with correct paths
  likely-music = pkgs.runCommand "likely-music" { } ''
    mkdir -p $out/bin
    source "${pkgs.dieHook}/nix-support/setup-hook"
    source "${pkgs.makeWrapper}/nix-support/setup-hook"
    makeWrapper "${likely-music-backend}/bin/likely-music-backend" "$out/bin/likely-music" \
      --argv0 likely-music \
      --set LIKELY_MUSIC_FRONTEND "${likely-music-frontend}/share/likely-music-frontend" \
      --set LIKELY_MUSIC_SYNTH "${fluidsynth-wrapper}/bin/fluidsynth-wrapper"
    '';

  fluidsynth-wrapper = pkgs.writeTextFile {
    name = "fluidsynth-wrapper";
    executable = true;
    destination = "/bin/fluidsynth-wrapper";
    text = ''
      #!${pkgs.bash}/bin/bash
      # fluidsynth-wrapper IN.mid OUT.wav
      if [ -z "$1" -o -z "$2" ]; then
        echo "$0: missing file parameter(s)" >&2
        exit 1
      fi
      ${pkgs.fluidsynth}/bin/fluidsynth -a file -i ${pkgs.soundfont-fluid}/share/soundfonts/FluidR3_GM2-2.sf2 -F "$2" "$1"
    '';
  };
}


{ kdePackage, cmake, perl, bzip2, xz, qt4, alsaLib, xineLib, samba,
  shared_mime_info, exiv2, libssh , kdelibs, automoc4, strigi, soprano,
  cluceneCore, attica, virtuoso, makeWrapper }:

kdePackage {
  pn = "kdebase-runtime";
  v = "4.5.0";

  buildInputs = [ cmake perl bzip2 xz qt4 alsaLib xineLib samba shared_mime_info
    exiv2 libssh kdelibs automoc4 strigi soprano cluceneCore attica
    makeWrapper];

  patches = [ ./freeze.diff ];

  postInstall = ''
    wrapProgram "$out/bin/nepomukservicestub" --prefix LD_LIBRARY_PATH : "${virtuoso}/lib" \
        --prefix PATH : "${virtuoso}/bin"
  '';

  meta = {
    description = "KDE runtime";
    longDescription = "Libraries and tools which supports running KDE desktop applications";
    license = "LGPL";
  };
}

Fix symlink. TODO: upstream fix

{ kdePackage, cmake, perl, bzip2, xz, qt4, alsaLib, xineLib, samba,
  shared_mime_info, exiv2, libssh , kdelibs, automoc4, strigi, soprano,
  cluceneCore, attica, virtuoso, makeWrapper, oxygen_icons }:

kdePackage {
  pn = "kdebase-runtime";
  v = "4.5.0";

  buildInputs = [ cmake perl bzip2 xz qt4 alsaLib xineLib samba shared_mime_info
    exiv2 libssh kdelibs automoc4 strigi soprano cluceneCore attica
    makeWrapper];

  patches = [ ./freeze.diff ];

  postInstall = ''
    rm -v $out/share/icons/default.kde4
    ln -s ${oxygen_icons}/share/icons/oxygen $out/share/icons/default.kde4
    wrapProgram "$out/bin/nepomukservicestub" --prefix LD_LIBRARY_PATH : "${virtuoso}/lib" \
        --prefix PATH : "${virtuoso}/bin"
  '';

  meta = {
    description = "KDE runtime";
    longDescription = "Libraries and tools which supports running KDE desktop applications";
    license = "LGPL";
  };
}


{ stdenv, fetchurl, gmp-static, gperf, autoreconfHook }:

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

  src = fetchurl {
    url = "http://yices.csl.sri.com/cgi-bin/yices2-newnewdownload.cgi?file=yices-${version}-src.tar.gz&accept=I+Agree";
    name = "yices-${version}-src.tar.gz";
    sha256 = "1wfq6hcm54h0mqmbs1ip63i0ywlwnciav86sbzk3gafxyzg1nd0c";
  };

  configureFlags = [ "--with-static-gmp=${gmp-static.out}/lib/libgmp.a"
                     "--with-static-gmp-include-dir=${gmp-static.dev}/include"
                   ];
  buildInputs = [ gmp-static gperf autoreconfHook ];

  installPhase = ''make install LDCONFIG=true'';

  meta = {
    description = "A high-performance theorem prover and SMT solver";
    homepage    = "http://yices.csl.sri.com";
    license     = stdenv.lib.licenses.unfreeRedistributable;
    platforms   = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
  };
}

Build in parallel, run tests, fix test shebang.

{ stdenv, fetchurl, gmp-static, gperf, autoreconfHook }:

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

  src = fetchurl {
    url = "http://yices.csl.sri.com/cgi-bin/yices2-newnewdownload.cgi?file=yices-${version}-src.tar.gz&accept=I+Agree";
    name = "yices-${version}-src.tar.gz";
    sha256 = "1wfq6hcm54h0mqmbs1ip63i0ywlwnciav86sbzk3gafxyzg1nd0c";
  };

  patchPhase = ''patchShebangs tests/regress/check.sh'';

  configureFlags = [ "--with-static-gmp=${gmp-static.out}/lib/libgmp.a"
                     "--with-static-gmp-include-dir=${gmp-static.dev}/include"
                   ];
  buildInputs = [ gmp-static gperf autoreconfHook ];

  enableParallelBuilding = true;
  doCheck = true;

  installPhase = ''make install LDCONFIG=true'';

  meta = {
    description = "A high-performance theorem prover and SMT solver";
    homepage    = "http://yices.csl.sri.com";
    license     = stdenv.lib.licenses.unfreeRedistributable;
    platforms   = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.thoughtpolice ];
  };
}


{ stdenv, fetchurl, pkgconfig, libraw1394 }:

stdenv.mkDerivation rec {
  name = "libavc1394-0.5.4";

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

  buildInputs = [ pkgconfig ];
  propagatedBuildInputs = [ libraw1394 ];

  meta = {
    description = "Programming interface for the 1394 Trade Association AV/C (Audio/Video Control) Digital Interface Command Set";
    homepage = http://sourceforge.net/projects/libavc1394/;
    license = [ "GPL" "LGPL" ];
  };
}

Add platforms and update license

{ stdenv, fetchurl, pkgconfig, libraw1394 }:

stdenv.mkDerivation rec {
  name = "libavc1394-0.5.4";

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

  buildInputs = [ pkgconfig ];
  propagatedBuildInputs = [ libraw1394 ];

  meta = {
    description = "Programming interface for the 1394 Trade Association AV/C (Audio/Video Control) Digital Interface Command Set";
    homepage = http://sourceforge.net/projects/libavc1394/;
    license = stdenv.lib.licenses.lgpl21Plus;
    platforms = stdenv.lib.platforms.linux;
  };
}


{ stdenv, fetchurl, openssl }:

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

  src = fetchurl {
    url = "mirror://sourceforge/uftp-multicast/source-tar/uftp-${version}.tar.gz";
    sha256 = "13y7k6g6jksnllw0mwgzw4dqczh5c5hvq3zlqin7q98m0fpib4ly";
  };

  buildInputs = [ openssl ];

  outputs = [ "out" "man" ];

  patchPhase = ''
    substituteInPlace makefile --replace gcc cc
  '';

  installPhase = ''
    mkdir -p $out/bin $doc/share/man/man1
    cp {uftp,uftpd,uftp_keymgt,uftpproxyd} $out/bin/
    cp {uftp.1,uftpd.1,uftp_keymgt.1,uftpproxyd.1} $doc/share/man/man1
  '';

  meta = {
    description = "Encrypted UDP based FTP with multicast";
    homepage = http://uftp-multicast.sourceforge.net/;
    license = stdenv.lib.licenses.gpl3;
    maintainers = [ stdenv.lib.maintainers.fadenb ];
    platforms = with stdenv.lib.platforms; linux ++ darwin;
  };
}

Fix manpage fallout from previous commits

{ stdenv, fetchurl, openssl }:

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

  src = fetchurl {
    url = "mirror://sourceforge/uftp-multicast/source-tar/uftp-${version}.tar.gz";
    sha256 = "13y7k6g6jksnllw0mwgzw4dqczh5c5hvq3zlqin7q98m0fpib4ly";
  };

  buildInputs = [ openssl ];

  outputs = [ "out" "man" ];

  patchPhase = ''
    substituteInPlace makefile --replace gcc cc
  '';

  installPhase = ''
    mkdir -p $out/bin $man/share/man/man1
    cp {uftp,uftpd,uftp_keymgt,uftpproxyd} $out/bin/
    cp {uftp.1,uftpd.1,uftp_keymgt.1,uftpproxyd.1} $man/share/man/man1
  '';

  meta = {
    description = "Encrypted UDP based FTP with multicast";
    homepage = http://uftp-multicast.sourceforge.net/;
    license = stdenv.lib.licenses.gpl3;
    maintainers = [ stdenv.lib.maintainers.fadenb ];
    platforms = with stdenv.lib.platforms; linux ++ darwin;
  };
}


{ stdenv, fetchurl, tcl, openssl }:

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

  configureFlags = "--with-tcl=" + tcl + "/lib "
                 + "--with-tclinclude=" + tcl + "/include "
                 + "--with-ssl-dir=" + openssl;

  preConfigure = ''
    configureFlags="--exec_prefix=$prefix $configureFlags"
  '';

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

  passthru = {
    libPrefix = "tls${version}";
  };

  buildInputs = [ tcl openssl ];

  meta = {
    homepage = "http://tls.sourceforge.net/";
    description = "An OpenSSL / RSA-bsafe Tcl extension";
    license = stdenv.lib.licenses.tcltk;
    platforms = stdenv.lib.platforms.unix;
  };
}

Fix reference to openssl dev output

{ stdenv, fetchurl, tcl, openssl }:

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

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

  buildInputs = [ tcl openssl ];

  configureFlags = [
    "--with-tcl=${tcl}/lib"
    "--with-tclinclude=${tcl}/include"
    "--with-ssl-dir=${openssl.dev}"
  ];

  preConfigure = ''
    configureFlags="--exec_prefix=$prefix $configureFlags"
  '';

  passthru = {
    libPrefix = "tls${version}";
  };

  meta = {
    homepage = "http://tls.sourceforge.net/";
    description = "An OpenSSL / RSA-bsafe Tcl extension";
    license = stdenv.lib.licenses.tcltk;
    platforms = stdenv.lib.platforms.unix;
  };
}


{ stdenv, fetchurl, ... } @ args:

import ./generic.nix (args // rec {
  version = "3.17-rc2";
  modDirVersion = "3.17.0-rc2";
  extraMeta.branch = "3.17";

  src = fetchurl {
    url = "mirror://kernel/linux/kernel/v3.x/testing/linux-${version}.tar.xz";
    sha256 = "094r4kqp7bj1wcdfsgdmv73law4zb7d0sd8lw82v3rz944mlm9y3";
  };

  kernelPatches = args.kernelPatches ++ [ { name = "3.17-buildfix.patch"; patch = ./3.17-buildfix.patch; } ];

  features.iwlwifi = true;
  features.efiBootStub = true;
  features.needsCifsUtils = true;
  features.canDisableNetfilterConntrackHelpers = true;
  features.netfilterRPFilter = true;

  # Should the testing kernels ever be built on Hydra?
  extraMeta.hydraPlatforms = [];

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

Update testing 3.17-rc2 -> 3.18-rc3

{ stdenv, fetchurl, ... } @ args:

import ./generic.nix (args // rec {
  version = "3.18-rc3";
  modDirVersion = "3.18.0-rc3";
  extraMeta.branch = "3.18";

  src = fetchurl {
    url = "mirror://kernel/linux/kernel/v3.x/testing/linux-${version}.tar.xz";
    sha256 = "1w58szpljzm2ys53fiagqypiw9ylbqf843rwqyv9bwxg5lm1jaq1";
  };

  features.iwlwifi = true;
  features.efiBootStub = true;
  features.needsCifsUtils = true;
  features.canDisableNetfilterConntrackHelpers = true;
  features.netfilterRPFilter = true;

  # Should the testing kernels ever be built on Hydra?
  extraMeta.hydraPlatforms = [];

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


{ stdenv, fetchurl, pythonPackages, pygobject, gst_python
, gst_plugins_good, gst_plugins_base, gst_plugins_ugly
}:

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

  version = "1.1.1";

  src = fetchurl {
    url = "https://github.com/mopidy/mopidy/archive/v${version}.tar.gz";
    sha256 = "1xfyg8xqgnrb98wx7a4fzr4vlzkffjhkc1s36ka63rwmx86vqhyw";
  };

  propagatedBuildInputs = with pythonPackages; [
    gst_python pygobject pykka tornado requests2 gst_plugins_base gst_plugins_good gst_plugins_ugly
  ];

  # There are no tests
  doCheck = false;

  postInstall = ''
    wrapProgram $out/bin/mopidy \
      --prefix GST_PLUGIN_SYSTEM_PATH : "$GST_PLUGIN_SYSTEM_PATH"
  '';

  meta = with stdenv.lib; {
    homepage = http://www.mopidy.com/;
    description = ''
      An extensible music server that plays music from local disk, Spotify,
      SoundCloud, Google Play Music, and more
    '';
    license = licenses.asl20;
    maintainers = [ maintainers.rickynils ];
    hydraPlatforms = [];
  };
}

Fix fetching songs over HTTPS

{ stdenv, fetchurl, pythonPackages, pygobject, gst_python, wrapGAppsHook
, glib_networking, gst_plugins_good, gst_plugins_base, gst_plugins_ugly
}:

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

  version = "1.1.1";

  src = fetchurl {
    url = "https://github.com/mopidy/mopidy/archive/v${version}.tar.gz";
    sha256 = "1xfyg8xqgnrb98wx7a4fzr4vlzkffjhkc1s36ka63rwmx86vqhyw";
  };

  buildInputs = [
    wrapGAppsHook gst_plugins_base gst_plugins_good gst_plugins_ugly glib_networking
  ];

  propagatedBuildInputs = with pythonPackages; [
    gst_python pygobject pykka tornado requests2
  ];

  # There are no tests
  doCheck = false;

  preFixup = ''
    gappsWrapperArgs+=(--prefix GST_PLUGIN_SYSTEM_PATH : "$GST_PLUGIN_SYSTEM_PATH")
  '';

  meta = with stdenv.lib; {
    homepage = http://www.mopidy.com/;
    description = ''
      An extensible music server that plays music from local disk, Spotify,
      SoundCloud, Google Play Music, and more
    '';
    license = licenses.asl20;
    maintainers = [ maintainers.rickynils ];
    hydraPlatforms = [];
  };
}


{ system ? null }:
let this = import ./. { inherit system; };
    reflexEnv = platform: (builtins.getAttr platform this).ghcWithPackages (p: import ./packages.nix { haskellPackages = p; inherit platform; });
in this.nixpkgs.runCommand "shell" {
  buildCommand = ''
    echo "$propagatedBuildInputs $buildInputs $nativeBuildInputs $propagatedNativeBuildInputs" > $out
  '';
  buildInputs = [
    this.nixpkgs.nodejs
    this.nixpkgs.curl
    this.ghc.cabal-install
  ] ++ builtins.map reflexEnv this.platforms;
} ""

Add grunt-cli to build the JS bindings library in blaze-react.

{ system ? null }:
let this = import ./. { inherit system; };
    reflexEnv = platform: (builtins.getAttr platform this).ghcWithPackages (p: import ./packages.nix { haskellPackages = p; inherit platform; });
in this.nixpkgs.runCommand "shell" {
  buildCommand = ''
    echo "$propagatedBuildInputs $buildInputs $nativeBuildInputs $propagatedNativeBuildInputs" > $out
  '';
  buildInputs = [
    this.nixpkgs.nodePackages.grunt-cli
    this.nixpkgs.nodejs
    this.nixpkgs.curl
    this.ghc.cabal-install
  ] ++ builtins.map reflexEnv this.platforms;
} ""


{stdenv, fetchurl, libuuid, popt, devicemapper, libgcrypt }:

stdenv.mkDerivation {
  name = "cryptsetup-1.4.1";
  src = fetchurl {
    url = http://cryptsetup.googlecode.com/files/cryptsetup-1.4.1.tar.bz2;
    sha256 = "82b143328c2b427ef2b89fb76c701d311c95b54093c21bbf22342f7b393bddcb";
  };

  buildInputs = [ libuuid popt devicemapper libgcrypt ];

  meta = {
    homepage = http://code.google.com/p/cryptsetup/;
    description = "LUKS for dm-crypt";
    license = "GPLv2";
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}

Revert cryptsetup update to version 1.4.1.

{stdenv, fetchurl, libuuid, popt, devicemapper, udev }:

stdenv.mkDerivation {
  name = "cryptsetup-1.0.6";
  src = fetchurl {
    url = http://cryptsetup.googlecode.com/files/cryptsetup-1.0.6.tar.bz2;
    sha256 = "df7fda80cfa01f063caf39140287a47d018dfe056fc71a3ba605e690ff0183fd";
  };

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

  patchPhase = ''
    sed -i -e 's@/sbin/udevsettle@${udev}/sbin/udevadm settle@' lib/libdevmapper.c
  '';

  buildInputs = [ libuuid popt devicemapper ];

  meta = {
    homepage = http://code.google.com/p/cryptsetup/;
    description = "LUKS for dm-crypt";
    license = "GPLv2";
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}


{ pkgs ? import <nixpkgs> { } }:

with pkgs;
let
  ghc = haskellPackages.ghcWithPackages (
    ps: with ps; [
      aeson
      array
      base
      bytestring
      containers
      cryptonite
      hashmap
      lens
      parsec
      scientific
      text
    ]
  );
in
stdenv.mkDerivation {
  name = "advent-of-code";

  buildInputs = [
    cargo
    ghc
    pony-corral
    ponyc
    pcre2  # used by the Pony regex library
    python3
    rls
    rustPlatform.rust.rustc
    rustPlatform.rustcSrc
    rustfmt
    swiProlog
    swiftformat
  ];
}

Install ctags to stop ponylang-mode complaining.

{ pkgs ? import <nixpkgs> { } }:

with pkgs;
let
  ghc = haskellPackages.ghcWithPackages (
    ps: with ps; [
      aeson
      array
      base
      bytestring
      containers
      cryptonite
      hashmap
      lens
      parsec
      scientific
      text
    ]
  );
in
stdenv.mkDerivation {
  name = "advent-of-code";

  buildInputs = [
    cargo
    ctags
    ghc
    pony-corral
    ponyc
    pcre2  # used by the Pony regex library
    python3
    rls
    rustPlatform.rust.rustc
    rustPlatform.rustcSrc
    rustfmt
    swiProlog
    swiftformat
  ];
}


pkgs: rec {
  haskellPackages = pkgs.haskellPackages.override {
    overrides = self: super: rec {
      taffybar = pkgs.haskell.lib.overrideCabal (super.taffybar.overrideAttrs (oldAttrs: rec {
        src = fetchGit ./.;
      })) (oldDerivation: {
        libraryHaskellDepends = oldDerivation.libraryHaskellDepends ++ [ self.broadcast-chan ];
      });
      broadcast-chan = pkgs.haskell.lib.overrideCabal super.broadcast-chan (_: {
        version = "0.2.0.2";
        sha256 = "12ax37y9i3cs8wifz01lpq0awm9c235l5xkybf13ywvyk5svb0jv";
        revision = null;
        editedCabalFile = null;
        broken = false;
      });
    };
  };
}

Add nix overrides in a way that preserves those that already exist

pkgs: rec {
  haskellPackages = pkgs.haskellPackages.override (old: {
    overrides = pkgs.lib.composeExtensions (old.overrides or (_: _: {})) (self: super: rec {
      taffybar = pkgs.haskell.lib.overrideCabal (super.taffybar.overrideAttrs (oldAttrs: rec {
        src = fetchGit ./.;
      })) (oldDerivation: {
        libraryHaskellDepends = oldDerivation.libraryHaskellDepends ++ [ self.broadcast-chan ];
      });
      broadcast-chan = pkgs.haskell.lib.overrideCabal super.broadcast-chan (_: {
        version = "0.2.0.2";
        sha256 = "12ax37y9i3cs8wifz01lpq0awm9c235l5xkybf13ywvyk5svb0jv";
        revision = null;
        editedCabalFile = null;
        broken = false;
      });
    });
  });
}


{ stdenv, fetchurl, kdelibs, cmake, gmp, qca2, boost, gettext, qt4, automoc4,
  perl }:

stdenv.mkDerivation rec {
  name = pname + "-" + version;
  pname = "libktorrent";
  version = "1.0.3";

  src = fetchurl {
    url = "${meta.homepage}/downloads/4${builtins.substring 1
      (builtins.stringLength version) version}/${name}.tar.bz2";
    sha256 = "1yfayzbmi7im0pf4g7awn8lqianpr55xwbsldz7lyj9lc1a3xcgs";
  };

# TODO: xfs.h
  propagatedBuildInputs = [ kdelibs gmp boost qt4 ];
  buildInputs = [ cmake automoc4 qca2 gettext perl ];

  meta = {
    description = "A bittorrent library used in ktorrent";
    homepage = http://ktorrent.org;
  };
}

Fix libktorrent compilation with kde-4.4

{ stdenv, fetchurl, kdelibs, cmake, gmp, qca2, boost, gettext, qt4, automoc4,
  perl, phonon }:

stdenv.mkDerivation rec {
  name = pname + "-" + version;
  pname = "libktorrent";
  version = "1.0.3";

  src = fetchurl {
    url = "${meta.homepage}/downloads/4${builtins.substring 1
      (builtins.stringLength version) version}/${name}.tar.bz2";
    sha256 = "1yfayzbmi7im0pf4g7awn8lqianpr55xwbsldz7lyj9lc1a3xcgs";
  };

# TODO: xfs.h
  propagatedBuildInputs = [ kdelibs gmp boost qt4 phonon ];
  buildInputs = [ cmake automoc4 qca2 gettext perl ];

  meta = {
    description = "A bittorrent library used in ktorrent";
    homepage = http://ktorrent.org;
  };
}


# This module provides suggestions of packages to install if the user
# tries to run a missing command in Bash.  This is implemented using a
# SQLite database that maps program names to Nix package names (e.g.,
# "pdflatex" is mapped to "tetex").

{ config, pkgs, ... }:

with pkgs.lib;

let

  commandNotFound = pkgs.substituteAll {
    name = "command-not-found";
    dir = "bin";
    src = ./command-not-found.pl;
    isExecutable = true;
    inherit (pkgs) perl;
    perlFlags = concatStrings (map (path: "-I ${path}/lib/perl5/site_perl ")
      [ pkgs.perlPackages.DBI pkgs.perlPackages.DBDSQLite ]);
  };

in

{

  environment.interactiveShellInit =
    ''
      # This function is called whenever a command is not found.
      command_not_found_handle() {
        local p=/run/current-system/sw/bin/command-not-found
        if [ -x $p -a -f /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite ]; then
          # Run the helper program.
          $p "$1"
          # Retry the command if we just installed it.
          if [ $? = 126 ]; then
            "$@"
          fi
        else
          echo "$1: command not found" >&2
        fi
      }
    '';

  environment.systemPackages = [ commandNotFound ];

  # TODO: tab completion for uninstalled commands! :-)

}

Return exit code 127 if a command is not found

# This module provides suggestions of packages to install if the user
# tries to run a missing command in Bash.  This is implemented using a
# SQLite database that maps program names to Nix package names (e.g.,
# "pdflatex" is mapped to "tetex").

{ config, pkgs, ... }:

with pkgs.lib;

let

  commandNotFound = pkgs.substituteAll {
    name = "command-not-found";
    dir = "bin";
    src = ./command-not-found.pl;
    isExecutable = true;
    inherit (pkgs) perl;
    perlFlags = concatStrings (map (path: "-I ${path}/lib/perl5/site_perl ")
      [ pkgs.perlPackages.DBI pkgs.perlPackages.DBDSQLite ]);
  };

in

{

  environment.interactiveShellInit =
    ''
      # This function is called whenever a command is not found.
      command_not_found_handle() {
        local p=/run/current-system/sw/bin/command-not-found
        if [ -x $p -a -f /nix/var/nix/profiles/per-user/root/channels/nixos/programs.sqlite ]; then
          # Run the helper program.
          $p "$1"
          # Retry the command if we just installed it.
          if [ $? = 126 ]; then
            "$@"
          else
            return 127
          fi
        else
          echo "$1: command not found" >&2
          return 127
        fi
      }
    '';

  environment.systemPackages = [ commandNotFound ];

  # TODO: tab completion for uninstalled commands! :-)

}


{ stdenv, fetchurl, libuuid, libselinux }:
let
  sourceInfo = rec {
    version = "2.2.4";
    url = "http://nilfs.sourceforge.net/download/nilfs-utils-${version}.tar.bz2";
    sha256 = "1ywmhrf6dz5g3ik4wf3hlnzmv1qa0q2qrgh3ir1pmbdhlgmkxdhm";
    baseName = "nilfs-utils";
    name = "${baseName}-${version}";
  };
in
stdenv.mkDerivation rec {
  src = fetchurl {
    url = sourceInfo.url;
    sha256 = sourceInfo.sha256;
  };

  inherit (sourceInfo) name version;
  buildInputs = [libuuid libselinux];

  preConfigure = ''
    sed -e '/sysconfdir=\/etc/d; ' -i configure
    sed -e "s@sbindir=/sbin@sbindir=$out/sbin@" -i configure
    sed -e 's@/sbin/@'"$out"'/sbin/@' -i ./lib/cleaner*.c
  '';

  meta = {
    description = "NILFS utilities";
    maintainers = with stdenv.lib.maintainers;
    [
      raskin
    ];
    platforms = with stdenv.lib.platforms;
      linux;
    downloadPage = "http://nilfs.sourceforge.net/en/download.html";
    updateWalker = true;
    inherit version;
  };
}

Set dontPatchELF due to broken RPATH by patchelf

{ stdenv, fetchurl, libuuid, libselinux }:
let
  sourceInfo = rec {
    version = "2.2.4";
    url = "http://nilfs.sourceforge.net/download/nilfs-utils-${version}.tar.bz2";
    sha256 = "1ywmhrf6dz5g3ik4wf3hlnzmv1qa0q2qrgh3ir1pmbdhlgmkxdhm";
    baseName = "nilfs-utils";
    name = "${baseName}-${version}";
  };
in
stdenv.mkDerivation rec {
  src = fetchurl {
    url = sourceInfo.url;
    sha256 = sourceInfo.sha256;
  };

  inherit (sourceInfo) name version;
  buildInputs = [libuuid libselinux];

  preConfigure = ''
    sed -e '/sysconfdir=\/etc/d; ' -i configure
    sed -e "s@sbindir=/sbin@sbindir=$out/sbin@" -i configure
    sed -e 's@/sbin/@'"$out"'/sbin/@' -i ./lib/cleaner*.c
  '';

  # FIXME: Remove after https://github.com/NixOS/patchelf/pull/98 is in
  dontPatchELF = true;

  meta = {
    description = "NILFS utilities";
    maintainers = with stdenv.lib.maintainers;
    [
      raskin
    ];
    platforms = with stdenv.lib.platforms;
      linux;
    downloadPage = "http://nilfs.sourceforge.net/en/download.html";
    updateWalker = true;
  };
}


{ pkgs ? (import <nixpkgs> {}) }:

let
  env = with pkgs.rustStable; [
    rustc
    cargo
  ];
in

pkgs.stdenv.mkDerivation rec {
    name = "imag";
    src = ./.;
    version = "0.0.0";

    buildInputs = [ env ];

}

Add dependencies for imag: openssl, zlib, cmake

{ pkgs ? (import <nixpkgs> {}) }:

let
  env = with pkgs.rustStable; [
    rustc
    cargo
  ];

  dependencies = with pkgs; [
    openssl
    zlib
    cmake
  ];
in

pkgs.stdenv.mkDerivation rec {
    name = "imag";
    src = ./.;
    version = "0.0.0";

    buildInputs = [ env dependencies ];

}


# This script is used for building the program on NixOS with the proper dependencies.
# To use, simply run nix-shell in this directory and run "cargo build" as you normally would.

with import <nixpkgs> {};

stdenv.mkDerivation {
    name = "anup";
    buildInputs = [ pkgconfig openssl zlib ];
}

Fix incorrect build inputs for NixOS build script

# This script is used for building the program on NixOS with the proper dependencies.
# To use, simply run nix-shell in this directory and run "cargo build" as you normally would.

with import <nixpkgs> {};

stdenv.mkDerivation {
    name = "anup";
    buildInputs = [ pkgconfig openssl gcc ];
}


{ stdenv, fetchgit, SDL }:

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

  src = fetchgit {
    url = "git://linuxconsole.git.sourceforge.net/gitroot/linuxconsole/linuxconsole";
    rev = "dac2cae0e5795ddc27b76a92767dd9e07a10621e";
    sha256 = "350b008e614923dbd548fcaaf2842b39433acdcf595e2ce8aaf1599f076d331d";
  };

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

  meta = {
    homepage = "https://sourceforge.net/projects/linuxconsole/";
    description = "A set of tools for joysticks and serial peripherals";
    license = stdenv.lib.licenses.gpl2Plus;

    longDescription = ''
      The included tools are:

      ffcfstress(1)  - force-feedback stress test
      ffmvforce(1)   - force-feedback orientation test
      ffset(1)       - force-feedback configuration tool
      fftest(1)      - general force-feedback test
      jstest(1)      - joystick test
      jscal(1)       - joystick calibration tool
      inputattach(1) - connects legacy serial devices to the input layer
    '';
  };
}

Update consoletools from 1.4.3 -> 1.4.6

{ stdenv, fetchurl, SDL }:

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

  src = fetchurl {
    url = "mirror://sourceforge/linuxconsole/${name}.tar.bz2";
    sha256 = "0035yhjbjdis5wqmbdz67xq61065x7vrx5mb7kb1rhrx3ag43wcf";
  };

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

  meta = {
    homepage = "https://sourceforge.net/projects/linuxconsole/";
    description = "A set of tools for joysticks and serial peripherals";
    license = stdenv.lib.licenses.gpl2Plus;

    longDescription = ''
      The included tools are:

      ffcfstress(1)  - force-feedback stress test
      ffmvforce(1)   - force-feedback orientation test
      ffset(1)       - force-feedback configuration tool
      fftest(1)      - general force-feedback test
      jstest(1)      - joystick test
      jscal(1)       - joystick calibration tool
      inputattach(1) - connects legacy serial devices to the input layer
    '';
  };
}


{ stdenv, fetchurl, glib, qt4, pkgconfig, libnl, pygobject, python }:

let
  version = "014";
in

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

  src = fetchurl {
    url = "http://launchpad.net/ntrack/main/${version}/+download/${name}.tar.gz";
    sha256 = "1aqn3q0dj2kk0j9rf02qgbfghlykaas7q0g8wxyz7nd6zg4qhyj2";
  };

  buildInputs = [ libnl qt4 ];

  buildNativeInputs = [ pkgconfig python ];

  configureFlags = "--without-gobject CFLAGS=--std=gnu99";

  postPatch = ''
    sed -e "s@/usr\(/lib/ntrack/modules/\)@$out&@" -i common/ntrack.c
    '';
}

Apply upstream patches to ntrack\n\nProbably fixes 100% CPU problem in kded module

{ stdenv, fetchurl, glib, qt4, pkgconfig, libnl, pygobject, python, automake
, autoconf }:

let
  version = "014";
in

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

  src = fetchurl {
    url = "http://launchpad.net/ntrack/main/${version}/+download/${name}.tar.gz";
    sha256 = "1aqn3q0dj2kk0j9rf02qgbfghlykaas7q0g8wxyz7nd6zg4qhyj2";
  };

  buildInputs = [ libnl qt4 ];

  buildNativeInputs = [ pkgconfig python automake autoconf ];

  configureFlags = "--without-gobject CFLAGS=--std=gnu99";

  patchP0 = fetchurl {
    url = http://bazaar.launchpad.net/~asac/ntrack/main/diff/312/309;
    name = "ntrack-bzr-309-to-312.patch";
    sha256 = "1bpjpikln2i7nsmd2gl82g08yzaqac311sgsva7z7pqccxz0vsj5";
  };

  patchP1 = fetchurl {
    url = "https://bugs.launchpad.net/ntrack/+bug/750554/+attachment/2291609/+files/ntrack_libnl_link.diff";
    sha256 = "1al6wfjph7nmck1q2q2z98cnzcrwpln2wwh45xynsxr6wgczwck6";
  };

  patchPhase =
    ''
      patch -p0 < ${patchP0}
      patch -p1 < ${patchP1}
      sed -e "s@/usr\(/lib/ntrack/modules/\)@$out&@" -i common/ntrack.c
    '';

  preConfigure = "automake"; # The second patch changes Makefile.am files
}


{ stdenv, fetchurl, pkgconfig, fuse, scons }:

stdenv.mkDerivation rec {
  name = "fuse-exfat-1.0.1";

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

  buildInputs = [ pkgconfig fuse scons ];

  buildPhase = ''
    export CCFLAGS="-O2 -Wall -std=c99 -I${fuse}/include"
    export LDFLAGS="-L${fuse}/lib"
    mkdir -pv $out/sbin
    scons DESTDIR=$out/sbin install
  '';

  installPhase = ":";

  meta = {
    homepage = http://code.google.com/p/exfat/;
    description = "A FUSE-based filesystem that allows read and write access to exFAT devices";
    platforms = stdenv.lib.platforms.linux;
    license = stdenv.lib.licenses.gpl2;
  };
}

Update fuse-exfat 1.0.1 -> 1.1.0

{ stdenv, fetchurl, pkgconfig, fuse, scons }:

stdenv.mkDerivation rec {
  name = "fuse-exfat-1.1.0";

  src = fetchurl {
    sha256 = "0glmgwrf0nv09am54i6s35ksbvrywrwc51w6q32mv5by8475530r";
    url = "https://docs.google.com/uc?export=download&id=0B7CLI-REKbE3VTdaa0EzTkhYdU0";
    name = "${name}.tar.gz";
  };

  buildInputs = [ pkgconfig fuse scons ];

  buildPhase = ''
    export CCFLAGS="-O2 -Wall -std=c99 -I${fuse}/include"
    export LDFLAGS="-L${fuse}/lib"
    mkdir -pv $out/sbin
    scons DESTDIR=$out/sbin install
  '';

  installPhase = ":";

  meta = with stdenv.lib; {
    homepage = http://code.google.com/p/exfat/;
    description = "A FUSE-based filesystem that allows read and write access to exFAT devices";
    platforms = with platforms; linux;
    license = with licenses; gpl2Plus;
    maintainers = with maintainers; [ nckx ];
  };
}


with import <nixpkgs> {};
stdenv.mkDerivation rec {

  name = "nix-cage";

  nativeBuildInputs = [ makeWrapper ];

  src = fetchFromGitHub {
    owner  = "corpix";
    repo   = name;
    rev    = "a731efaabcb67a4e9db933f452b7681229d64baa";
    sha256 = "1fn4wx6pjmy899qjg7nq0sm66ky3ll69mdica0h7577sgsldm9cm";
  };

  installPhase = ''
    source $stdenv/setup
    set -e

    mkdir -p $out/bin
    cp       $src/${name}    $out/bin
    chmod +x $out/bin/${name}

    wrapProgram $out/bin/${name} --prefix PATH : ${stdenv.lib.makeBinPath [
      python36
      bubblewrap
      nix
    ]}
  '';

  meta = {
    homepage = https://github.com/corpix/nix-cage;
    description = "Sandboxed environments with nix-shell";

    longDescription = ''
      Sandboxed environments with bwrap and nix-shell
    '';

    license = stdenv.lib.licenses.mit;
    platforms = stdenv.lib.platforms.all;
  };
}

Use patchShebangs instead of making a wrapper

with import <nixpkgs> {};
stdenv.mkDerivation rec {

  name = "nix-cage";

  buildInputs = [ python36 bubblewrap nix ];

  src = fetchFromGitHub {
    owner  = "corpix";
    repo   = name;
    rev    = "a731efaabcb67a4e9db933f452b7681229d64baa";
    sha256 = "1fn4wx6pjmy899qjg7nq0sm66ky3ll69mdica0h7577sgsldm9cm";
  };

  buildPhase = ''
    patchShebangs .
  '';

  installPhase = ''
    source $stdenv/setup
    set -e

    mkdir -p $out/bin
    cp       $src/${name}    $out/bin
    chmod +x $out/bin/${name}
  '';

  meta = {
    homepage = https://github.com/corpix/nix-cage;
    description = "Sandboxed environments with nix-shell";

    longDescription = ''
      Sandboxed environments with bwrap and nix-shell
    '';

    license = stdenv.lib.licenses.mit;
    platforms = stdenv.lib.platforms.all;
  };
}


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

Correct relative path to xdg-open-brief.patch

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


{ composableDerivation, fetchurl, yacc, flex, texLive }:

let edf = composableDerivation.edf; in

composableDerivation.composableDerivation {} rec {
  name="avrdude-5.10";

  src = fetchurl {
    url = "http://download.savannah.gnu.org/releases/avrdude/${name}.tar.gz";
    sha256 = "0pmy73777x8p7f2aj2w2q1dnk1bvhd1cm7hcs1s9hsdqsmiinl41";
  };

  configureFlags = [ "--disable-dependency-tracking" ];

  buildInputs = [ yacc flex ];

  flags =
       edf { name = "doc"; enable = { buildInputs = texLive; configureFlags = ["--enable-doc"]; }; }
    // edf { name = "parport"; };

  cfg = {
    docSupport = false; # untested
    parportSupport = true;
  };

  meta = {
    license = "GPL-2";
    description = "AVR Downloader/UploaDEr";
    homepage = http://savannah.nongnu.org/projects/avrdude;
  };
}

Add libusb to enable USB support

{ composableDerivation, fetchurl, yacc, flex, texLive, libusb }:

let edf = composableDerivation.edf; in

composableDerivation.composableDerivation {} rec {
  name="avrdude-5.10";

  src = fetchurl {
    url = "http://download.savannah.gnu.org/releases/avrdude/${name}.tar.gz";
    sha256 = "0pmy73777x8p7f2aj2w2q1dnk1bvhd1cm7hcs1s9hsdqsmiinl41";
  };

  configureFlags = [ "--disable-dependency-tracking" ];

  buildInputs = [ yacc flex libusb ];

  flags =
       edf { name = "doc"; enable = { buildInputs = texLive; configureFlags = ["--enable-doc"]; }; }
    // edf { name = "parport"; };

  cfg = {
    docSupport = false; # untested
    parportSupport = true;
  };

  meta = {
    license = "GPL-2";
    description = "AVR Downloader/UploaDEr";
    homepage = http://savannah.nongnu.org/projects/avrdude;
  };
}


{ callPackage, fetchurl, coq }:

let param =
  {
    version = "1.6.1";
    url = https://github.com/math-comp/math-comp/archive/mathcomp-1.6.1.tar.gz;
    sha256 = "1j9ylggjzrxz1i2hdl2yhsvmvy5z6l4rprwx7604401080p5sgjw";
  }; in

callPackage ./generic.nix {
  name = "coq${coq.coq-version}-ssreflect-${param.version}";
  src = fetchurl { inherit (param) url sha256; };
}

Build version 0.6.4 for Coq 8.6 and 8.7

{ callPackage, fetchurl, coq }:

let param =
  {
    "8.4" =  {
      version = "1.6.1";
      url = https://github.com/math-comp/math-comp/archive/mathcomp-1.6.1.tar.gz;
      sha256 = "1j9ylggjzrxz1i2hdl2yhsvmvy5z6l4rprwx7604401080p5sgjw";
    };

    "8.5" =  {
      version = "1.6.1";
      url = https://github.com/math-comp/math-comp/archive/mathcomp-1.6.1.tar.gz;
      sha256 = "1j9ylggjzrxz1i2hdl2yhsvmvy5z6l4rprwx7604401080p5sgjw";
    };

    "8.6" =  {
      version = "1.6.4";
      url = https://github.com/math-comp/math-comp/archive/mathcomp-1.6.4.tar.gz;
      sha256 = "0qmjjb6jsxmmf4gpw10r30rmrvwqgzirvvgyy41mz2vhgwis8wn6";
    };

    "8.7" = {
      version = "1.6.4";
      url = https://github.com/math-comp/math-comp/archive/mathcomp-1.6.4.tar.gz;
      sha256 = "0qmjjb6jsxmmf4gpw10r30rmrvwqgzirvvgyy41mz2vhgwis8wn6";
    };

  }."${coq.coq-version}"
; in

callPackage ./generic.nix {
  name = "coq${coq.coq-version}-ssreflect-${param.version}";
  src = fetchurl { inherit (param) url sha256; };
}


{ stdenv, fetchgit }:

stdenv.mkDerivation {
  name = "wavegain-1.3.1";
  src = fetchgit {
    url = "https://github.com/MestreLion/wavegain.git";
    sha256 = "1h886xijc9d7h4p6qx12c6kgwmp6s1bdycnyylkayfncczzlbi24";
  };

  installPhase = ''
    strip -s wavegain
    install -vD wavegain "$out/bin/wavegain"
  '';

  meta = {
    description = "ReplayGain for wave files";
    homepage = https://github.com/MestreLion/wavegain;
    license = stdenv.lib.licenses.lgpl21;
    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.robbinch ];
  };
}

Use fetchFromGitHub instead of fetchgit.

{ stdenv, fetchFromGitHub }:

stdenv.mkDerivation {
  name = "wavegain-1.3.1";
  src = fetchFromGitHub {
    owner = "MestreLion";
    repo = "wavegain";
    rev = "c928eaf97aeec5732625491b64c882e08e314fee";
    sha256 = "0wghqnsbypmr4xcrhb568bfjdnxzzp8qgnws3jslzmzf34dpk5ls";
  };

  installPhase = ''
    strip -s wavegain
    install -vD wavegain "$out/bin/wavegain"
  '';

  meta = {
    description = "ReplayGain for wave files";
    homepage = https://github.com/MestreLion/wavegain;
    license = stdenv.lib.licenses.lgpl21;
    platforms = stdenv.lib.platforms.linux;
    maintainers = [ stdenv.lib.maintainers.robbinch ];
  };
}


{ lib, buildGoModule, fetchFromGitHub }:

buildGoModule rec {
  name = "do-agent-${version}";
  version = "3.5.6";

  src = fetchFromGitHub {
    owner = "digitalocean";
    repo = "do-agent";
    rev = "${version}";
    sha256 = "1gl034cslqa30fqy2p9rymgx398s1rcgbmfvzk5zjlrw47327k8i";
  };

  buildFlagsArray = ''
    -ldflags=
      -X main.version=${version}
  '';

  modSha256 = "0ydjwxdkcz0blpzwapiaq66vh7nrcg4j91z6h7v4ynnw2rgp7pmy";

  meta = with lib; {
    description = ''
      Collects system metrics from a DigitalOcean Droplet (on which the program
      runs) and sends them to DigitalOcean
    '';
    homepage = https://github.com/digitalocean/do-agent;
    license = licenses.asl20;
    maintainers = with maintainers; [ yvt ];
    platforms = platforms.linux;
  };
}

Use pname instead of name

{ lib, buildGoModule, fetchFromGitHub }:

buildGoModule rec {
  pname = "do-agent";
  version = "3.5.6";

  src = fetchFromGitHub {
    owner = "digitalocean";
    repo = "do-agent";
    rev = "${version}";
    sha256 = "1gl034cslqa30fqy2p9rymgx398s1rcgbmfvzk5zjlrw47327k8i";
  };

  buildFlagsArray = ''
    -ldflags=
      -X main.version=${version}
  '';

  modSha256 = "0ydjwxdkcz0blpzwapiaq66vh7nrcg4j91z6h7v4ynnw2rgp7pmy";

  meta = with lib; {
    description = ''
      Collects system metrics from a DigitalOcean Droplet (on which the program
      runs) and sends them to DigitalOcean
    '';
    homepage = https://github.com/digitalocean/do-agent;
    license = licenses.asl20;
    maintainers = with maintainers; [ yvt ];
    platforms = platforms.linux;
  };
}


{ qt5 }:

let
  mkTelegram = args: qt5.callPackage (import ./generic.nix args) { };
  stableVersion = {
    stable = true;
    version = "1.7.7";
    sha256Hash = "0w3jq02qzpx58xlmwaj0lgav5lx6s9hdidnq9v1npp4qmpdnsn75";
    # svn log svn://svn.archlinux.org/community/telegram-desktop/trunk
    archPatchesRevision = "476826";
    archPatchesHash = "1vnlvba60hxd5jlh0fvsa50xmb9xgcphdsx6j1ld7f12m7ik68zr";
  };
in {
  stable = mkTelegram stableVersion;
  preview = mkTelegram (stableVersion // {
    stable = false;
  });
}

Update the Arch patches for a HiDPI fix

{ qt5 }:

let
  mkTelegram = args: qt5.callPackage (import ./generic.nix args) { };
  stableVersion = {
    stable = true;
    version = "1.7.7";
    sha256Hash = "0w3jq02qzpx58xlmwaj0lgav5lx6s9hdidnq9v1npp4qmpdnsn75";
    # svn log svn://svn.archlinux.org/community/telegram-desktop/trunk
    archPatchesRevision = "480743";
    archPatchesHash = "0jfyp642l2850yzgrw3irq8bn6vl44rx2693c5cshwbihd212af7";
  };
in {
  stable = mkTelegram stableVersion;
  preview = mkTelegram (stableVersion // {
    stable = false;
  });
}


{ stdenv, fetchPypi, buildPythonPackage, persistent, zope_interface, transaction }:

buildPythonPackage rec {
  pname = "BTrees";
  version = "4.4.1";
  name = "${pname}-${version}";

  propagatedBuildInputs = [ persistent zope_interface transaction ];

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

  meta = with stdenv.lib; {
    description = "Scalable persistent components";
    homepage = http://packages.python.org/BTrees;
    license = licenses.zpt21;
  };
}

Add missing build-time only dependencies

{ stdenv, fetchPypi, buildPythonPackage, persistent, zope_interface, transaction }:

buildPythonPackage rec {
  pname = "BTrees";
  version = "4.4.1";
  name = "${pname}-${version}";

  buildInputs = [ transaction ];
  propagatedBuildInputs = [ persistent zope_interface ];

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

  meta = with stdenv.lib; {
    description = "Scalable persistent components";
    homepage = http://packages.python.org/BTrees;
    license = licenses.zpt21;
  };
}


{ lib, fetchFromGitHub, buildPythonPackage, six, pyudev, pygobject3 }:

buildPythonPackage rec {
  pname = "rtslib";
  version = "2.1.75";

  src = fetchFromGitHub {
    owner = "open-iscsi";
    repo = "${pname}-fb";
    rev = "refs/tags/v${version}";
    sha256 = "sha256-qBlr4K+LeJIC6Hwy6dN9n/VjHIUYCy8pLlRtPvooWyE=";
  };

  propagatedBuildInputs = [ six pyudev pygobject3 ];

  meta = with lib; {
    description = "A Python object API for managing the Linux LIO kernel target";
    homepage = "https://github.com/open-iscsi/rtslib-fb";
    license = licenses.asl20;
  };
}

Add patch to fix import check

{ lib, fetchFromGitHub, fetchpatch, buildPythonPackage, six, pyudev, pygobject3 }:

buildPythonPackage rec {
  pname = "rtslib";
  version = "2.1.75";

  src = fetchFromGitHub {
    owner = "open-iscsi";
    repo = "${pname}-fb";
    rev = "refs/tags/v${version}";
    sha256 = "sha256-qBlr4K+LeJIC6Hwy6dN9n/VjHIUYCy8pLlRtPvooWyE=";
  };

  patches = [
    # <https://github.com/open-iscsi/rtslib-fb/pull/187>
    (fetchpatch {
      url = "https://github.com/zhaofengli/rtslib-fb/commit/1c3c8257940a88e65676f4333363ddf259a06723.patch";
      sha256 = "sha256-nDzL8pUKwKIej+6rOg7Om5AkwkClKk6qKlImbpoufz4=";
    })
  ];

  propagatedBuildInputs = [ six pyudev pygobject3 ];

  meta = with lib; {
    description = "A Python object API for managing the Linux LIO kernel target";
    homepage = "https://github.com/open-iscsi/rtslib-fb";
    license = licenses.asl20;
  };
}


{ lib, stdenv, fetchzip, makeWrapper, mono }:

stdenv.mkDerivation rec {
  pname = "juniper";
  version = "2.3.0";

  src = fetchzip {
    url = "http://www.juniper-lang.org/installers/Juniper-${version}.zip";
    sha256 = "10am6fribyl7742yk6ag0da4rld924jphxja30gynzqysly8j0vg";
    stripRoot = false;
  };

  doCheck = true;

  nativeBuildInputs = [ makeWrapper ];

  buildInputs = [ mono ];

  installPhase = ''
    runHook preInstall
    rm juniper # original script with regular Linux assumptions
    mkdir -p $out/bin
    cp -r ./* $out
    makeWrapper ${mono}/bin/mono $out/bin/juniper \
      --add-flags "$out/Juniper.exe \$@"
    runHook postInstall
  '';

  meta = with lib; {
    description = "Functional reactive programming language for programming Arduino";
    longDescription = ''
      Juniper targets Arduino and supports many features typical of functional programming languages, including algebraic data types, tuples, records,
      pattern matching, immutable data structures, parametric polymorphic functions, and anonymous functions (lambdas).
      Some imperative programming concepts are also present in Juniper, such as for, while and do while loops, the ability to mark variables as mutable, and mutable references.
    '';
    homepage = "https://www.juniper-lang.org/";
    license = licenses.mit;
    maintainers = with maintainers; [ wunderbrick ];
    platforms = platforms.linux;
  };
}

Remove wunderbrick from juniper maintainers

{ lib, stdenv, fetchzip, makeWrapper, mono }:

stdenv.mkDerivation rec {
  pname = "juniper";
  version = "2.3.0";

  src = fetchzip {
    url = "http://www.juniper-lang.org/installers/Juniper-${version}.zip";
    sha256 = "10am6fribyl7742yk6ag0da4rld924jphxja30gynzqysly8j0vg";
    stripRoot = false;
  };

  doCheck = true;

  nativeBuildInputs = [ makeWrapper ];

  buildInputs = [ mono ];

  installPhase = ''
    runHook preInstall
    rm juniper # original script with regular Linux assumptions
    mkdir -p $out/bin
    cp -r ./* $out
    makeWrapper ${mono}/bin/mono $out/bin/juniper \
      --add-flags "$out/Juniper.exe \$@"
    runHook postInstall
  '';

  meta = with lib; {
    description = "Functional reactive programming language for programming Arduino";
    longDescription = ''
      Juniper targets Arduino and supports many features typical of functional programming languages, including algebraic data types, tuples, records,
      pattern matching, immutable data structures, parametric polymorphic functions, and anonymous functions (lambdas).
      Some imperative programming concepts are also present in Juniper, such as for, while and do while loops, the ability to mark variables as mutable, and mutable references.
    '';
    homepage = "https://www.juniper-lang.org/";
    license = licenses.mit;
    maintainers = with maintainers; [ ];
    platforms = platforms.linux;
  };
}


{ stdenv, fetchurl, groff }:

stdenv.mkDerivation rec {
  name = "mdadm-3.3";

  src = fetchurl {
    url = "mirror://kernel/linux/utils/raid/mdadm/${name}.tar.bz2";
    sha256 = "0igdqflihiq1dp5qlypzw0xfl44f4n3bckl7r2x2wfgkplcfa1ww";
  };

  nativeBuildInputs = [ groff ];

  preConfigure = "sed -e 's@/lib/udev@\${out}/lib/udev@' -e 's@ -Werror @ @' -i Makefile";

  # Force mdadm to use /var/run/mdadm.map for its map file (or
  # /dev/.mdadm/map as a fallback).
  preBuild =
    ''
      makeFlagsArray=(INSTALL=install BINDIR=$out/sbin MANDIR=$out/share/man RUN_DIR=/dev/.mdadm)
      if [[ -n "$crossConfig" ]]; then
        makeFlagsArray+=(CROSS_COMPILE=$crossConfig-)
      fi
    '';

  preInstall =
    ''
    substituteInPlace udev-md-raid-assembly.rules --replace "/sbin/mdadm" "$out/sbin/mdadm"
    substituteInPlace udev-md-raid-arrays.rules --replace "/sbin/mdadm" "$out/sbin/mdadm"
    '';

  meta = {
    description = "Programs for managing RAID arrays under Linux";
    homepage = http://neil.brown.name/blog/mdadm;
  };
}

Revert "Update path in udev rule of mdadm"

{ stdenv, fetchurl, groff }:

stdenv.mkDerivation rec {
  name = "mdadm-3.3";

  src = fetchurl {
    url = "mirror://kernel/linux/utils/raid/mdadm/${name}.tar.bz2";
    sha256 = "0igdqflihiq1dp5qlypzw0xfl44f4n3bckl7r2x2wfgkplcfa1ww";
  };

  nativeBuildInputs = [ groff ];

  preConfigure = "sed -e 's@/lib/udev@\${out}/lib/udev@' -e 's@ -Werror @ @' -i Makefile";

  # Force mdadm to use /var/run/mdadm.map for its map file (or
  # /dev/.mdadm/map as a fallback).
  preBuild =
    ''
      makeFlagsArray=(INSTALL=install BINDIR=$out/sbin MANDIR=$out/share/man RUN_DIR=/dev/.mdadm)
      if [[ -n "$crossConfig" ]]; then
        makeFlagsArray+=(CROSS_COMPILE=$crossConfig-)
      fi
    '';

  meta = {
    description = "Programs for managing RAID arrays under Linux";
    homepage = http://neil.brown.name/blog/mdadm;
  };
}


{ stdenv, fetchgit }:

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

  src = fetchgit {
    url = "https://git.sr.ht/~sircmpwn/scdoc";
    rev = version;
    sha256 = "0fm3x6ma1pzlajfcy32ayqrcab8lwl64nxfaqgc6019mxw87y1ja";
  };

  postPatch = ''
    substituteInPlace Makefile \
      --replace "-static" "" \
      --replace "/usr/local" "$out"
    # It happens from time to time that the version wasn't updated:
    sed -iE 's/VERSION=[0-9]\.[0-9]\.[0-9]/VERSION=${version}/' Makefile
  '';

  doCheck = true;

  meta = with stdenv.lib; {
    description = "A simple man page generator";
    longDescription = ''
      scdoc is a simple man page generator written for POSIX systems written in
      C99.
    '';
    homepage = https://git.sr.ht/~sircmpwn/scdoc/;
    license = licenses.mit;
    platforms = platforms.unix;
    maintainers = with maintainers; [ primeos ];
  };
}

Update the URLs (homepage and download)

{ stdenv, fetchurl }:

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

  src = fetchurl {
    url = "https://git.sr.ht/~sircmpwn/scdoc/archive/${version}.tar.gz";
    sha256 = "0hcwpyy97afwq40qn8jq75f1b2p0172lil1v0hs9a0rislpqk5nm";
  };

  postPatch = ''
    substituteInPlace Makefile \
      --replace "-static" "" \
      --replace "/usr/local" "$out"
    # It happens from time to time that the version wasn't updated:
    sed -iE 's/VERSION=[0-9]\.[0-9]\.[0-9]/VERSION=${version}/' Makefile
  '';

  doCheck = true;

  meta = with stdenv.lib; {
    description = "A simple man page generator";
    longDescription = ''
      scdoc is a simple man page generator written for POSIX systems written in
      C99.
    '';
    homepage = https://git.sr.ht/~sircmpwn/scdoc;
    license = licenses.mit;
    platforms = platforms.unix;
    maintainers = with maintainers; [ primeos ];
  };
}


{ stdenv, fetchurl, gettext, libnl, ncurses, pciutils, pkgconfig, zlib }:

stdenv.mkDerivation rec {
  name = "powertop-2.6.1";

  src = fetchurl {
    url = "https://01.org/sites/default/files/downloads/powertop/${name}.tar.gz";
    sha256 = "1r103crmkdk617qrxqjzy2mlhaacbpg5q795546zwcxlbdnxwk03";
  };

  buildInputs = [ gettext libnl ncurses pciutils pkgconfig zlib ];

  meta = {
    description = "Analyze power consumption on Intel-based laptops";
    license = stdenv.lib.licenses.gpl2;
    maintainers = [ stdenv.lib.maintainers.chaoflow ];
    platforms = stdenv.lib.platforms.linux;
  };
}

Update Powertop: 2.6.1 -> 2.7

{ stdenv, fetchurl, gettext, libnl, ncurses, pciutils, pkgconfig, zlib }:

stdenv.mkDerivation rec {
  name = "powertop-2.7";

  src = fetchurl {
    url = "https://01.org/sites/default/files/downloads/powertop/${name}.tar.gz";
    sha256 = "1jkqqr3l1x98m7rgin1dgfzxqwj4vciw9lyyq1kl9bdswa818jwd";
  };

  buildInputs = [ gettext libnl ncurses pciutils pkgconfig zlib ];

  meta = {
    description = "Analyze power consumption on Intel-based laptops";
    license = stdenv.lib.licenses.gpl2;
    maintainers = [ stdenv.lib.maintainers.chaoflow ];
    platforms = stdenv.lib.platforms.linux;
  };
}


# VirtualBox server
{ config, pkgs, ... }:

with pkgs.lib;

let

  cfg = config.services.virtualbox;

in

{

  ###### interface

  options = {

    services.virtualbox = {

      enable = mkOption {
        default = false;
        description = "Whether to enable the VirtualBox service and other guest additions.";
      };

    };

  };

  ###### implementation

  config = mkIf cfg.enable {

    environment.systemPackages = [ ];

    boot.extraModulePackages = [ pkgs.linuxPackages.virtualboxGuestAdditions ];

    jobs.virtualbox =
      { description = "VirtualBox service";

        startOn = "started udev";

        exec = "${pkgs.linuxPackages.virtualboxGuestAdditions}/sbin/VBoxService";
      };

  };

}

Make VirtualBox Guest Additions use the configured kernel.

# VirtualBox server
{ config, pkgs, ... }:

with pkgs.lib;

let

  cfg = config.services.virtualbox;
  kernel = config.boot.kernelPackages;

in

{

  ###### interface

  options = {

    services.virtualbox = {

      enable = mkOption {
        default = false;
        description = "Whether to enable the VirtualBox service and other guest additions.";
      };

    };

  };

  ###### implementation

  config = mkIf cfg.enable {

    environment.systemPackages = [ ];

    boot.extraModulePackages = [ kernel.virtualboxGuestAdditions ];

    jobs.virtualbox =
      { description = "VirtualBox service";

        startOn = "started udev";

        exec = "${kernel.virtualboxGuestAdditions}/sbin/VBoxService";
      };

  };

}


{ stdenv, fetchFromGitHub, autoreconfHook, flex }:

stdenv.mkDerivation rec {
  pname = "libconfuse";
  version = "3.3";

  src = fetchFromGitHub {
    sha256 = "1npfk5jv59kk4n8pkyx89fn9s6p8x3gbffs42jaw24frgxfgp8ca";
    rev = "v${version}";
    repo = "libconfuse";
    owner = "martinh";
  };

  nativeBuildInputs = [ autoreconfHook flex ];

  enableParallelBuilding = true;

  # On darwin the tests depend on the installed libraries because of install_name.
  doInstallCheck = true;
  installCheckTarget = "check";

  meta = with stdenv.lib; {
    inherit (src.meta) homepage;
    description = "Small configuration file parser library for C";
    longDescription = ''
      libConfuse (previously libcfg) is a configuration file parser library
      written in C. It supports sections and (lists of) values, as well as
      some other features. It makes it very easy to add configuration file
      capability to a program using a simple API.

      The goal of libConfuse is not to be the configuration file parser library
      with a gazillion of features. Instead, it aims to be easy to use and
      quick to integrate with your code.
    '';
    license = licenses.isc;
    platforms = platforms.linux ++ platforms.darwin;
  };
}

Disable failing tests on darwin

{ stdenv, fetchFromGitHub, autoreconfHook, flex }:

stdenv.mkDerivation rec {
  pname = "libconfuse";
  version = "3.3";

  src = fetchFromGitHub {
    sha256 = "1npfk5jv59kk4n8pkyx89fn9s6p8x3gbffs42jaw24frgxfgp8ca";
    rev = "v${version}";
    repo = "libconfuse";
    owner = "martinh";
  };

  postPatch = ''
    substituteInPlace tests/Makefile.am \
      --replace 'TESTS            += empty_string' "" \
      --replace 'TESTS            += print_filter' ""
  '';

  nativeBuildInputs = [ autoreconfHook flex ];

  enableParallelBuilding = true;

  # On darwin the tests depend on the installed libraries because of install_name.
  doInstallCheck = true;
  installCheckTarget = "check";

  meta = with stdenv.lib; {
    inherit (src.meta) homepage;
    description = "Small configuration file parser library for C";
    longDescription = ''
      libConfuse (previously libcfg) is a configuration file parser library
      written in C. It supports sections and (lists of) values, as well as
      some other features. It makes it very easy to add configuration file
      capability to a program using a simple API.

      The goal of libConfuse is not to be the configuration file parser library
      with a gazillion of features. Instead, it aims to be easy to use and
      quick to integrate with your code.
    '';
    license = licenses.isc;
    platforms = platforms.linux ++ platforms.darwin;
  };
}


{stdenv, fetchurl, mesa, tcl, tk, file, libXmu, cmake, libtool, qt4,
ftgl, freetype}:

stdenv.mkDerivation rec {
  name = "opencascade-oce-0.17.2";
  src = fetchurl {
    url = https://github.com/tpaviot/oce/archive/OCE-0.17.2.tar.gz;
    sha256 = "0vpmnb0k5y2f7lpmwx9pg9yfq24zjvnsak5alzacncfm1hv9b6cd";
  };

  buildInputs = [ mesa tcl tk file libXmu libtool qt4 ftgl freetype cmake ];

  preConfigure = ''
    cmakeFlags="$cmakeFlags -DOCE_INSTALL_PREFIX=$out"
  '';

  # https://bugs.freedesktop.org/show_bug.cgi?id=83631
  NIX_CFLAGS_COMPILE = "-DGLX_GLXEXT_LEGACY";

  enableParallelBuilding = true;

  meta = {
    description = "Open CASCADE Technology, libraries for 3D modeling and numerical simulation";
    homepage = http://www.opencascade.org/;
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}

Fix build against glibc 2.26

{stdenv, fetchurl, mesa, tcl, tk, file, libXmu, cmake, libtool, qt4,
ftgl, freetype}:

stdenv.mkDerivation rec {
  name = "opencascade-oce-0.17.2";
  src = fetchurl {
    url = https://github.com/tpaviot/oce/archive/OCE-0.17.2.tar.gz;
    sha256 = "0vpmnb0k5y2f7lpmwx9pg9yfq24zjvnsak5alzacncfm1hv9b6cd";
  };

  buildInputs = [ mesa tcl tk file libXmu libtool qt4 ftgl freetype cmake ];

  # Fix for glibc 2.26
  postPatch = ''
    sed -i -e 's/^\( *#include <\)x\(locale.h>\)//' \
      src/Standard/Standard_CLocaleSentry.hxx
  '';

  preConfigure = ''
    cmakeFlags="$cmakeFlags -DOCE_INSTALL_PREFIX=$out"
  '';

  # https://bugs.freedesktop.org/show_bug.cgi?id=83631
  NIX_CFLAGS_COMPILE = "-DGLX_GLXEXT_LEGACY";

  enableParallelBuilding = true;

  meta = {
    description = "Open CASCADE Technology, libraries for 3D modeling and numerical simulation";
    homepage = http://www.opencascade.org/;
    maintainers = with stdenv.lib.maintainers; [viric];
    platforms = with stdenv.lib.platforms; linux;
  };
}


{ stdenv, buildPythonPackage, fetchPypi,
  pytest }:

buildPythonPackage rec {
  pname = "rfc3986";
  version = "1.2.0";

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

  checkInputs = [ pytest ];
  checkPhase = ''
    py.test
  '';

  meta = with stdenv.lib; {
    homepage = https://rfc3986.readthedocs.org;
    license = licenses.asl20;
    description = "Validating URI References per RFC 3986";
  };
}

Replace deprecated py.test command with pytest

{ stdenv, buildPythonPackage, fetchPypi,
  pytest }:

buildPythonPackage rec {
  pname = "rfc3986";
  version = "1.2.0";

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

  checkInputs = [ pytest ];
  checkPhase = ''
    pytest
  '';

  meta = with stdenv.lib; {
    homepage = https://rfc3986.readthedocs.org;
    license = licenses.asl20;
    description = "Validating URI References per RFC 3986";
  };
}


{ stdenv, fetchurl, perl, zlib }:

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

  src = fetchurl {
    url = "http://www.nih.at/libzip/${name}.tar.gz";
    sha256 = "08b26qbfxq6z5xf36y1d8insm5valv83dhj933iag6man04prb2r";
  };

  outputs = [ "dev" "out" ];

  nativeBuildInputs = [ perl ];
  propagatedBuildInputs = [ zlib ];

  preInstall = ''
    patchShebangs man/handle_links
  '';

  # At least mysqlWorkbench cannot find zipconf.h; I think also openoffice
  # had this same problem.  This links it somewhere that mysqlworkbench looks.
  postInstall = ''
    ( cd $dev/include ; ln -s ../lib/libzip/include/zipconf.h zipconf.h )
  '';

  meta = {
    homepage = http://www.nih.at/libzip;
    description = "A C library for reading, creating and modifying zip archives";
  };
}

Move directory containing zipconf.h to $dev

{ stdenv, fetchurl, perl, zlib }:

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

  src = fetchurl {
    url = "http://www.nih.at/libzip/${name}.tar.gz";
    sha256 = "08b26qbfxq6z5xf36y1d8insm5valv83dhj933iag6man04prb2r";
  };

  outputs = [ "dev" "out" ];

  nativeBuildInputs = [ perl ];
  propagatedBuildInputs = [ zlib ];

  preInstall = ''
    patchShebangs man/handle_links
  '';

  # At least mysqlWorkbench cannot find zipconf.h; I think also openoffice
  # had this same problem.  This links it somewhere that mysqlworkbench looks.
  postInstall = ''
    mkdir -p $dev/lib
    mv $out/lib/libzip $dev/lib/libzip
    ( cd $dev/include ; ln -s ../lib/libzip/include/zipconf.h zipconf.h )
  '';

  meta = {
    homepage = http://www.nih.at/libzip;
    description = "A C library for reading, creating and modifying zip archives";
  };
}


a :
let
  fetchurl = a.fetchurl;

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

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

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

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

Build btrfs-image, although it was mistakenly omitted in release Makefile

a :
let
  fetchurl = a.fetchurl;

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

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

  phaseNames = ["doEnsureBtrfsImage" "doMakeInstall"];

  doEnsureBtrfsImage = a.fullDepEntry (''
    if ! grep 'progs = ' Makefile | grep btrfs-image; then
      sed -e 's/progs = .*/& btrfs-image/' -i Makefile
    fi
  '') ["minInit" "doUnpack"];

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


{stdenv, fetchurl, pkgconfig, libxml2, gnutls, libproxy, sqlite, curl, glib, GConf}:

stdenv.mkDerivation {
  name = "libsoup-2.26.2";
  src = fetchurl {
    url = mirror://gnome/desktop/2.26/2.26.2/sources/libsoup-2.26.2.tar.bz2;
    sha256 = "0ywsy30x0sl42m6s3rqk5vm4018shx1s50hsqgg9a8yybfhxvkmg";
  };
  buildInputs = [ pkgconfig libxml2 gnutls libproxy sqlite curl glib GConf ];
}

Update libsoup for WebKit update

{stdenv, fetchurl, pkgconfig, libxml2, gnutls, libproxy, sqlite, curl, glib, GConf}:

stdenv.mkDerivation {
  name = "libsoup-2.27.4";
  src = fetchurl {
    url = mirror://gnome/desktop/2.27/2.27.4/sources/libsoup-2.27.4.tar.bz2;
    sha256 = "4d67aa8d2d3c719b67bde58ca3b8a94aa1d172bc242672401d7f3d22685065b9";
  };
  buildInputs = [ pkgconfig libxml2 gnutls libproxy sqlite curl glib GConf ];
}


{ fetchFromGitHub
, glib
, gobject-introspection
, meson
, ninja
, pkgconfig
, stdenv
, wrapGAppsHook
}:

stdenv.mkDerivation rec {
  pname = "cinnamon-menus";
  version = "4.8.1";

  src = fetchFromGitHub {
    owner = "linuxmint";
    repo = pname;
    rev = version;
    sha256 = "1fsiq8q8b65skxbg1bsishygnw2zg8kr0d09rassqjdimd4yfi1y";
  };

  buildInputs = [
    glib
    gobject-introspection
  ];

  nativeBuildInputs = [
    meson
    ninja
    wrapGAppsHook
    pkgconfig
  ];

  meta = with stdenv.lib; {
    homepage = "https://github.com/linuxmint/cinnamon-menus";
    description = "A menu system for the Cinnamon project";
    license = [ licenses.gpl2 licenses.lgpl2 ];
    platforms = platforms.linux;
    maintainers = teams.cinnamon.members;
  };
}

Revert "cinnamon.cinnamon-menus: 4.6.1 -> 4.8.1"

{ fetchFromGitHub
, glib
, gobject-introspection
, meson
, ninja
, pkgconfig
, stdenv
, wrapGAppsHook
}:

stdenv.mkDerivation rec {
  pname = "cinnamon-menus";
  version = "4.6.1";

  src = fetchFromGitHub {
    owner = "linuxmint";
    repo = pname;
    rev = version;
    sha256 = "1qdaql4mknhzvl2qi1pyw4c820lqb7lg07gblh0wzfk4f7h8hddx";
  };

  buildInputs = [
    glib
    gobject-introspection
  ];

  nativeBuildInputs = [
    meson
    ninja
    wrapGAppsHook
    pkgconfig
  ];

  meta = with stdenv.lib; {
    homepage = "https://github.com/linuxmint/cinnamon-menus";
    description = "A menu system for the Cinnamon project";
    license = [ licenses.gpl2 licenses.lgpl2 ];
    platforms = platforms.linux;
    maintainers = teams.cinnamon.members;
  };
}


{ lib
, buildPythonPackage
, fetchFromGitHub
, pytestCheckHook
, pytest-asyncio
}:

buildPythonPackage rec {
  pname = "sanic-routing";
  version = "21.12.0";

  src = fetchFromGitHub {
    owner = "sanic-org";
    repo = "sanic-routing";
    rev = "v${version}";
    hash = "sha256-IN+keJ5OI++p33/FgW5Xo+Pk09VuR7EASDF7G6eWvM4=";
  };

  checkInputs = [ pytestCheckHook pytest-asyncio ];

  disabledTests = [
    # sanic_routing/route.py:333: DeprecationWarning: Use of 'number' as a path parameter type is deprected, and will be removed in Sanic v21.12. Instead, use <number:float>.
    "test_casting"
  ];

  pythonImportsCheck = [ "sanic_routing" ];

  meta = with lib; {
    description = "Core routing component for the Sanic web framework";
    homepage = "https://github.com/sanic-org/sanic-routing";
    license = licenses.mit;
    maintainers = with maintainers; [ AluisioASG ];
  };
}

Revert "python3Packages.sanic-routing: disable failing test"

{ lib
, buildPythonPackage
, fetchFromGitHub
, pytestCheckHook
, pytest-asyncio
}:

buildPythonPackage rec {
  pname = "sanic-routing";
  version = "21.12.0";

  src = fetchFromGitHub {
    owner = "sanic-org";
    repo = "sanic-routing";
    rev = "v${version}";
    hash = "sha256-IN+keJ5OI++p33/FgW5Xo+Pk09VuR7EASDF7G6eWvM4=";
  };

  checkInputs = [ pytestCheckHook pytest-asyncio ];
  pythonImportsCheck = [ "sanic_routing" ];

  meta = with lib; {
    description = "Core routing component for the Sanic web framework";
    homepage = "https://github.com/sanic-org/sanic-routing";
    license = licenses.mit;
    maintainers = with maintainers; [ AluisioASG ];
  };
}


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

Add appimage-run package to Nix

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


{ lib, pythonPackages, fetchurl, libxslt, docbook5_xsl }:

pythonPackages.buildPythonPackage rec {
  name = "nixops-1.0";
  namePrefix = "";

  src = fetchurl {
    url = "http://nixos.org/releases/nixops/${name}/${name}.tar.bz2";
    sha256 = "9ae2dfac8e1fa895aef81323b14a3398f03a1cbd8c86ea10b6fff7312e1fadbb";
  };

  buildInputs = [ libxslt ];

  pythonPath =
    [ pythonPackages.prettytable
      pythonPackages.boto
      pythonPackages.sqlite3
    ];

  doCheck = false;

  postInstall =
    ''
      make -C doc/manual install nixops.1 docbookxsl=${docbook5_xsl}/xml/xsl/docbook \
        docdir=$out/share/doc/nixops mandir=$out/share/man

      mkdir -p $out/share/nix/nixops
      cp -av nix/* $out/share/nix/nixops
    '';

  meta = {
    homepage = https://github.com/NixOS/nixops;
    description = "NixOS cloud provisioning and deployment tool";
    maintainers = [ lib.maintainers.eelco lib.maintainers.rob ];
    platforms = lib.platforms.linux;
  };
}

Update nixops to version 1.0.1

{ lib, pythonPackages, fetchurl, libxslt, docbook5_xsl }:

pythonPackages.buildPythonPackage rec {
  name = "nixops-1.0.1";
  namePrefix = "";

  src = fetchurl {
    url = "http://nixos.org/releases/nixops/${name}/${name}.tar.bz2";
    sha256 = "c6dda2597ba0ab2f60c984d4715163c02940f20803619668d6c16eba8570a394";
  };

  buildInputs = [ libxslt ];

  pythonPath =
    [ pythonPackages.prettytable
      pythonPackages.boto
      pythonPackages.sqlite3
    ];

  doCheck = false;

  postInstall =
    ''
      # Backward compatibility symlink.
      ln -s nixops $out/bin/charon

      make -C doc/manual install nixops.1 docbookxsl=${docbook5_xsl}/xml/xsl/docbook \
        docdir=$out/share/doc/nixops mandir=$out/share/man

      mkdir -p $out/share/nix/nixops
      cp -av nix/* $out/share/nix/nixops
    '';

  meta = {
    homepage = https://github.com/NixOS/nixops;
    description = "NixOS cloud provisioning and deployment tool";
    maintainers = [ lib.maintainers.eelco lib.maintainers.rob ];
    platforms = lib.platforms.linux;
  };
}


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

{ config, pkgs, ... }:

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

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

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

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

{ config, pkgs, ... }:

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

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


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

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

Update haskell-hspec2 to version 0.3.4

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

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


{ stdenv, fetchurl, autoreconfHook }:

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

  src = fetchurl {
    url = "https://nixos.org/releases/patchelf/${name}/${name}.tar.bz2";
    sha256 = "1wzwvnlyf853hw9zgqq5522bvf8gqadk8icgqa41a5n7593csw7n";
  };

  # Drop test that fails on musl (?)
  postPatch = stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
    substituteInPlace tests/Makefile.am \
      --replace "set-rpath-library.sh" ""
  '' +
  # extend version identifier to more informative than "0.10".
  ''
    echo -n ${version} > version
  '';

  setupHook = [ ./setup-hook.sh ];

  nativeBuildInputs = [ autoreconfHook ];
  buildInputs = [ ];

  doCheck = !stdenv.isDarwin;

  meta = {
    homepage = https://nixos.org/patchelf.html;
    license = "GPL";
    description = "A small utility to modify the dynamic linker and RPATH of ELF executables";
    maintainers = [ stdenv.lib.maintainers.eelco ];
    platforms = stdenv.lib.platforms.all;
  };
}

Adjust patchelfUnstable to patchelf derivation layout

{ stdenv, fetchurl, autoreconfHook }:

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

  src = fetchurl {
    url = "https://nixos.org/releases/patchelf/${name}/${name}.tar.bz2";
    sha256 = "1wzwvnlyf853hw9zgqq5522bvf8gqadk8icgqa41a5n7593csw7n";
  };

  # Drop test that fails on musl (?)
  postPatch = stdenv.lib.optionalString stdenv.hostPlatform.isMusl ''
    substituteInPlace tests/Makefile.am \
      --replace "set-rpath-library.sh" ""
  '';

  setupHook = [ ./setup-hook.sh ];

  nativeBuildInputs = [ autoreconfHook ];
  buildInputs = [ ];

  doCheck = !stdenv.isDarwin;

  meta = with stdenv.lib; {
    homepage = https://nixos.org/patchelf.html;
    license = licenses.gpl3;
    description = "A small utility to modify the dynamic linker and RPATH of ELF executables";
    maintainers = [ maintainers.eelco ];
    platforms = platforms.all;
  };
}


{ callPackage }:

let
  common = opts: callPackage (import ./common.nix opts);
in
  rec {
    sublime3-dev = common {
      buildVersion = "3203";
      dev = true;
      x32sha256 = "builder for '/nix/store/r17nxj6c8cchi1vz498yg8a6z2ghilaf-sublimetext-3203.tar.bz2.drv' failed due to signal 31 (Bad system call)";
      x64sha256 = "0dp4vi39s2gq5a7snz0byrf44i0csbzwq6hn7i2zqa6rpvfywa1d";
    } {};

    sublime3 = common {
      buildVersion = "3200";
      x32sha256 = "01krmbji8z62x4kl1hf3c1nfj4c4n4xmg1df62ljiwhkcfm74izr";
      x64sha256 = "1gagc50fqb0d2bszi8m5spzb64shkaylvrwl6fxah55xcmy2kmdr";
    } {};
  }

Revert "sublime3-dev: 3184 → 3203"

{ callPackage }:

let
  common = opts: callPackage (import ./common.nix opts);
in
  rec {
    sublime3-dev = common {
      buildVersion = "3184";
      dev = true;
      x32sha256 = "1b6f1fid75g5z247dbnyyj276lrlv99scrdk1vvfcr6vyws77vzr";
      x64sha256 = "03127jhfjr17ai96p3axh5b5940fds8jcw6vkid8y6dmvd2dpylz";
    } {};

    sublime3 = common {
      buildVersion = "3200";
      x32sha256 = "01krmbji8z62x4kl1hf3c1nfj4c4n4xmg1df62ljiwhkcfm74izr";
      x64sha256 = "1gagc50fqb0d2bszi8m5spzb64shkaylvrwl6fxah55xcmy2kmdr";
    } {};
  }


{ config, pkgs, ... }:

{
  services.canto-daemon.enable = true;
  environment.systemPackages = [
    pkgs.canto-curses
    pkgs.canto-daemon
  ];
}

Add a little note about canto

# Canto is an Atom/RSS feed reader for the console that is meant to be quick,
# concise, and colorful.
#
# Manual: http://codezen.org/canto-ng/manual/

{ config, pkgs, ... }:

{
  services.canto-daemon.enable = true;
  environment.systemPackages = [
    pkgs.canto-curses
    pkgs.canto-daemon
  ];
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "miniupnpc-1.9.20150917";

  src = fetchurl {
    url = "http://miniupnp.free.fr/files/download.php?file=${name}.tar.gz";
    sha256 = "1nhiixfmlagcv9srni19r95n1v069rlq98fn8x4xpsf154lw71rh";
    name = "${name}.tar.gz";
  };

  doCheck = true;

  installFlags = "PREFIX=$(out) INSTALLPREFIX=$(out)";

  meta = {
    homepage = http://miniupnp.free.fr/;
    description = "A client that implements the UPnP Internet Gateway Device (IGD) specification";
    platforms = stdenv.lib.platforms.linux;
  };
}

Revert "miniupnpc: 1.9.20150703 -> 1.9.20150917"

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "miniupnpc-1.9.20150730";

  src = fetchurl {
    url = "http://miniupnp.free.fr/files/download.php?file=${name}.tar.gz";
    sha256 = "0156hssql8iaziwba8ag7y39lchrgwcvlhck2d2qak1vznqzlr0x";
    name = "${name}.tar.gz";
  };

  doCheck = true;

  installFlags = "PREFIX=$(out) INSTALLPREFIX=$(out)";

  meta = {
    homepage = http://miniupnp.free.fr/;
    description = "A client that implements the UPnP Internet Gateway Device (IGD) specification";
    platforms = stdenv.lib.platforms.linux;
  };
}


Make non-nullable class properties NOT NULL in database

-- Make columns NOT NULL that shouldn't be null
ALTER TABLE `alliance`
	MODIFY `alliance_account` int unsigned NOT NULL DEFAULT '0',
	MODIFY `leader_id` int unsigned NOT NULL DEFAULT '0',
	MODIFY `alliance_password` varchar(32) NOT NULL;

ALTER TABLE `hardware_type`
	MODIFY `hardware_name` varchar(32) NOT NULL,
	MODIFY `cost` int unsigned NOT NULL;

ALTER TABLE `location_type`
	MODIFY `location_name` varchar(55) NOT NULL,
	MODIFY `location_image` varchar(32) NOT NULL;

ALTER TABLE `port_has_goods`
	MODIFY `transaction_type` enum('Buy','Sell') NOT NULL,
	MODIFY `amount` int unsigned NOT NULL;

ALTER TABLE `level`
	MODIFY `level_name` varchar(32) NOT NULL,
	MODIFY `requirement` int unsigned NOT NULL;

ALTER TABLE `good`
	MODIFY `good_name` varchar(32) NOT NULL,
	MODIFY `base_price` int unsigned NOT NULL;

ALTER TABLE `weapon_type`
	MODIFY `weapon_name` varchar(32) NOT NULL,
	MODIFY `race_id` int unsigned NOT NULL,
	MODIFY `cost` int unsigned NOT NULL,
	MODIFY `shield_damage` int unsigned NOT NULL,
	MODIFY `armour_damage` int unsigned NOT NULL,
	MODIFY `accuracy` int unsigned NOT NULL,
	MODIFY `power_level` int unsigned NOT NULL,
	MODIFY `buyer_restriction` int unsigned NOT NULL;