{ stdenv, fetchurl, perl, groff }:

let version = "2.9"; in

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

  src = fetchurl {
    url    = "http://llvm.org/releases/${version}/llvm-${version}.tgz";
    sha256 = "0y9pgdakn3n0vf8zs6fjxjw6972nyw4rkfwwza6b8a3ll77kc4k6";
  };

  buildInputs = [ perl groff ];

  configureFlags = [ "--enable-optimized" "--enable-shared" "--disable-static" ]
    ++ stdenv.lib.optionals (stdenv.gcc ? clang) [
      "--with-built-clang=yes"
      "CXX=clang++"
    ];

  meta = {
    homepage = http://llvm.org/;
    description = "Collection of modular and reusable compiler and toolchain technologies";
    license = "BSD";
    maintainers = with stdenv.lib.maintainers; [viric shlevy];
    platforms = with stdenv.lib.platforms; all;
  };
}

Use the sw_vers program on darwin

{ stdenv, fetchurl, perl, groff, darwinSwVersUtility }:

let version = "2.9"; in

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

  src = fetchurl {
    url    = "http://llvm.org/releases/${version}/llvm-${version}.tgz";
    sha256 = "0y9pgdakn3n0vf8zs6fjxjw6972nyw4rkfwwza6b8a3ll77kc4k6";
  };

  buildInputs = [ perl groff ] ++
    stdenv.lib.optional stdenv.isDarwin darwinSwVersUtility;

  configureFlags = [ "--enable-optimized" "--enable-shared" "--disable-static" ]
    ++ stdenv.lib.optionals (stdenv.gcc ? clang) [
      "--with-built-clang=yes"
      "CXX=clang++"
    ];

  meta = {
    homepage = http://llvm.org/;
    description = "Collection of modular and reusable compiler and toolchain technologies";
    license = "BSD";
    maintainers = with stdenv.lib.maintainers; [viric shlevy];
    platforms = with stdenv.lib.platforms; all;
  };
}


{
  packageOverrides = pkgs: with pkgs; rec {
    myProfile = writeText "my-profile" ''
      export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
      export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
    '';
    myPackages = pkgs.buildEnv {
      name = "my-packages";
      paths = [
        aspell
        coreutils
        gnupg
        curl
        git
        jq
        skim
        bat
        exa
        lsd
        tig
        ripgrep
        fd
        tree
        python3Packages.pynvim
        stow
        xclip
        pass
        tmux
        nodejs-13_x
        yarn
        emacs
        htop
        bandwhich
        broot
        gawk
        nnn
        go
      ];
      pathsToLink = [ "/share" "/bin" "/Applications" ];
      extraOutputsToInstall = [ "man" "doc" ];
    };
  };
}

Add delta, git diff with color

{
  packageOverrides = pkgs: with pkgs; rec {
    myProfile = writeText "my-profile" ''
      export PATH=$HOME/.nix-profile/bin:/nix/var/nix/profiles/default/bin:/sbin:/bin:/usr/sbin:/usr/bin
      export MANPATH=$HOME/.nix-profile/share/man:/nix/var/nix/profiles/default/share/man:/usr/share/man
    '';
    myPackages = pkgs.buildEnv {
      name = "my-packages";
      paths = [
        aspell
        coreutils
        gnupg
        curl
        git
        jq
        skim
        bat
        exa
        lsd
        tig
        ripgrep
        fd
        tree
        python3Packages.pynvim
        stow
        xclip
        pass
        tmux
        nodejs-13_x
        yarn
        emacs
        htop
        bandwhich
        broot
        gawk
        nnn
        go
        gitAndTools.delta
      ];
      pathsToLink = [ "/share" "/bin" "/Applications" ];
      extraOutputsToInstall = [ "man" "doc" ];
    };
  };
}


{ cabal, ansiTerminal, ansiWlPprint, binary, boehmgc, Cabal
, deepseq, filepath, gmp, happy, haskeline, languageJava, mtl
, network, parsers, split, text, time, transformers, trifecta
, unorderedContainers, utf8String, vector, vectorBinaryInstances
, xml
}:

cabal.mkDerivation (self: {
  pname = "idris";
  version = "0.9.10.1";
  sha256 = "194gbpk8fy64maj9lcwj9hkbndc3287bh9mz2jm09vd11i23iyg1";
  isLibrary = false;
  isExecutable = true;
  buildDepends = [
    ansiTerminal ansiWlPprint binary Cabal deepseq filepath haskeline
    languageJava mtl network parsers split text time transformers
    trifecta unorderedContainers utf8String vector
    vectorBinaryInstances xml
  ];
  buildTools = [ happy ];
  extraLibraries = [ boehmgc gmp ];
  meta = {
    homepage = "http://www.idris-lang.org/";
    description = "Functional Programming Language with Dependent Types";
    license = self.stdenv.lib.licenses.bsd3;
    platforms = self.ghc.meta.platforms;
  };
})

Build with llvm backend and libffi support

{ cabal, ansiTerminal, ansiWlPprint, binary, boehmgc, Cabal
, deepseq, filepath, gmp, happy, haskeline, languageJava, mtl
, network, parsers, split, text, time, transformers, trifecta
, unorderedContainers, utf8String, vector, vectorBinaryInstances
, xml, llvmGeneral, libffi
}:

cabal.mkDerivation (self: {
  pname = "idris";
  version = "0.9.10.1";
  sha256 = "194gbpk8fy64maj9lcwj9hkbndc3287bh9mz2jm09vd11i23iyg1";
  isLibrary = false;
  isExecutable = true;
  buildDepends = [
    ansiTerminal ansiWlPprint binary Cabal deepseq filepath haskeline
    languageJava mtl network parsers split text time transformers
    trifecta unorderedContainers utf8String vector
    vectorBinaryInstances xml llvmGeneral
  ];
  buildTools = [ happy ];
  extraLibraries = [ boehmgc gmp libffi ];
  configureFlags = [ "-f" "llvm" "-f" "gmp" "-f" "ffi" ];
  meta = {
    homepage = "http://www.idris-lang.org/";
    description = "Functional Programming Language with Dependent Types";
    license = self.stdenv.lib.licenses.bsd3;
    platforms = self.ghc.meta.platforms;
  };
})


{ stdenv, fetchurl, autoconf, automake, libtool, pkgconfig, file, protobufc }:

stdenv.mkDerivation rec {
  name = "riemann-c-client-${version}";

  version = "1.2.0";

  src = fetchurl {
    url = "https://github.com/algernon/riemann-c-client/archive/${name}.tar.gz";
    sha256 = "1w3rx0hva605d5vzlhhm4pb43ady0m3s4mz8ix1ycn4b8cq9jsjs";
  };

  buildInputs = [ autoconf automake libtool pkgconfig file protobufc ];

  preConfigure = "autoreconf -i";

  meta = with stdenv.lib; {
    homepage = "https://github.com/algernon/riemann-c-client";
    description = "A C client library for the Riemann monitoring system";
    license = licenses.gpl3;
    maintainers = [ maintainers.rickynils ];
    platforms = platforms.linux;
  };
}

Update from 1.2.0 to 1.2.1

{ stdenv, fetchurl, autoconf, automake, libtool, pkgconfig, file, protobufc }:

stdenv.mkDerivation rec {
  name = "riemann-c-client-${version}";

  version = "1.2.1";

  src = fetchurl {
    url = "https://github.com/algernon/riemann-c-client/archive/${name}.tar.gz";
    sha256 = "132yd1m523inmv17sd48xf7xdqb7jj36v7is1xw7w9nny6qxkzwm";
  };

  buildInputs = [ autoconf automake libtool pkgconfig file protobufc ];

  preConfigure = "autoreconf -i";

  meta = with stdenv.lib; {
    homepage = "https://github.com/algernon/riemann-c-client";
    description = "A C client library for the Riemann monitoring system";
    license = licenses.gpl3;
    maintainers = [ maintainers.rickynils ];
    platforms = platforms.linux;
  };
}


{stdenv, fetchFromGitHub }:

stdenv.mkDerivation rec {
    name = "rebar3-nix-bootstrap";
    version = "0.0.1";

    src = fetchFromGitHub {
        owner = "erlang-nix";
        repo = "rebar3-nix-bootstrap";
        rev = "${version}";
        sha256 = "0xyj7j59dmxyl5nhhsmb0r1pihmk0s4k02ga1rfgm30rij6n7431";
    };

    installFlags = "PREFIX=$(out)";

    meta = {
      description = "Shim command to help bootstrap a rebar3 project on Nix";
      license = stdenv.lib.licenses.asl20;
      homepage = "https://github.com/erl-nix/rebar3-nix-bootstrap";
      maintainers = with stdenv.lib.maintainers; [ ericbmerritt ];
    };
}

Make rebar3-nix-bootstrap depend on erlang.

{stdenv, fetchFromGitHub, erlang }:

stdenv.mkDerivation rec {
    name = "rebar3-nix-bootstrap";
    version = "0.0.1";

    src = fetchFromGitHub {
        owner = "erlang-nix";
        repo = "rebar3-nix-bootstrap";
        rev = "${version}";
        sha256 = "0xyj7j59dmxyl5nhhsmb0r1pihmk0s4k02ga1rfgm30rij6n7431";
    };

    buildInputs = [ erlang ];

    installFlags = "PREFIX=$(out)";

    meta = {
      description = "Shim command to help bootstrap a rebar3 project on Nix";
      license = stdenv.lib.licenses.asl20;
      homepage = "https://github.com/erl-nix/rebar3-nix-bootstrap";
      maintainers = with stdenv.lib.maintainers; [ ericbmerritt ];
    };
}


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

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

Update haskell-http-kit to version 0.4.0

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

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


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

  src = fetchurl {
    url = "http://pkgs.fedoraproject.org/repo/pkgs/pcsc-lite-ccid/ccid-1.4.13.tar.bz2/89c167a873df1f8bc0dc907ce209e5ff/ccid-1.4.13.tar.bz2";
    sha256 = "1w0mxb5qzps9x2fcggv958mwgwmvfxxj4nspxs67fa7qg7r6yxar";
  };

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

  buildInputs = [ pcsclite pkgconfig libusb1 ];

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

Update from 1.4.13 -> 1.4.14

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

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

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

  buildInputs = [ pcsclite pkgconfig libusb1 ];

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


{stdenv, fetchurl, bison, flex}:

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

  src = fetchurl {
    url = "https://acpica.org/sites/acpica/files/acpica-unix-${version}.tar.gz";
    sha256 = "1n7lqmv77kg28drahvxzybwl9v4hzwi8i7xkpgliclfcp5ff909b";
  };

  NIX_CFLAGS_COMPILE = [
    "-O3"
    # See: https://github.com/acpica/acpica/issues/387:
    "-Wno-error=format-overflow"
  ];

  buildFlags = "iasl";

  buildInputs = [ bison flex ];

  installPhase =
    ''
      install -d $out/bin
      install generate/unix/bin*/iasl $out/bin
    '';

  meta = {
    description = "Intel ACPI Compiler";
    homepage = http://www.acpica.org/;
    license = stdenv.lib.licenses.iasl;
    platforms = stdenv.lib.platforms.linux;
  };
}

Revert "iasl: 20180313 -> 20180508"

{stdenv, fetchurl, bison, flex}:

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

  src = fetchurl {
    url = "https://acpica.org/sites/acpica/files/acpica-unix-${version}.tar.gz";
    sha256 = "05ab2xfv9wqwbzjaa9xqgrvvan87rxv29hw48h1gcckpc5smp2wm";
  };

  NIX_CFLAGS_COMPILE = [
    "-O3"
    # See: https://github.com/acpica/acpica/issues/387:
    "-Wno-error=format-overflow"
  ];

  buildFlags = "iasl";

  buildInputs = [ bison flex ];

  installPhase =
    ''
      install -d $out/bin
      install generate/unix/bin*/iasl $out/bin
    '';

  meta = {
    description = "Intel ACPI Compiler";
    homepage = http://www.acpica.org/;
    license = stdenv.lib.licenses.iasl;
    platforms = stdenv.lib.platforms.linux;
  };
}


{ lib
, stdenv
, fetchFromGitHub
, pkg-config
, poppler
}:

stdenv.mkDerivation rec {
  pname = "pdftoipe";
  version = "7.2.24.1";

  src = fetchFromGitHub {
    owner = "otfried";
    repo = "ipe-tools";
    rev = "v${version}";
    sha256 = "jlrjrjzZQo79CKMySayhCm1dqLh89wOQuXrXa2aqc0k=";
  };
  sourceRoot = "source/pdftoipe";

  nativeBuildInputs = [ pkg-config ];
  buildInputs = [ poppler ];

  installPhase = ''
    install -D pdftoipe $out/bin/pdftoipe
  '';

  meta = with lib; {
    description = "A program that tries to convert arbitrary PDF documents to Ipe files";
    homepage = "https://github.com/otfried/ipe-tools";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ yrd ];
  };
}

Fix build with latest poppler version

{ lib
, stdenv
, fetchFromGitHub
, pkg-config
, poppler
, fetchpatch
}:

stdenv.mkDerivation rec {
  pname = "pdftoipe";
  version = "7.2.24.1";

  src = fetchFromGitHub {
    owner = "otfried";
    repo = "ipe-tools";
    rev = "v${version}";
    sha256 = "jlrjrjzZQo79CKMySayhCm1dqLh89wOQuXrXa2aqc0k=";
  };

  patches = [
    # Fix build with poppler > 22.03.0
    # https://github.com/otfried/ipe-tools/pull/48
    (fetchpatch {
      url = "https://github.com/otfried/ipe-tools/commit/14335180432152ad094300d0afd00d8e390469b2.patch";
      sha256 = "sha256-V3FmwG3bR6io/smxjasFJ5K0/u8RSFfdUX41ClGXhFc=";
      stripLen = 1;
      name = "poppler_fix_build.patch";
    })
  ];

  sourceRoot = "source/pdftoipe";

  nativeBuildInputs = [ pkg-config ];
  buildInputs = [ poppler ];

  installPhase = ''
    install -D pdftoipe $out/bin/pdftoipe
  '';

  meta = with lib; {
    description = "A program that tries to convert arbitrary PDF documents to Ipe files";
    homepage = "https://github.com/otfried/ipe-tools";
    license = licenses.gpl3Plus;
    maintainers = with maintainers; [ yrd ];
  };
}


{ haskellLib }:

self: super: {
  ghcjs-prim = null;
  derive = null;
  focus-http-th = null;
  th-lift-instances = null;
  websockets = null;
  wai = null;
  warp = null;
  wai-app-static = null;

  cabal-doctest = null;
  syb = haskellLib.overrideCabal super.syb (drv: { jailbreak = true; });

  reflex-todomvc = haskellLib.overrideCabal super.reflex-todomvc (drv: {
    postFixup = ''
      mkdir $out/reflex-todomvc.app
      cp reflex-todomvc.app/* $out/reflex-todomvc.app/
      cp $out/bin/reflex-todomvc $out/reflex-todomvc.app/
    '';
  });
  cabal-macosx = null;
  mkDerivation = drv: super.mkDerivation (drv // {
    doHaddock = false;
    enableSharedLibraries = false;
    enableSharedExecutables = false;
  });
}

Add temporary fix for Haskell free + iOS issue

{ haskellLib }:

self: super: {
  ghcjs-prim = null;
  derive = null;
  focus-http-th = null;
  th-lift-instances = null;
  websockets = null;
  wai = null;
  warp = null;
  wai-app-static = null;

  cabal-doctest = null;
  syb = haskellLib.overrideCabal super.syb (drv: { jailbreak = true; });

  # HACK(matthewbauer):
  # Temporary fix for https://github.com/ekmett/free/issues/176
  # Optimizations are broken on iOS for some modules.
  free = haskellLib.appendConfigureFlag super.free "--enable-optimization=0";
  jsaddle = haskellLib.appendConfigureFlag super.jsaddle "--enable-optimization=0";

  reflex-todomvc = haskellLib.overrideCabal super.reflex-todomvc (drv: {
    postFixup = ''
      mkdir $out/reflex-todomvc.app
      cp reflex-todomvc.app/* $out/reflex-todomvc.app/
      cp $out/bin/reflex-todomvc $out/reflex-todomvc.app/
    '';
  });
  cabal-macosx = null;
  mkDerivation = drv: super.mkDerivation (drv // {
    doHaddock = false;
    enableSharedLibraries = false;
    enableSharedExecutables = false;
  });
}


{ lib, perlPackages, fetchFromGitHub, installShellFiles }:

perlPackages.buildPerlPackage rec {
  pname = "wakeonlan";
  version = "0.42";

  src = fetchFromGitHub {
    owner = "jpoliv";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-zCOpp5iNrWwh2knBGWhiEyG9IPAnFRwH5jJLEVLBISM=";
  };

  outputs = [ "out" ];

  nativeBuildInputs = [ installShellFiles ];
  # checkInputs = [ perl534Packages.TestPerlCritic perl534Packages.TestPod perl534Packages.TestPodCoverage ];
  doCheck = false;  # Missing package for https://github.com/genio/test-spelling to run tests

  installPhase = ''
    install -Dt $out/bin wakeonlan
    installManPage blib/man1/wakeonlan.1
  '';

  meta = with lib; {
    description = "Perl script for waking up computers via Wake-On-LAN magic packets";
    homepage = "https://github.com/jpoliv/wakeonlan";
    license = licenses.artistic1;
    maintainers = with maintainers; [ SuperSandro2000 ];
  };
}

Patch and run perl tests

{ lib, perlPackages, fetchFromGitHub, installShellFiles }:

perlPackages.buildPerlPackage rec {
  pname = "wakeonlan";
  version = "0.42";

  src = fetchFromGitHub {
    owner = "jpoliv";
    repo = pname;
    rev = "v${version}";
    sha256 = "sha256-zCOpp5iNrWwh2knBGWhiEyG9IPAnFRwH5jJLEVLBISM=";
  };

  outputs = [ "out" ];

  nativeBuildInputs = [ installShellFiles ];

  checkInputs = [ perlPackages.TestPerlCritic perlPackages.TestPod perlPackages.TestPodCoverage ];
  # Linting and formatting checks are of no interest for us.
  preCheck = ''
    rm -f t/93_pod_spell.t
  '';

  installPhase = ''
    install -Dt $out/bin wakeonlan
    installManPage blib/man1/wakeonlan.1
  '';

  meta = with lib; {
    description = "Perl script for waking up computers via Wake-On-LAN magic packets";
    homepage = "https://github.com/jpoliv/wakeonlan";
    license = licenses.artistic1;
    maintainers = with maintainers; [ SuperSandro2000 ];
  };
}


/* A Hydra jobset to test Guile-using applications and libraries with the
   Guile 2.x pre-releases.

   -- ludo@gnu.org  */

let
  allPackages = import ./all-packages.nix;

  pkgs = allPackages {
    packageOverrides = pkgs: pkgs // { guile = pkgs.guile_1_9; };
  };

  inherit (pkgs.lib.platforms) linux darwin cygwin allBut all;

in {
  /* The package list below was obtained with:

     cat top-level/all-packages.nix				\
     | grep -B3 'guile[^=]*$'					\
     | grep '^[[:blank:]]*[a-zA-Z0-9_]\+[[:blank:]]*='		\
     | sed -es'/^[[:blank:]]*\(.\+\)[[:blank:]]*=.*$/\1= linux;/g'

     with some minor edits.
   */

  lsh = linux;
  mailutils = linux;
  mcron = linux;
  guileLib = linux;
  guileLint = linux;
  gwrap = linux;
  gnutls = linux;
  dico = linux;
  trackballs = linux;
  beast = linux;
  elinks = linux;
  gnunet = linux;
  snd = linux;
  ballAndPaddle = linux;
  drgeo = linux;
  lilypond = linux;
}

Add Guile itself to the jobset.

/* A Hydra jobset to test Guile-using applications and libraries with the
   Guile 2.x pre-releases.

   -- ludo@gnu.org  */

let
  allPackages = import ./all-packages.nix;

  pkgs = allPackages {
    packageOverrides = pkgs: pkgs // { guile = pkgs.guile_1_9; };
  };

  inherit (pkgs.lib.platforms) linux darwin cygwin allBut all;

in {
  /* The package list below was obtained with:

     cat top-level/all-packages.nix				\
     | grep -B3 'guile[^=]*$'					\
     | grep '^[[:blank:]]*[a-zA-Z0-9_]\+[[:blank:]]*='		\
     | sed -es'/^[[:blank:]]*\(.\+\)[[:blank:]]*=.*$/\1= linux;/g'

     with some minor edits.
   */

  guile = linux;

  lsh = linux;
  mailutils = linux;
  mcron = linux;
  guileLib = linux;
  guileLint = linux;
  gwrap = linux;
  gnutls = linux;
  dico = linux;
  trackballs = linux;
  beast = linux;
  elinks = linux;
  gnunet = linux;
  snd = linux;
  ballAndPaddle = linux;
  drgeo = linux;
  lilypond = linux;
}


{ config, pkgs, ... }:

###### implementation

let

  tempConf = "/var/run/mdadm.conf";
  modprobe = config.system.sbin.modprobe;
  inherit (pkgs) mdadm;

in

{

  jobs.swraid =
    { startOn = "started udev or new-devices";

      script =
        ''
          # Load the necessary RAID personalities.
          # !!! hm, doesn't the kernel load these automatically?
          for mod in raid0 raid1 raid5; do
              ${modprobe}/sbin/modprobe $mod || true
          done

          # Scan /proc/partitions for RAID devices.
          ${mdadm}/sbin/mdadm --examine --brief --scan -c partitions > ${tempConf}

          if ! test -s ${tempConf}; then exit 0; fi

          # Activate each device found.
          ${mdadm}/sbin/mdadm --assemble -c ${tempConf} --scan

          initctl emit -n new-devices
        '';

      task = true;
    };

}

Remove loop of new-device messages. Add a shell script to watch new devices.

{ config, pkgs, ... }:

###### implementation

let

  tempConf = "/var/run/mdadm.conf";
  logFile = "/var/log/mdadmEvents.log";
  modprobe = config.system.sbin.modprobe;
  inherit (pkgs) mdadm;

  mdadmEventHandler = pkgs.writeScript "mdadmEventHandler.sh" ''
    #!/bin/sh

    echo "$@" >> ${logFile}
    case $1 in
      (NewArray)
        initctl emit -n new-devices
        ;;
      (*) ;;
    esac
  '';

in

{

  jobs.swraid =
    { startOn = [ "startup" "new-devices" ];

      script =
        ''
          # Load the necessary RAID personalities.
          # !!! hm, doesn't the kernel load these automatically?
          for mod in raid0 raid1 raid5; do
              ${modprobe}/sbin/modprobe $mod || true
          done

          # Scan /proc/partitions for RAID devices.
          ${mdadm}/sbin/mdadm --examine --brief --scan -c partitions > ${tempConf}

          if ! test -s ${tempConf}; then exit 0; fi

          # Activate each device found.
          ${mdadm}/sbin/mdadm --assemble -c ${tempConf} --scan
        '';

      task = true;
    };

  jobs.swraidEvents = {
    name = "swraid-events";
    description = "Watch mdadm events.";
    startOn = [ "startup" ];
    exec = "${mdadm}/sbin/mdadm --monitor --scan --program ${mdadmEventHandler}";
  };

}


{ stdenv, fetchurl, gfortran, atlas, cmake, python }:

stdenv.mkDerivation {
  name = "liblapack-3.4.0";
  src = fetchurl {
    url = "http://www.netlib.org/lapack/lapack-3.4.0.tgz";
    sha256 = "1sf30v1ps5icg67dvw5sbx5yhypx13am470gqg2f7l04f3wrw4x7";
  };

  propagatedBuildInputs = [ atlas ];
  buildInputs = [ gfortran cmake ];
  buildNativeInputs = [ python ];

  cmakeFlags = [
    "-DUSE_OPTIMIZED_BLAS=ON"
    "-DBLAS_ATLAS_f77blas_LIBRARY=${atlas}/lib/libf77blas.a"
    "-DBLAS_ATLAS_atlas_LIBRARY=${atlas}/lib/libatlas.a"
    "-DCMAKE_Fortran_FLAGS=-fPIC"
  ];

  doCheck = true;

  checkPhase = "
    sed -i 's,^#!.*,#!${python}/bin/python,' lapack_testing.py
    ctest
  ";

  enableParallelBuilding = true;

  passthru = {
    blas = atlas;
  };

  meta = {
    description = "Linear Algebra PACKage";
    license = "revised-BSD";
    homepage = "http://www.netlib.org/lapack/";
  };
}

Support shared library build; tests do not currently work for shared build.

{ stdenv, fetchurl, gfortran, atlas, cmake, python, shared ? false }:
let
  atlasMaybeShared = if shared then atlas.override {shared=true;} else atlas;
  usedLibExtension = if shared then ".so" else ".a";
in
stdenv.mkDerivation {
  name = "liblapack-3.4.0";
  src = fetchurl {
    url = "http://www.netlib.org/lapack/lapack-3.4.0.tgz";
    sha256 = "1sf30v1ps5icg67dvw5sbx5yhypx13am470gqg2f7l04f3wrw4x7";
  };

  propagatedBuildInputs = [ atlasMaybeShared ];
  buildInputs = [ gfortran cmake ];
  buildNativeInputs = [ python ];

  cmakeFlags = [
    "-DUSE_OPTIMIZED_BLAS=ON"
    "-DBLAS_ATLAS_f77blas_LIBRARY=${atlasMaybeShared}/lib/libf77blas${usedLibExtension}"
    "-DBLAS_ATLAS_atlas_LIBRARY=${atlasMaybeShared}/lib/libatlas${usedLibExtension}"
    "-DCMAKE_Fortran_FLAGS=-fPIC"
  ]
  ++ (stdenv.lib.optional shared "-DBUILD_SHARED_LIBS=ON")
  ;

  doCheck = ! shared;

  checkPhase = "
    sed -i 's,^#!.*,#!${python}/bin/python,' lapack_testing.py
    ctest
  ";

  enableParallelBuilding = true;

  passthru = {
    blas = atlas;
  };

  meta = {
    description = "Linear Algebra PACKage";
    license = "revised-BSD";
    homepage = "http://www.netlib.org/lapack/";
  };
}


# This file is autogenerated from update.sh in the same directory.
{
  dev = {
    version = "31.0.1650.0";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-31.0.1650.0.tar.xz";
    sha256 = "1ic46hv795scn4lyn2lkj1mk13ypznlbhcgk14r5jnypdii8slpj";
  };
  beta = {
    version = "30.0.1599.59";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-30.0.1599.59.tar.xz";
    sha256 = "1a8yj883qm1g59gm1rbncwdrr9q1n4h4hiipqhgbjasfcf2aawnq";
  };
  stable = {
    version = "29.0.1547.76";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-29.0.1547.76.tar.xz";
    sha256 = "1218a3y1q10fjrf8zf08ing9wxf6lls5w3gjmnp9azzbyr02gnv1";
  };
}

Update all channels to latest versions.

# This file is autogenerated from update.sh in the same directory.
{
  dev = {
    version = "31.0.1650.4";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-31.0.1650.4.tar.xz";
    sha256 = "1i61izfn06ldxkgdrisdibbn5hrghyjslf81yszpw69k0z87k3lm";
  };
  beta = {
    version = "30.0.1599.66";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-30.0.1599.66.tar.xz";
    sha256 = "092ps4y4s544lswrqqk8qij5n7ax4bsfl5vdj5cwfncvsqpjds4g";
  };
  stable = {
    version = "30.0.1599.66";
    url = "http://commondatastorage.googleapis.com/chromium-browser-official/chromium-30.0.1599.66.tar.xz";
    sha256 = "092ps4y4s544lswrqqk8qij5n7ax4bsfl5vdj5cwfncvsqpjds4g";
  };
}


{ config, options, pkgs, ... }:

{
  imports = [
    ../common.nix
    ../../hardware-configuration.nix # Include the results of the hardware scan.
  ];

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "John-VirtualBox-NixOS"; # Define your hostname.

  environment.systemPackages = with pkgs; [
    git
  ];

  users.users.john.extraGroups = [ "vboxsf" ];

  nix.nixPath = options.nix.nixPath.default ++ [
    ("ssh-config-file=${pkgs.writeText "ssh_config" ''
       Host github.com
       IdentityFile /etc/ssh/ssh_host_rsa_key
       StrictHostKeyChecking=no
     ''}")
  ];
}

Simplify ssh-private key entry in $NIX_PATH

{ config, options, pkgs, ... }:

{
  imports = [
    ../common.nix
    ../../hardware-configuration.nix # Include the results of the hardware scan.
  ];

  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;

  networking.hostName = "John-VirtualBox-NixOS"; # Define your hostname.

  environment.systemPackages = with pkgs; [
    git
  ];

  users.users.john.extraGroups = [ "vboxsf" ];

  nix.nixPath = options.nix.nixPath.default ++ [
    ("ssh-config-file=" + pkgs.writeText "ssh_config" ''
       Host github.com
       IdentityFile /etc/ssh/ssh_host_rsa_key
       StrictHostKeyChecking=no
     '')
  ];
}


{ fetchurl, stdenv }:

stdenv.mkDerivation rec {
  name = "pax-utils-${version}";
  version = "0.9.2";

  src = fetchurl {
    url = "http://dev.gentoo.org/~vapier/dist/${name}.tar.xz";
    sha256 = "1pmlpjhr2475h5v90abmsfgr37r3b6c4mknhzswbgcb10vgh322p";
  };

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

  meta = with stdenv.lib; {
    description = "A suite of tools for PaX/grsecurity";
    homepage    = "http://dev.gentoo.org/~vapier/dist/";
    license     = licenses.gpl2;
    platforms   = platforms.linux;
    maintainers = with maintainers; [ thoughtpolice wizeman ];
  };
}

Update from 0.9.2 -> 1.0

{ fetchurl, stdenv }:

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

  src = fetchurl {
    url = "http://dev.gentoo.org/~vapier/dist/${name}.tar.xz";
    sha256 = "04p356j46symayh2d14i51xv9qic3iz9gnc7fr906skw3hccr7y3";
  };

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

  meta = with stdenv.lib; {
    description = "A suite of tools for PaX/grsecurity";
    homepage    = "http://dev.gentoo.org/~vapier/dist/";
    license     = licenses.gpl2;
    platforms   = platforms.linux;
    maintainers = with maintainers; [ thoughtpolice wizeman ];
  };
}


{ stdenv, buildPackages, hostPlatform, fetchurl, perl, callPackage, linux_latest, ... } @ args:

let buildLinux = attrs: callPackage ./generic.nix attrs; in

with stdenv.lib;

buildLinux (args // rec {
  version = linux_latest.version;

  # modDirVersion needs to be x.y.z, will automatically add .0 if needed
  modDirVersion = concatStrings (intersperse "." (take 3 (splitString "." "${version}.0")));

  # branchVersion needs to be x.y
  extraMeta.branch = concatStrings (intersperse "." (take 2 (splitString "." version)));

  src = linux_latest.src;
} // (args.argsOverride or {}))

Use Linux 4.15 for the time being

{ stdenv, buildPackages, hostPlatform, fetchurl, perl, callPackage, linux_4_15, ... } @ args:

let
  buildLinux = attrs: callPackage ./generic.nix attrs;
  linux = linux_4_15;
in

with stdenv.lib;

buildLinux (args // rec {
  version = linux.version;

  # modDirVersion needs to be x.y.z, will automatically add .0 if needed
  modDirVersion = concatStrings (intersperse "." (take 3 (splitString "." "${version}.0")));

  # branchVersion needs to be x.y
  extraMeta.branch = concatStrings (intersperse "." (take 2 (splitString "." version)));

  src = linux.src;
} // (args.argsOverride or {}))


{ nixpkgs ? import <nixpkgs> {}}:
nixpkgs.callPackage (
{ stdenv, rust, postgresql, openssl, vim_configurable }:

# Vim with rust + git support
let vim = vim_configurable.customize {
  name = "vim";
  vimrcConfig.customRC = ''
    set backspace=indent,eol,start

    let g:rustfmt_autosave = 1
    autocmd FileType rust compiler cargo
    let g:racer_cmd = "${nixpkgs.rustracer}/bin/racer"
    let $RUST_SRC_PATH="${nixpkgs.rustc.src}/src"
    let g:racer_experimental_completer = 1
    au FileType rust nmap gd <Plug>(rust-def)
    au FileType rust nmap gs <Plug>(rust-def-split)
    au FileType rust nmap gx <Plug>(rust-def-vertical)
    au FileType rust nmap <leader>gd <Plug>(rust-doc)
  '';
  vimrcConfig.vam.pluginDictionaries = [{ names = [
    "fugitive"
    "vim-racer"
    "rust-vim"
    "syntastic"
  ];}];
}; in

stdenv.mkDerivation rec {
  name = "bap-rust";
  buildInputs = [ rust postgresql openssl vim ];
}
) {rust = nixpkgs.rustChannels.nightly.rust; }

Use stable rust in dev

{ nixpkgs ? import <nixpkgs> {}}:
nixpkgs.callPackage (
{ stdenv, rust, postgresql, openssl, vim_configurable }:

# Vim with rust + git support
let vim = vim_configurable.customize {
  name = "vim";
  vimrcConfig.customRC = ''
    set backspace=indent,eol,start

    let g:rustfmt_autosave = 1
    autocmd FileType rust compiler cargo
    let g:racer_cmd = "${nixpkgs.rustracer}/bin/racer"
    let $RUST_SRC_PATH="${nixpkgs.rustc.src}/src"
    let g:racer_experimental_completer = 1
    au FileType rust nmap gd <Plug>(rust-def)
    au FileType rust nmap gs <Plug>(rust-def-split)
    au FileType rust nmap gx <Plug>(rust-def-vertical)
    au FileType rust nmap <leader>gd <Plug>(rust-doc)
  '';
  vimrcConfig.vam.pluginDictionaries = [{ names = [
    "fugitive"
    "vim-racer"
    "rust-vim"
    "syntastic"
  ];}];
}; in

stdenv.mkDerivation rec {
  name = "bap-rust";
  buildInputs = [ rust postgresql openssl vim ];
}
) {rust = nixpkgs.rustChannels.stable.rust; }


{ fetchurl }:

rec {
  version = "4.0.6";
  name = "mingw-w64-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/mingw-w64/mingw-w64-v${version}.tar.bz2";
    sha256 = "0p01vm5kx1ixc08402z94g1alip4vx66gjpvyi9maqyqn2a76h0c";
  };
}

Add enable-idl / enable-secure-api flags

{ fetchurl }:

rec {
  version = "4.0.6";
  name = "mingw-w64-${version}";

  src = fetchurl {
    url = "mirror://sourceforge/mingw-w64/mingw-w64-v${version}.tar.bz2";
    sha256 = "0p01vm5kx1ixc08402z94g1alip4vx66gjpvyi9maqyqn2a76h0c";
  };

  configureFlags = [
    "--enable-idl"
    "--enable-secure-api"
  ];
}


{ config, lib, options, pkgs, ... }:
{
  environment.darwinConfig = "$HOME/.local/etc/nix/darwin-configuration.nix";
  environment.systemPackages =
    with pkgs;
    [
      cmake
      ispell
      glslviewer
      nodejs-8_x
      ninja
      nixops
      mercurial
      packer
      ripgrep
      terraform
      urweb
      vagrant
      xz
    ];

  environment.variables.NIX_REMOTE = "daemon";
  launchd.daemons.nix-daemon.environment.OBJC_DISABLE_INITIALIZE_FORK_SAFETY = "YES";
  programs.bash.enable = true;
  programs.fish.enable = true;
  programs.fish.interactiveShellInit = ''
    set fish_function_path $HOME/.local/etc/fish/functions $fish_function_path
  '';

  services.activate-system.enable = true;
  services.nix-daemon.enable = true;
  /* services.mysql.enable = true; */

  system.stateVersion = 4;
  nix.maxJobs = 2;
  nix.nixPath = [ "darwin=/Users/cbarrett/Documents/Code/nix-darwin/default.nix" ] ++ options.nix.nixPath.default;
  nix.package = pkgs.nix;
  nix.trustedUsers = [ "root" "cbarrett" ];
}

Add more commented out mysql stuff

{ config, lib, options, pkgs, ... }:
{
  environment.darwinConfig = "$HOME/.local/etc/nix/darwin-configuration.nix";
  environment.systemPackages =
    with pkgs;
    [
      cmake
      ispell
      glslviewer
      nodejs-8_x
      ninja
      nixops
      mercurial
      packer
      ripgrep
      terraform
      urweb
      vagrant
      xz
    ];

  environment.variables.NIX_REMOTE = "daemon";
  launchd.daemons.nix-daemon.environment.OBJC_DISABLE_INITIALIZE_FORK_SAFETY = "YES";
  programs.bash.enable = true;
  programs.fish.enable = true;
  programs.fish.interactiveShellInit = ''
    set fish_function_path $HOME/.local/etc/fish/functions $fish_function_path
  '';

  services.activate-system.enable = true;
  services.nix-daemon.enable = true;
  /* services.mysql.enable = true; */

  /* system.activationScripts.postActivation.text = '' */
  /*   mkdir -m 775 -p ${config.services.mysql.dataDir} */
  /* ''; */
  system.stateVersion = 4;
  nix.maxJobs = 2;
  nix.nixPath = [ "darwin=/Users/cbarrett/Documents/Code/nix-darwin/default.nix" ] ++ options.nix.nixPath.default;
  nix.package = pkgs.nix;
  nix.trustedUsers = [ "root" "cbarrett" ];
}


with import <nixpkgs> {};

stdenv.mkDerivation {
    name = "node";
    buildInputs = [
        nodejs-8_x
    ];
    shellHook = ''
        export PATH="$PWD/node_modules/.bin/:$PATH"
    '';
}

Add `run` alias for `npm run`

with import <nixpkgs> {};

stdenv.mkDerivation {
    name = "node";
    buildInputs = [
        nodejs-8_x
    ];
    shellHook = ''
        export PATH="$PWD/node_modules/.bin/:$PATH"
        alias run='npm run'
    '';
}


{ stdenv, fetchurl }:

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

  src = fetchurl {
    url = "http://kent.dl.sourceforge.net/sourceforge/linux-diag/${name}.tar.gz";
    sha256 = "e865de2c1f559fff0d3fc936e660c0efaf7afe662064f2fb97ccad1ec28d208a";
  };

  meta = {
    homepage = http://linux-diag.sourceforge.net/Sysfsutils.html;
    longDescription =
      ''
        These are a set of utilites built upon sysfs, a new virtual
        filesystem in Linux kernel versions 2.5+ that exposes a system's
        device tree.
      '';
    license = "GPL-v2 / LGPL-v2.1";
  };
}

Use SourceForge mirror instead of static URL.

{ stdenv, fetchurl }:

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

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

  meta = {
    homepage = http://linux-diag.sourceforge.net/Sysfsutils.html;
    longDescription =
      ''
        These are a set of utilites built upon sysfs, a new virtual
        filesystem in Linux kernel versions 2.5+ that exposes a system's
        device tree.
      '';
    license = "GPL-v2 / LGPL-v2.1";
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "gnu-efi_${version}";
  version = "3.0v";

  src = fetchurl {
    url = "mirror://sourceforge/gnu-efi/${name}.orig.tar.gz";
    sha256 = "1pqgpm999l7zb8gh3s0zd2ax6f0n2l4jip7h0d2y91hhcy6zjxn7";
  };

  arch = with stdenv.lib; head (splitString "-" stdenv.system);

  makeFlags = [
    "CC=gcc"
    "AS=as"
    "LD=ld"
    "AR=ar"
    "RANLIB=ranlib"
    "OBJCOPY=objcopy"
  ];

  buildPhase = ''
    make $makeFlags
    make $makeFlags -C apps clean all
  '';

  installPhase = ''
    mkdir -pv $out/include/efi/{protocol,$arch}
    make PREFIX="$out" $makeFlags install
    mkdir -pv $out/share/gnu-efi
    install -D -m644 apps/*.efi $out/share/gnu-efi
  '';

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

Downgrade gnu-efi back: this fixes build of gummiboot without breaking syslinux build

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "gnu-efi_${version}";
  version = "3.0u";

  src = fetchurl {
    url = "mirror://sourceforge/gnu-efi/${name}.orig.tar.gz";
    sha256 = "0klkdxh1aqwwfm393q67nxww6liffyp2lfybbnh4q819b06la39w";
  };

  arch = with stdenv.lib; head (splitString "-" stdenv.system);

  makeFlags = [
    "CC=gcc"
    "AS=as"
    "LD=ld"
    "AR=ar"
    "RANLIB=ranlib"
    "OBJCOPY=objcopy"
  ];

  buildPhase = ''
    make $makeFlags
    make $makeFlags -C apps clean all
  '';

  installPhase = ''
    mkdir -pv $out/include/efi/{protocol,$arch}
    make PREFIX="$out" $makeFlags install
    mkdir -pv $out/share/gnu-efi
    install -D -m644 apps/*.efi $out/share/gnu-efi
  '';

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


{ lib, stdenv, fetchFromGitHub, postgresql, python2, gnused }:

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

  src = fetchFromGitHub {
    owner = "jtv";
    repo = "libpqxx";
    rev = version;
    sha256 = "1dv96h10njg115216n2zm6fsvi4kb502hmhhn8cjhlfbxr9vc84q";
  };

  nativeBuildInputs = [ gnused python2 ];
  buildInputs = [ postgresql ];

  preConfigure = ''
    patchShebangs .
  '';

  configureFlags = "--enable-shared";

  meta = {
    description = "A C++ library to access PostgreSQL databases";
    homepage = http://pqxx.org/development/libpqxx/;
    license = lib.licenses.postgresql;
    platforms = lib.platforms.linux;
    maintainers = [ lib.maintainers.eelco ];
  };
}

Add dependency on doxygen and xmlto

{ lib, stdenv, fetchFromGitHub, postgresql, doxygen, xmlto, python2, gnused }:

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

  src = fetchFromGitHub {
    owner = "jtv";
    repo = "libpqxx";
    rev = version;
    sha256 = "1dv96h10njg115216n2zm6fsvi4kb502hmhhn8cjhlfbxr9vc84q";
  };

  nativeBuildInputs = [ gnused python2 ];
  buildInputs = [ postgresql doxygen xmlto ];

  preConfigure = ''
    patchShebangs .
  '';

  configureFlags = "--enable-shared";

  meta = {
    description = "A C++ library to access PostgreSQL databases";
    homepage = http://pqxx.org/development/libpqxx/;
    license = lib.licenses.postgresql;
    platforms = lib.platforms.linux;
    maintainers = [ lib.maintainers.eelco ];
  };
}


{ stdenv, fetchurl, buildPythonPackage, pythonPackages, pygtk }:

buildPythonPackage {
  name = "keepnote-0.7.8";
  namePrefix = "";

  src = fetchurl {
    url = "http://keepnote.org/download/keepnote-0.7.8.tar.gz";
    sha256 = "0nhkkv1n0lqf3zn17pxg5cgryv1wwlj4hfmhixwd76rcy8gs45dh";
  };

  propagatedBuildInputs = [ pythonPackages.sqlite3 pygtk ];

  # Testing fails.
  doCheck = false;

  meta = {
    description = "Note taking application";
    homepage = http://rasm.ods.org/keepnote;
    license = stdenv.lib.licenses.gpl2Plus;
    maintainers = [ maintainers.robberer ];
  };
}

Revert "keepnote: add myself as a maintainer"

{ stdenv, fetchurl, buildPythonPackage, pythonPackages, pygtk }:

buildPythonPackage {
  name = "keepnote-0.7.8";
  namePrefix = "";

  src = fetchurl {
    url = "http://keepnote.org/download/keepnote-0.7.8.tar.gz";
    sha256 = "0nhkkv1n0lqf3zn17pxg5cgryv1wwlj4hfmhixwd76rcy8gs45dh";
  };

  propagatedBuildInputs = [ pythonPackages.sqlite3 pygtk ];

  # Testing fails.
  doCheck = false;

  meta = {
    description = "Note taking application";
    homepage = http://rasm.ods.org/keepnote;
    license = stdenv.lib.licenses.gpl2Plus;
  };
}


{ cabal }:

cabal.mkDerivation (self: {
  pname = "modular-arithmetic";
  version = "1.0.1.1";
  sha256 = "14n83kjmz8mqjivjhwxk1zckms5z3gn77yq2hsw2yybzff2vkdkd";
  meta = {
    description = "A type for integers modulo some constant";
    license = self.stdenv.lib.licenses.bsd3;
    platforms = self.ghc.meta.platforms;
  };
})

Add noHaddock flag to modular-artihmetic

{ cabal }:

cabal.mkDerivation (self: {
  pname = "modular-arithmetic";
  version = "1.0.1.1";
  sha256 = "14n83kjmz8mqjivjhwxk1zckms5z3gn77yq2hsw2yybzff2vkdkd";
  noHaddock = true;
  meta = {
    description = "A type for integers modulo some constant";
    license = self.stdenv.lib.licenses.bsd3;
    platforms = self.ghc.meta.platforms;
  };
})


with import <nixpkgs> {
  overlays = [
    (self: super: {
      dep = import ./nix/dep.nix super;
    })
  ];
};

stdenv.mkDerivation {
    name = "dividat-driver";
    builder = "${bash}/bin/bash";
    buildInputs = [
      go_1_9
      dep

      gcc
      # Required for static linking on Linux
      (if stdenv.isDarwin then null else musl)

      # node for tests
      nodejs-8_x
    ];
}

Add awscli to nix environment

with import <nixpkgs> {
  overlays = [
    (self: super: {
      dep = import ./nix/dep.nix super;
    })
  ];
};

stdenv.mkDerivation {
    name = "dividat-driver";
    builder = "${bash}/bin/bash";
    buildInputs = [
      go_1_9
      dep

      gcc
      # Required for static linking on Linux
      (if stdenv.isDarwin then null else musl)

      # node for tests
      nodejs-8_x

      # for deployment to S3
      awscli
    ];
}


{ 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
    python3
    rustc
    rustfmt
    rustracer
    swiProlog
    swiftformat
  ];
}

Use RLS instead of Rust Racer.

{ 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
    python3
    rls
    rustPlatform.rust.rustc
    rustPlatform.rustcSrc
    rustfmt
    swiProlog
    swiftformat
  ];
}


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

Update stable to 50.0.2661.102 for multiple security fixes

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


with import (fetchTarball https://github.com/nixos/nixpkgs/tarball/f52505fac8c82716872a616c501ad9eff188f97f) { };

stdenv.mkDerivation {
    name = "dev-shell";
    src = null;
    buildInputs = [ nodejs-11_x ];
}

Use node 12, which is needed for Object.fromEntries.

with import (fetchTarball https://github.com/nixos/nixpkgs/tarball/525f0b043652cb62192874054d7aca5843d45e8f) { };

stdenv.mkDerivation {
    name = "dev-shell";
    src = null;
    buildInputs = [ nodejs-12_x ];
}


# Helper script for Niklaus to be able to work under NixOS
# To get into a fish shell call in this directory: nix-shell --run fish
{ pkgs ? import <nixpkgs> {} }:
let mvn = pkgs.maven.override { jdk = pkgs.openjdk8; };
in pkgs.mkShell {
  buildInputs = [ mvn pkgs.jq pkgs.adoptopenjdk-hotspot-bin-8 pkgs.ruby pkgs.rubyPackages.rugged];
}
# Tested with the following commands after calling nix-shell
# mvn -V clean verify  -Dtycho.localArtifacts=ignore -DskipTests
# ./ch.elexis.core.releng/update_changelog.rb  --force-tag=release/3.8 --with-tickets

Update nixos to use java11

# Helper script for Niklaus to be able to work under NixOS
# To get into a fish shell call in this directory: nix-shell --run fish
{ pkgs ? import <nixpkgs> {} }:
let mvn = pkgs.maven.override { jdk = pkgs.openjdk11; };
in pkgs.mkShell {
  buildInputs = [ mvn pkgs.jq pkgs.adoptopenjdk-hotspot-bin-11 pkgs.ruby pkgs.rubyPackages.rugged];
}
# Tested with the following commands after calling nix-shell
# mvn -V clean verify  -Dtycho.localArtifacts=ignore -DskipTests
# ./ch.elexis.core.releng/update_changelog.rb  --force-tag=release/3.8 --with-tickets


{ pkgs ?  import ./nixpkgs.nix {}
, ghc ? pkgs.haskell.compiler.ghc8107
}:

with pkgs;

haskell.lib.buildStackProject ({
  name = "liquidhaskell-stack";
  buildInputs = [
    git
    hostname
    nix
    z3
  ];
  ghc = ghc;
  LANG = "en_US.utf8";
})

Add cacert to suppress message from Nix when downloading nixpkgs

{ pkgs ?  import ./nixpkgs.nix {}
, ghc ? pkgs.haskell.compiler.ghc8107
}:

with pkgs;

haskell.lib.buildStackProject ({
  name = "liquidhaskell-stack";
  buildInputs = [
    cacert
    git
    hostname
    nix
    z3
  ];
  ghc = ghc;
  LANG = "en_US.utf8";
})


{ stdenv, fetchFromGitHub, makeWrapper, perl, mono, gtk }:

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

  src = fetchFromGitHub {
    owner = "KSP-CKAN";
    repo = "CKAN";
    rev = "v${version}";
    sha256 = "0lfvl8w09lakz35szp5grfvhq8xx486f5igvj1m6azsql4n929lg";
  };

  buildInputs = [ makeWrapper perl mono gtk ];

  postPatch = ''
    substituteInPlace bin/build \
      --replace /usr/bin/perl ${perl}/bin/perl
  '';

  # Tests don't currently work, as they try to write into /var/empty.
  doCheck = false;
  checkTarget = "test";

  installPhase = ''
    mkdir -p $out/bin
    for exe in *.exe; do
      install -m 0644 $exe $out/bin
      makeWrapper ${mono}/bin/mono $out/bin/$(basename $exe .exe) \
        --add-flags $out/bin/$exe \
        --set LD_LIBRARY_PATH ${gtk.out}/lib
    done
  '';

  meta = {
    description = "Mod manager for Kerbal Space Program";
    homepage = https://github.com/KSP-CKAN/CKAN;
    license = stdenv.lib.licenses.mit;
    maintainers = [ stdenv.lib.maintainers.Baughn ];
    platforms = stdenv.lib.platforms.all;
  };
}

Add curl to runtime libraries

{ stdenv, fetchFromGitHub, makeWrapper, perl, mono, gtk, curl }:

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

  src = fetchFromGitHub {
    owner = "KSP-CKAN";
    repo = "CKAN";
    rev = "v${version}";
    sha256 = "0lfvl8w09lakz35szp5grfvhq8xx486f5igvj1m6azsql4n929lg";
  };

  buildInputs = [ makeWrapper perl mono ];

  postPatch = ''
    substituteInPlace bin/build \
      --replace /usr/bin/perl ${perl}/bin/perl
  '';

  # Tests don't currently work, as they try to write into /var/empty.
  doCheck = false;
  checkTarget = "test";

  libraries = stdenv.lib.makeLibraryPath [ gtk curl ];

  installPhase = ''
    mkdir -p $out/bin
    for exe in *.exe; do
      install -m 0644 $exe $out/bin
      makeWrapper ${mono}/bin/mono $out/bin/$(basename $exe .exe) \
        --add-flags $out/bin/$exe \
        --set LD_LIBRARY_PATH $libraries
    done
  '';

  meta = {
    description = "Mod manager for Kerbal Space Program";
    homepage = https://github.com/KSP-CKAN/CKAN;
    license = stdenv.lib.licenses.mit;
    maintainers = [ stdenv.lib.maintainers.Baughn ];
    platforms = stdenv.lib.platforms.all;
  };
}


{ stdenv, fetchurl, qt4, alsaLib, jackaudio }:

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

  # some dependencies such as killall have to be installed additionally

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

  buildInputs = [ qt4 alsaLib jackaudio ];

  meta = {
    description = "qt jackd control gui tool";
    homepage = http://qjackctl.sourceforge.net/;
    license = "GPL";
  };
}

Add dbus support to qjackctl so that it can use jackdbus

{ stdenv, fetchurl, qt4, alsaLib, jackaudio, dbus }:

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

  # some dependencies such as killall have to be installed additionally

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

  buildInputs = [ qt4 alsaLib jackaudio dbus ];

  meta = {
    description = "qt jackd control gui tool";
    homepage = http://qjackctl.sourceforge.net/;
    license = "GPL";
  };
}


{ stdenv, fetchurl, xz, coreutils ? null }:

stdenv.mkDerivation rec {
  name = "diffutils-3.4";

  src = fetchurl {
    url = "mirror://gnu/diffutils/${name}.tar.xz";
    sha256 = "1qlw328qpbss07zrb14ls0rhnhbvxrnssgbmrxxj2gdcy8jw0lyv";
  };

  outputs = [ "out" "info" ];

  /* If no explicit coreutils is given, use the one from stdenv. */
  nativeBuildInputs = [ xz.bin coreutils ];

  meta = {
    homepage = http://www.gnu.org/software/diffutils/diffutils.html;
    description = "Commands for showing the differences between files (diff, cmp, etc.)";
    platforms = stdenv.lib.platforms.unix;
  };
}

Revert "diffutils: 3.3 -> 3.4"

{ stdenv, fetchurl, xz, coreutils ? null }:

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

  src = fetchurl {
    url = "mirror://gnu/diffutils/${name}.tar.xz";
    sha256 = "1761vymxbp4wb5rzjvabhdkskk95pghnn67464byvzb5mfl8jpm2";
  };

  outputs = [ "out" "info" ];

  /* If no explicit coreutils is given, use the one from stdenv. */
  nativeBuildInputs = [ xz.bin coreutils ];

  meta = {
    homepage = http://www.gnu.org/software/diffutils/diffutils.html;
    description = "Commands for showing the differences between files (diff, cmp, etc.)";
    platforms = stdenv.lib.platforms.unix;
  };
}


{ pkgs ? import ../nix/nixpkgs.nix, compiler ? null
, forShell ? pkgs.lib.inNixShell, hoogle ? forShell, withSwiftshader ? false
, buildProfiling ? false }:

let
  haskellPackages = let
    hp = if compiler == null then
      pkgs.haskellPackages
    else
      pkgs.haskell.packages.${compiler};
  in hp.override {
    overrides = import ../nix/haskell-packages.nix {
      inherit pkgs hoogle buildProfiling;
    };
  };

in if forShell then
  haskellPackages.shellFor ({
    packages = p: [ p.vulkan-examples ];
    buildInputs = with pkgs; [
      vulkan-tools-lunarg
      vulkan-validation-layers
      shaderc
    ];
    withHoogle = hoogle;
  } // pkgs.lib.optionalAttrs withSwiftshader {
    VK_ICD_FILENAMES =
      "${pkgs.swiftshader}/share/vulkan/icd.d/vk_swiftshader_icd.json";
  })
else
  haskellPackages.vulkan-examples

Use vulkan-extension-layer for swiftshader shell

{ pkgs ? import ../nix/nixpkgs.nix, compiler ? null
, forShell ? pkgs.lib.inNixShell, hoogle ? forShell, withSwiftshader ? false
, buildProfiling ? false }:

let
  haskellPackages = let
    hp = if compiler == null then
      pkgs.haskellPackages
    else
      pkgs.haskell.packages.${compiler};
  in hp.override {
    overrides = import ../nix/haskell-packages.nix {
      inherit pkgs hoogle buildProfiling;
    };
  };

in if forShell then
  haskellPackages.shellFor ({
    packages = p: [ p.vulkan-examples ];
    buildInputs = with pkgs;
      [ vulkan-tools-lunarg vulkan-validation-layers shaderc ]
      ++ pkgs.lib.optional withSwiftshader vulkan-extension-layer;
    withHoogle = hoogle;
  } // pkgs.lib.optionalAttrs withSwiftshader {
    VK_ICD_FILENAMES =
      "${pkgs.swiftshader}/share/vulkan/icd.d/vk_swiftshader_icd.json";
  })
else
  haskellPackages.vulkan-examples


# 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 = [ buildPackages.stdenv.cc pkgconfig openssl.dev ];
}

Add xdg_utils to built inputs for NixOS 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 = [ buildPackages.stdenv.cc pkgconfig openssl.dev xdg_utils ];
}


{ haskellPackages }:

with haskellPackages;

cabal.mkDerivation (self: {
  pname = "nixrbd";
  version = "0.0";
  isLibrary = false;
  isExecutable = true;
  src = ./.;
  buildDepends = [
    cmdargs
    httpTypes
    text
    transformers
    wai
    warp
  ];
})

Install nixrbd.nix in include dir

{ haskellPackages }:

with haskellPackages;

cabal.mkDerivation (self: {
  pname = "nixrbd";
  version = "0.0";
  isLibrary = false;
  isExecutable = true;
  src = ./.;
  postInstall = ''
    mkdir -p $out/include
    cp lib/nixrbd.nix $out/include/
  '';
  buildDepends = [
    cmdargs
    httpTypes
    text
    transformers
    wai
    warp
  ];
})


{ config, lib, pkgs, ... }:
{
  imports = [
    ./base
    ./connectiq
    ./emacs
    ./gpg
    ./haskell
    ./mail
    ./theme
    ./xsession
  ];

  config = {
    # TODO: https://github.com/NixOS/nixpkgs/issues/60012
    services.nextcloud-client.enable = true;

    home.packages = [
      pkgs.chromium # a browser
      pkgs.docker-compose # docker projects
      pkgs.firefox # the browser
      pkgs.gnome3.eog # image viewer
      pkgs.gnome3.evince # pdf viewer
      # pkgs.gnome3.nautilus -> see README.md#Dependencies
      pkgs.pandoc # convert everything
      pkgs.scrot # screenshots
      pkgs.keepassxc # secret stuff
      pkgs.spotify # unlimited music
      pkgs.signal-desktop # connect with rl
      pkgs.skype # old-school comms
    ];
  };
}

Fix module reference to base.nix

{ config, lib, pkgs, ... }:
{
  imports = [
    ./base.nix
    ./connectiq
    ./emacs
    ./gpg
    ./haskell
    ./mail
    ./theme
    ./xsession
  ];

  config = {
    # TODO: https://github.com/NixOS/nixpkgs/issues/60012
    services.nextcloud-client.enable = true;

    home.packages = [
      pkgs.chromium # a browser
      pkgs.docker-compose # docker projects
      pkgs.firefox # the browser
      pkgs.gnome3.eog # image viewer
      pkgs.gnome3.evince # pdf viewer
      # pkgs.gnome3.nautilus -> see README.md#Dependencies
      pkgs.pandoc # convert everything
      pkgs.scrot # screenshots
      pkgs.keepassxc # secret stuff
      pkgs.spotify # unlimited music
      pkgs.signal-desktop # connect with rl
      pkgs.skype # old-school comms
    ];
  };
}


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

{
  options = {
    roles.java.haveIntelliJUltimateLicense = lib.mkOption {
      type = lib.types.bool;
      default = false;
    };
  };

  config = {
    environment.systemPackages = with pkgs; [
      openjdk

      # Build tools
      maven
      gradle

      # IDEs
      eclipses.eclipse-java
      (if config.roles.java.haveIntelliJUltimateLicense then idea.idea-ultimate else idea.idea-community)
    ];
    my-config.vscodeExtensions = with (import ../vscode-extensions.nix); [
      vscode-java-pack
    ];
  };
}

Install OpenJDK 12 alongside OpenJDK 8, add symlinks to /nix/store

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

let
  pkgs-unstable = import <nixpkgs-unstable> { config = { allowUnfree = true; }; };
in
{
  options = {
    roles.java.haveIntelliJUltimateLicense = lib.mkOption {
      type = lib.types.bool;
      default = false;
    };
  };

  config = {
    # add symlinks /etc/openjdk{8,12} to /nix/store
    environment.etc = {
      "openjdk8".source = "${pkgs.openjdk8}/lib/openjdk";
      "openjdk12".source = "${pkgs-unstable.openjdk12}/lib/openjdk";
    };

    environment.systemPackages = with pkgs; [
      openjdk

      # Build tools
      maven
      gradle

      # IDEs
      eclipses.eclipse-java
      (if config.roles.java.haveIntelliJUltimateLicense then idea.idea-ultimate else idea.idea-community)
    ];
    my-config.vscodeExtensions = with (import ../vscode-extensions.nix); [
      vscode-java-pack
    ];
  };
}


{ stdenv, fetchurl, zlib }:

stdenv.mkDerivation rec {
  name = "kexec-tools-${version}";
  version = "2.0.16";

  src = fetchurl {
    urls = [
      "mirror://kernel/linux/utils/kernel/kexec/${name}.tar.xz"
      "http://horms.net/projects/kexec/kexec-tools/${name}.tar.xz"
    ];
    sha256 = "043hasx5b9zk7r7dzx24z5wybg74dpmh0nyns6nrnb3mmm8k642v";
  };

  hardeningDisable = [ "format" "pic" "relro" ];

  buildInputs = [ zlib ];

  meta = with stdenv.lib; {
    homepage = http://horms.net/projects/kexec/kexec-tools;
    description = "Tools related to the kexec Linux feature";
    platforms = platforms.linux;
  };
}

Add dependency on build CC

{ stdenv, buildPackages, fetchurl, zlib }:

stdenv.mkDerivation rec {
  name = "kexec-tools-${version}";
  version = "2.0.16";

  src = fetchurl {
    urls = [
      "mirror://kernel/linux/utils/kernel/kexec/${name}.tar.xz"
      "http://horms.net/projects/kexec/kexec-tools/${name}.tar.xz"
    ];
    sha256 = "043hasx5b9zk7r7dzx24z5wybg74dpmh0nyns6nrnb3mmm8k642v";
  };

  hardeningDisable = [ "format" "pic" "relro" ];

  nativeBuildInputs = [ buildPackages.stdenv.cc ];
  buildInputs = [ zlib ];

  meta = with stdenv.lib; {
    homepage = http://horms.net/projects/kexec/kexec-tools;
    description = "Tools related to the kexec Linux feature";
    platforms = platforms.linux;
  };
}


{ pkgs, config, ... }:

{
  programs.bash = {
    enable = true;
    historyControl = [ "ignorespace" ];

    initExtra = ''
      # Shell prompt
      function git_slug {
          if $(test -d .git); then
              if $([ -z "$(git status --porcelain)" ]); then
                  echo "$(git rev-parse --abbrev-ref HEAD)  "
              else
                  echo "$(git rev-parse --abbrev-ref HEAD)* "
              fi
          fi
      }
      export PS1='\[\033[1;33m\]\w\[\033[0m\] $(git_slug)$ '
    '';

    shellAliases = {
      l = "LC_COLLATE=C ls --group-directories-first -FHAlh -w 80";
      ll = "LC_COLLATE=C ls --group-directories-first -FHA -w 80";
      ls = "LC_COLLATE=C ls --group-directories-first -FH -w 80";
      vi = "${config.home.sessionVariables.EDITOR}";
      vim = "${config.home.sessionVariables.EDITOR}";
      space = "find -maxdepth 1 -exec du -sh '{}' \\; | sort -h";
      suspace = "sudo find -maxdepth 1 -exec du -sh '{}' --exclude='proc' \\; | sort -h";
    };

    shellOptions = [
      "cmdhist"
      "histappend"
      "checkwinsize"
      "extglob"
      "globstar"
      "checkjobs"
    ];
  };
}

Use color in ls aliases

{ pkgs, config, ... }:

{
  programs.bash = {
    enable = true;
    historyControl = [ "ignorespace" ];

    initExtra = ''
      # Shell prompt
      function git_slug {
          if $(test -d .git); then
              if $([ -z "$(git status --porcelain)" ]); then
                  echo "$(git rev-parse --abbrev-ref HEAD)  "
              else
                  echo "$(git rev-parse --abbrev-ref HEAD)* "
              fi
          fi
      }
      export PS1='\[\033[1;33m\]\w\[\033[0m\] $(git_slug)$ '
    '';

    shellAliases = {
      l = "LC_COLLATE=C ls --group-directories-first --color -FHAlh -w 80";
      ll = "LC_COLLATE=C ls --group-directories-first --color -FHA -w 80";
      ls = "LC_COLLATE=C ls --group-directories-first --color -FH -w 80";
      vi = "${config.home.sessionVariables.EDITOR}";
      vim = "${config.home.sessionVariables.EDITOR}";
      space = "find -maxdepth 1 -exec du -sh '{}' \\; | sort -h";
      suspace = "sudo find -maxdepth 1 -exec du -sh '{}' --exclude='proc' \\; | sort -h";
    };

    shellOptions = [
      "cmdhist"
      "histappend"
      "checkwinsize"
      "extglob"
      "globstar"
      "checkjobs"
    ];
  };
}


{ stdenv, fetchurl, erlang, python, libxml2, libxslt, xmlto
, docbook_xml_dtd_45, docbook_xsl }:

stdenv.mkDerivation rec {
  name = "rabbitmq-server-2.4.0";

  src = fetchurl {
    url = "http://www.rabbitmq.com/releases/rabbitmq-server/v2.4.0/${name}.tar.gz";
    sha256 = "0zvyyqw9kpzi791hvv8qj1aw0fpx5m5cgqfvffxfrdz8daxx3nma";
  };

  buildInputs =
    [ erlang python libxml2 libxslt xmlto docbook_xml_dtd_45 docbook_xsl ];

  preBuild =
    ''
      # Fix the "/usr/bin/env" in "calculate-relative".
      patchShebangs .
    '';

  installFlags = "TARGET_DIR=$(out)/libexec/rabbitmq SBIN_DIR=$(out)/sbin MAN_DIR=$(out)/share/man";

  postInstall =
    ''
      echo 'PATH=${erlang}/bin:${PATH:+:}$PATH' >> $out/sbin/rabbitmq-env
    ''; # */

  meta = {
    homepage = http://www.rabbitmq.com/;
    description = "An implementation of the AMQP messaging protocol";
    platforms = stdenv.lib.platforms.linux;
  };
}

Update rabbitmq to version 3.0.3

{ stdenv, fetchurl, erlang, python, libxml2, libxslt, xmlto
, docbook_xml_dtd_45, docbook_xsl, zip, unzip }:

stdenv.mkDerivation rec {
  name = "rabbitmq-server-3.0.3";

  src = fetchurl {
    url = "http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.3/${name}.tar.gz";
    sha256 = "07mp57xvszdrlgw8rgn9r9dpa6vdqdjk7f1dyh6a9sdg8s9fby38";
  };

  buildInputs =
    [ erlang python libxml2 libxslt xmlto docbook_xml_dtd_45 docbook_xsl zip unzip ];

  preBuild =
    ''
      # Fix the "/usr/bin/env" in "calculate-relative".
      patchShebangs .
    '';

  installFlags = "TARGET_DIR=$(out)/libexec/rabbitmq SBIN_DIR=$(out)/sbin MAN_DIR=$(out)/share/man";

  postInstall =
    ''
      echo 'PATH=${erlang}/bin:${PATH:+:}$PATH' >> $out/sbin/rabbitmq-env
    ''; # */

  meta = {
    homepage = http://www.rabbitmq.com/;
    description = "An implementation of the AMQP messaging protocol";
    platforms = stdenv.lib.platforms.linux;
  };
}


{ nixpkgs ? <nixpkgs> }:

let
  pkgs = import nixpkgs {};
in
rec {
  HelloLibrary = import ./HelloLibrary {
    inherit (pkgs) dotnetenv;
  };

  HelloWorldLibrary = import ./HelloWorldLibrary {
    inherit (pkgs) dotnetenv;
    inherit HelloLibrary;
  };

  HelloWorldApplication = import ./HelloWorldApplication {
    inherit (pkgs) dotnetenv;
    inherit HelloWorldLibrary;
  };
}

Use callPackage for the top-level composition expression

{ nixpkgs ? <nixpkgs> }:

let
  pkgs = import nixpkgs {};

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

  self = {
    HelloLibrary = callPackage ./HelloLibrary { };

    HelloWorldLibrary = callPackage ./HelloWorldLibrary { };

    HelloWorldApplication = callPackage ./HelloWorldApplication { };
  };
in
self


{stdenv, fetchurl, apacheAnt, jdk, unzip}:

stdenv.mkDerivation {
  name = "axis2-1.6.2";

  src = fetchurl {
    url = http://apache.proserve.nl//axis/axis2/java/core/1.6.2/axis2-1.6.2-bin.zip;
    sha256 = "02i6fv11ksd5ql81i501bcb11ib5gyhq3zxwrz5jm4ic80r097fp";
  };

  buildInputs = [ unzip apacheAnt jdk ];
  builder = ./builder.sh;
}

Remove the extra slash in URL

{stdenv, fetchurl, apacheAnt, jdk, unzip}:

stdenv.mkDerivation {
  name = "axis2-1.6.2";

  src = fetchurl {
    url = http://apache.proserve.nl/axis/axis2/java/core/1.6.2/axis2-1.6.2-bin.zip;
    sha256 = "02i6fv11ksd5ql81i501bcb11ib5gyhq3zxwrz5jm4ic80r097fp";
  };

  buildInputs = [ unzip apacheAnt jdk ];
  builder = ./builder.sh;
}


{ lib
, buildPythonPackage
, fetchFromGitHub
, smbus-cffi
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "bme680";
  version = "1.0.5";

  src = fetchFromGitHub {
    owner = "pimoroni";
    repo = "bme680-python";
    rev = "v${version}";
    sha256 = "sha256-oIXh1JnGTI/Cj4MQFpWq+sWR2X+ioCsK0Q+T7wPITCQ=";
  };

  propagatedBuildInputs = [ smbus-cffi ];

  preBuild = ''
    cd library
  '';
  checkInputs = [ pytestCheckHook ];

  # next release will have tests, but not the current one
  doCheck = false;

  pythonImportsCheck = [ "bme680" ];

  meta = with lib; {
    description = "Python library for driving the Pimoroni BME680 Breakout";
    homepage = "https://github.com/pimoroni/bme680-python";
    license = licenses.mit;
    maintainers = with maintainers; [ mic92 ];
  };
}

Mark Linux only as upstream

{ lib
, buildPythonPackage
, fetchFromGitHub
, smbus-cffi
, pytestCheckHook
}:

buildPythonPackage rec {
  pname = "bme680";
  version = "1.0.5";

  src = fetchFromGitHub {
    owner = "pimoroni";
    repo = "bme680-python";
    rev = "v${version}";
    sha256 = "sha256-oIXh1JnGTI/Cj4MQFpWq+sWR2X+ioCsK0Q+T7wPITCQ=";
  };

  propagatedBuildInputs = [ smbus-cffi ];

  preBuild = ''
    cd library
  '';
  checkInputs = [ pytestCheckHook ];

  # next release will have tests, but not the current one
  doCheck = false;

  pythonImportsCheck = [ "bme680" ];

  meta = with lib; {
    description = "Python library for driving the Pimoroni BME680 Breakout";
    homepage = "https://github.com/pimoroni/bme680-python";
    license = licenses.mit;
    platforms = platforms.linux;
    maintainers = with maintainers; [ mic92 ];
  };
}


{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "uncrustify-0.60";

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

  meta = with stdenv.lib; {
    description = "Source code beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA";
    homepage = http://uncrustify.sourceforge.net/;
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
    maintainers = [ maintainers.bjornfor ];
  };
}

Change current version of uncrustify to 0.61

{ stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "uncrustify";
  version = "0.61";

  src = fetchurl {
    url = "mirror://sourceforge/uncrustify/${name}-${version}.tar.gz";
    sha256 = "1df0e5a2716e256f0a4993db12f23d10195b3030326fdf2e07f8e6421e172df9";
  };

  meta = with stdenv.lib; {
    description = "Source code beautifier for C, C++, C#, ObjectiveC, D, Java, Pawn and VALA";
    homepage = http://uncrustify.sourceforge.net/;
    license = licenses.gpl2Plus;
    platforms = platforms.linux;
    maintainers = [ maintainers.bjornfor ];
  };
}


{ config, pkgs, modulesPath, ... }:

{
  imports = [ "${modulesPath}/virtualisation/amazon-image.nix" ];
}

Fix import using module args


{ stdenv, fetchurl, fetchpatch, pkgconfig, ncurses, readline }:

stdenv.mkDerivation rec {
  name = "abook-0.6.0pre2";

  src = fetchurl {
    url = "http://abook.sourceforge.net/devel/${name}.tar.gz";
    sha256 = "11fkyq9bqw7s6jf38yglk8bsx0ar2wik0fq0ds0rdp8985849m2r";
  };

  patches = [
    (fetchpatch {
       url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/gcc5.patch?h=packages/abook";
       name = "gcc5.patch";
       sha256 = "13n3qd6yy45i5n8ppjn9hj6y63ymjrq96280683xk7f7rjavw5nn";
     })
  ];

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ ncurses readline ];

  # Changed inline semantics in GCC5, need to export symbols for inline funcs
  postPatch = ''
    substituteInPlace database.c --replace inline extern
  '';

  meta = {
    homepage = "http://abook.sourceforge.net/";
    description = "Text-based addressbook program designed to use with mutt mail client";
    license = stdenv.lib.licenses.gpl2;
    maintainers = [ stdenv.lib.maintainers.edwtjo ];
    platforms = with stdenv.lib.platforms; linux;
  };
}

Revert "abook: fix compiling with gcc5"

{ stdenv, fetchurl, fetchpatch, pkgconfig, ncurses, readline }:

stdenv.mkDerivation rec {
  name = "abook-0.6.0pre2";

  src = fetchurl {
    url = "http://abook.sourceforge.net/devel/${name}.tar.gz";
    sha256 = "11fkyq9bqw7s6jf38yglk8bsx0ar2wik0fq0ds0rdp8985849m2r";
  };

  patches = [
    (fetchpatch {
       url = "https://projects.archlinux.org/svntogit/packages.git/plain/trunk/gcc5.patch?h=packages/abook";
       name = "gcc5.patch";
       sha256 = "13n3qd6yy45i5n8ppjn9hj6y63ymjrq96280683xk7f7rjavw5nn";
     })
  ];

  nativeBuildInputs = [ pkgconfig ];
  buildInputs = [ ncurses readline ];

  meta = {
    homepage = "http://abook.sourceforge.net/";
    description = "Text-based addressbook program designed to use with mutt mail client";
    license = stdenv.lib.licenses.gpl2;
    maintainers = [ stdenv.lib.maintainers.edwtjo ];
    platforms = with stdenv.lib.platforms; linux;
  };
}


{ stdenv, fetchurl } :

stdenv.mkDerivation rec {
  name = "joe-4.1";

  src = fetchurl {
    url = "mirror://sourceforge/joe-editor/${name}.tar.gz";
    sha256 = "1nznzr9h0rh8g15c56yxzwpn2labx9sgsak0wcnpj7wmpnr12ql1";
  };

  meta = with stdenv.lib; {
    description = "A full featured terminal-based screen editor";
    homepage = http://joe-editor.sourceforge.net;
    license = licenses.gpl2;
  };
}

Move version to own variable

{ stdenv, fetchurl } :

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

  src = fetchurl {
    url = "mirror://sourceforge/joe-editor/${name}.tar.gz";
    sha256 = "1nznzr9h0rh8g15c56yxzwpn2labx9sgsak0wcnpj7wmpnr12ql1";
  };

  meta = with stdenv.lib; {
    description = "A full featured terminal-based screen editor";
    homepage = http://joe-editor.sourceforge.net;
    license = licenses.gpl2;
  };
}


{ lib, stdenv, fetchurl, m4, which, yasm }:

stdenv.mkDerivation rec {
  pname = "mpir";
  version = "3.0.0";

  nativeBuildInputs = [ m4 which yasm ];

  src = fetchurl {
    url = "https://mpir.org/mpir-${version}.tar.bz2";
    sha256 = "1fvmhrqdjs925hzr2i8bszm50h00gwsh17p2kn2pi51zrxck9xjj";
  };

  configureFlags = [ "--enable-cxx --enable-fat" ];

  meta = {
    inherit version;
    description = "A highly optimised library for bignum arithmetic forked from GMP";
    license = lib.licenses.lgpl3Plus;
    maintainers = [lib.maintainers.raskin];
    platforms = lib.platforms.unix;
    downloadPage = "https://mpir.org/downloads.html";
    homepage = "https://mpir.org/";
    updateWalker = true;
  };
}

Fix configureFlags to be array

{ lib, stdenv, fetchurl, m4, which, yasm }:

stdenv.mkDerivation rec {
  pname = "mpir";
  version = "3.0.0";

  nativeBuildInputs = [ m4 which yasm ];

  src = fetchurl {
    url = "https://mpir.org/mpir-${version}.tar.bz2";
    sha256 = "1fvmhrqdjs925hzr2i8bszm50h00gwsh17p2kn2pi51zrxck9xjj";
  };

  configureFlags = [ "--enable-cxx" "--enable-fat" ];

  meta = {
    inherit version;
    description = "A highly optimised library for bignum arithmetic forked from GMP";
    license = lib.licenses.lgpl3Plus;
    maintainers = [lib.maintainers.raskin];
    platforms = lib.platforms.unix;
    downloadPage = "https://mpir.org/downloads.html";
    homepage = "https://mpir.org/";
    updateWalker = true;
  };
}


{ config, pkgs, ... }:

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

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

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

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

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

Add tig, especially useful for headless

{ config, pkgs, ... }:

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

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

    # Development
    gitAndTools.tig

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

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

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


{ lib, stdenv, fetchFromGitHub }:

stdenv.mkDerivation rec {
  version = "0.6.8";
  pname = "nix-bash-completions";

  src = fetchFromGitHub {
    owner = "hedning";
    repo = "nix-bash-completions";
    rev = "v${version}";
    sha256 = "1n5zs6xcnv4bv1hdaypmz7fv4j7dsr4a0ifah99iyj4p5j85i1bc";
  };

  # To enable lazy loading via. bash-completion we need a symlink to the script
  # from every command name.
  installPhase = ''
    commands=$(
      function complete() { shift 2; echo "$@"; }
      shopt -s extglob
      source _nix
    )
    install -Dm444 -t $out/share/bash-completion/completions _nix
    cd $out/share/bash-completion/completions
    for c in $commands; do
      ln -s _nix $c
    done
  '';

  meta = with lib; {
    homepage = "https://github.com/hedning/nix-bash-completions";
    description = "Bash completions for Nix, NixOS, and NixOps";
    license = licenses.bsd3;
    platforms = platforms.all;
    maintainers = with maintainers; [ hedning ];
  };
}

Reduce priority for Nix 2.4

{ lib, stdenv, fetchFromGitHub }:

stdenv.mkDerivation rec {
  version = "0.6.8";
  pname = "nix-bash-completions";

  src = fetchFromGitHub {
    owner = "hedning";
    repo = "nix-bash-completions";
    rev = "v${version}";
    sha256 = "1n5zs6xcnv4bv1hdaypmz7fv4j7dsr4a0ifah99iyj4p5j85i1bc";
  };

  # To enable lazy loading via. bash-completion we need a symlink to the script
  # from every command name.
  installPhase = ''
    commands=$(
      function complete() { shift 2; echo "$@"; }
      shopt -s extglob
      source _nix
    )
    install -Dm444 -t $out/share/bash-completion/completions _nix
    cd $out/share/bash-completion/completions
    for c in $commands; do
      ln -s _nix $c
    done
  '';

  meta = with lib; {
    homepage = "https://github.com/hedning/nix-bash-completions";
    description = "Bash completions for Nix, NixOS, and NixOps";
    license = licenses.bsd3;
    platforms = platforms.all;
    maintainers = with maintainers; [ hedning ];
    # Set a lower priority such that the newly provided completion from Nix 2.4 are preferred.
    priority = 10;
  };
}


{ stdenv, fetchFromGitHub, cmake }:

stdenv.mkDerivation rec {
  pname = "range-v3";
  version = "0.10.0";

  src = fetchFromGitHub {
    owner = "ericniebler";
    repo = "range-v3";
    rev = version;
    sha256 = "1h9h5j7pdi0afpip9ncq76h1xjhvb8bnm585q17afz2l4fydy8qj";
  };

  nativeBuildInputs = [ cmake ];

  doCheck = true;
  checkTarget = "test";

  enableParallelBuilding = true;

  meta = with stdenv.lib; {
    description = "Experimental range library for C++11/14/17";
    homepage = https://github.com/ericniebler/range-v3;
    license = licenses.boost;
    platforms = platforms.all;
    maintainers = with maintainers; [ primeos xwvvvvwx ];
  };
}

Fix the AArch64 build by disabling the tests

{ stdenv, fetchFromGitHub, cmake }:

stdenv.mkDerivation rec {
  pname = "range-v3";
  version = "0.10.0";

  src = fetchFromGitHub {
    owner = "ericniebler";
    repo = "range-v3";
    rev = version;
    sha256 = "1h9h5j7pdi0afpip9ncq76h1xjhvb8bnm585q17afz2l4fydy8qj";
  };

  nativeBuildInputs = [ cmake ];

  # Building the tests currently fails on AArch64 due to internal compiler
  # errors (with GCC 9.2):
  cmakeFlags = stdenv.lib.optional stdenv.isAarch64 "-DRANGE_V3_TESTS=OFF";

  doCheck = !stdenv.isAarch64;
  checkTarget = "test";

  enableParallelBuilding = true;

  meta = with stdenv.lib; {
    description = "Experimental range library for C++11/14/17";
    homepage = https://github.com/ericniebler/range-v3;
    license = licenses.boost;
    platforms = platforms.all;
    maintainers = with maintainers; [ primeos xwvvvvwx ];
  };
}


{ fetchurl, stdenv, kernelDev, onlyHeaders ? false }:

stdenv.mkDerivation rec {
  pname = "cryptodev-linux-1.5";
  name = "${pname}-${kernelDev.version}";

  src = fetchurl {
    url = "http://download.gna.org/cryptodev-linux/${pname}.tar.gz";
    sha256 = "13hybl5p0ck0vgi2gxmiwa2810gcfk78kdy17ai8nczj8il15mn0";
  };

  buildPhase = if !onlyHeaders then ''
    make -C ${kernelDev}/lib/modules/${kernelDev.modDirVersion}/build \
      SUBDIRS=`pwd` INSTALL_PATH=$out
  '' else ":";

  installPhase = stdenv.lib.optionalString (!onlyHeaders) ''
    make -C ${kernelDev}/lib/modules/${kernelDev.modDirVersion}/build \
      INSTALL_MOD_PATH=$out SUBDIRS=`pwd` modules_install
  '' + ''
    mkdir -p $out/include/crypto
    cp crypto/cryptodev.h $out/include/crypto
  '';

  meta = {
    description = "Device that allows access to Linux kernel cryptographic drivers";
    homepage = http://home.gna.org/cryptodev-linux/;
    license = "GPLv2+";
  };
}

Upgrade cryptodev from 1.5 -> 1.6

{ fetchurl, stdenv, kernelDev, onlyHeaders ? false }:

stdenv.mkDerivation rec {
  pname = "cryptodev-linux-1.6";
  name = "${pname}-${kernelDev.version}";

  src = fetchurl {
    url = "http://download.gna.org/cryptodev-linux/${pname}.tar.gz";
    sha256 = "0bryzdb4xz3fp2q00a0mlqkj629md825lnlh4gjwmy51irf45wbm";
  };

  buildPhase = if !onlyHeaders then ''
    make -C ${kernelDev}/lib/modules/${kernelDev.modDirVersion}/build \
      SUBDIRS=`pwd` INSTALL_PATH=$out
  '' else ":";

  installPhase = stdenv.lib.optionalString (!onlyHeaders) ''
    make -C ${kernelDev}/lib/modules/${kernelDev.modDirVersion}/build \
      INSTALL_MOD_PATH=$out SUBDIRS=`pwd` modules_install
  '' + ''
    mkdir -p $out/include/crypto
    cp crypto/cryptodev.h $out/include/crypto
  '';

  meta = {
    description = "Device that allows access to Linux kernel cryptographic drivers";
    homepage = http://home.gna.org/cryptodev-linux/;
    license = "GPLv2+";
  };
}


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

assert stdenv.isLinux;

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

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

  buildInputs = [ perl makeWrapper ];

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

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

  meta = {
    description = "Berkeley Lab Checkpoint/Restart for Linux (BLCR)";
    homepage = https://ftg.lbl.gov/projects/CheckpointRestart/;
    license = "GPL2";
  };
}

Update BLCR to version 0.8.4.

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

assert stdenv.isLinux;

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

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

  buildInputs = [ perl makeWrapper ];

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

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

  meta = {
    description = "Berkeley Lab Checkpoint/Restart for Linux (BLCR)";
    homepage = https://ftg.lbl.gov/projects/CheckpointRestart/;
    license = "GPL2";
  };
}


{ stdenv, fetchurl, utillinux }:

stdenv.mkDerivation rec {
  name = "fuse-2.9.2";

  builder = ./builder.sh;

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

  configureFlags = "--disable-kernel-module";

  buildInputs = [ utillinux ];

  inherit utillinux;

  meta = {
    homepage = http://fuse.sourceforge.net/;
    description = "Kernel module and library that allows filesystems to be implemented in user space";
  };
}

Upgrade fuse from 2.9.2 -> 2.9.3

{ stdenv, fetchurl, utillinux }:

stdenv.mkDerivation rec {
  name = "fuse-2.9.3";

  builder = ./builder.sh;

  src = fetchurl {
    url = "mirror://sourceforge/fuse/${name}.tar.gz";
    sha256 = "071r6xjgssy8vwdn6m28qq1bqxsd2bphcd2mzhq0grf5ybm87sqb";
  };

  configureFlags = "--disable-kernel-module";

  buildInputs = [ utillinux ];

  inherit utillinux;

  meta = {
    homepage = http://fuse.sourceforge.net/;
    description = "Kernel module and library that allows filesystems to be implemented in user space";
  };
}


# The releases of this project are apparently precompiled to .jar files.

{ stdenv, fetchurl, jre, runtimeShell }:

let

  version = "0.9";
  sha256 = "45dd668a9ceb9cd59529a9fefe422a002ee1554a61be07e6fc8b3baf33d733d9";

in stdenv.mkDerivation {
  name = "briss-${version}";
  src = fetchurl {
    url = "mirror://sourceforge/briss/briss-${version}.tar.gz";
    inherit sha256;
  };

  installPhase = ''
    mkdir -p "$out/bin";
    mkdir -p "$out/share";
    install -D -m444 -t "$out/share" *.jar
    echo "#!${runtimeShell}" > "$out/bin/briss"
    echo "${jre}/bin/java -Xms128m -Xmx1024m -cp \"$out/share/\" -jar \"$out/share/briss-${version}.jar\"" >> "$out/bin/briss"
    chmod +x "$out/bin/briss"
  '';

  meta = {
    homepage = https://sourceforge.net/projects/briss/;
    description = "Java application for cropping PDF files";
    license = stdenv.lib.licenses.gpl3;
    platforms = stdenv.lib.platforms.unix;
  };
}

Use makeWrapper so it can take command-line args

# The releases of this project are apparently precompiled to .jar files.

{ stdenv, fetchurl, jre, makeWrapper }:

let

  version = "0.9";
  sha256 = "45dd668a9ceb9cd59529a9fefe422a002ee1554a61be07e6fc8b3baf33d733d9";

in stdenv.mkDerivation {
  name = "briss-${version}";
  src = fetchurl {
    url = "mirror://sourceforge/briss/briss-${version}.tar.gz";
    inherit sha256;
  };

  nativeBuildInputs = [makeWrapper];

  installPhase = ''
    mkdir -p "$out/bin";
    mkdir -p "$out/share";
    install -D -m444 -t "$out/share" *.jar
    makeWrapper "${jre}/bin/java" "$out/bin/briss" --add-flags "-Xms128m -Xmx1024m -cp \"$out/share/\" -jar \"$out/share/briss-${version}.jar\""
  '';

  meta = {
    homepage = https://sourceforge.net/projects/briss/;
    description = "Java application for cropping PDF files";
    license = stdenv.lib.licenses.gpl3;
    platforms = stdenv.lib.platforms.unix;
  };
}


{ stdenv, fetchurl, pkgconfig, systemd ? null, libobjc, IOKit }:

stdenv.mkDerivation rec {
  name = "libusb-1.0.22";

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

  outputs = [ "out" "dev" ]; # get rid of propagating systemd closure

  nativeBuildInputs = [ pkgconfig ];
  propagatedBuildInputs =
    stdenv.lib.optional stdenv.isLinux systemd ++
    stdenv.lib.optionals stdenv.isDarwin [ libobjc IOKit ];

  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isLinux "-lgcc_s";

  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
    sed 's,-ludev,-L${systemd.lib}/lib -ludev,' -i $out/lib/libusb-1.0.la
  '';

  meta = {
    homepage = http://www.libusb.info;
    description = "User-space USB library";
    platforms = stdenv.lib.platforms.unix;
    maintainers = [ ];
  };
}

Build everywhere, since MinGW works

{ stdenv, fetchurl, pkgconfig, systemd ? null, libobjc, IOKit }:

stdenv.mkDerivation rec {
  name = "libusb-1.0.22";

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

  outputs = [ "out" "dev" ]; # get rid of propagating systemd closure

  nativeBuildInputs = [ pkgconfig ];
  propagatedBuildInputs =
    stdenv.lib.optional stdenv.isLinux systemd ++
    stdenv.lib.optionals stdenv.isDarwin [ libobjc IOKit ];

  NIX_LDFLAGS = stdenv.lib.optionalString stdenv.isLinux "-lgcc_s";

  preFixup = stdenv.lib.optionalString stdenv.isLinux ''
    sed 's,-ludev,-L${systemd.lib}/lib -ludev,' -i $out/lib/libusb-1.0.la
  '';

  meta = {
    homepage = http://www.libusb.info;
    description = "User-space USB library";
    platforms = stdenv.lib.platforms.all;
    maintainers = [ ];
  };
}


fetchTarball {
  url = "https://github.com/NixOS/nixpkgs/archive/c1427bf45ffd9f738cb811f980a7a4accf342783.tar.gz";
  sha256 = "16xmd9zlbiyqd90y5a2jqwvkmbn95wcxqk0qnxlf2lkryg8cvc89";
}

Upgrade to latest commit in nixos-18.09 channel

fetchTarball {
  url = "https://github.com/NixOS/nixpkgs/archive/a7e559a5504572008567383c3dc8e142fa7a8633.tar.gz";
  sha256 = "16j95q58kkc69lfgpjkj76gw5sx8rcxwi3civm0mlfaxxyw9gzp6";
}


{ stdenv, fetchurl, libtool, gettext }:

assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";

stdenv.mkDerivation {
  name = "cpufrequtils-008";

  src = fetchurl {
    url = http://ftp.be.debian.org/pub/linux/utils/kernel/cpufreq/cpufrequtils-008.tar.gz;
    md5 = "52d3e09e47ffef634833f7fab168eccf";
  };

  patchPhase = ''
    sed -e "s@= /usr/bin/@= @g" \
      -e "s@/usr/@$out/@" \
      -i Makefile
  '';

  buildInputs = [ stdenv.gcc.libc.kernelHeaders libtool gettext ];

  meta = {
    description = "Tools to display or change the CPU governor settings";
    platforms = stdenv.lib.platforms.linux;
  };
}

Update cpufrequtils hash to sha256

{ stdenv, fetchurl, libtool, gettext }:

assert stdenv.system == "i686-linux" || stdenv.system == "x86_64-linux";

stdenv.mkDerivation {
  name = "cpufrequtils-008";

  src = fetchurl {
    url = "http://ftp.be.debian.org/pub/linux/utils/kernel/cpufreq/${name}.tar.gz";
    sha256 = "127i38d4w1hv2dzdy756gmbhq25q3k34nqb2s0xlhsfhhdqs0lq0";
  };

  patchPhase = ''
    sed -e "s@= /usr/bin/@= @g" \
      -e "s@/usr/@$out/@" \
      -i Makefile
  '';

  buildInputs = [ stdenv.gcc.libc.kernelHeaders libtool gettext ];

  meta = {
    description = "Tools to display or change the CPU governor settings";
    platforms = stdenv.lib.platforms.linux;
  };
}


{ config, pkgs, ... }:

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

    # Editor
    neopkgs.neovim

    # Source control
    pkgs.git

    # Web
    pkgs.wget
    pkgs.curl
    pkgs.lynx

    # SSH
    pkgs.mosh

    # Email
    pkgs.isync

    # Interpreters
    pkgs.python
  ];
}

Use neovim as my default editor everywhere

{ config, pkgs, ... }:

let
  neopkgs = import (
    pkgs.fetchFromGitHub {
      owner = "NixOS";
      repo = "nixpkgs";
      rev = "8f793ce6bb050252e92a987cc3c5bd48d5423a42";
      sha256 = "0fydxirp79s4svr2gadp3hsx2vrank904n8c5kprqh3jrzid90cg";
    }
  ) {};
in
{
  environment.variables = {
    EDITOR = "nvim";
  };

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

    # Editor
    neopkgs.neovim

    # Source control
    pkgs.git

    # Web
    pkgs.wget
    pkgs.curl
    pkgs.lynx

    # SSH
    pkgs.mosh

    # Email
    pkgs.isync

    # Interpreters
    pkgs.python
  ];
}


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

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

rec {
  inherit nixpkgs pkgs;

  configComponents = [
    configuration
    ./check-config.nix
  ] ++ (import ../modules/module-list.nix);

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

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

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

Use "definitionsOf" & "fixableDeclarationsOf": Hide implementation details.

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

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

rec {
  inherit nixpkgs pkgs;

  configComponents = [
    configuration
    ./check-config.nix
  ] ++ (import ../modules/module-list.nix);

  config_ =
    pkgs.lib.definitionsOf configComponents {
      inherit pkgs;
    };

  # "fixableDeclarationsOf" is used instead of "declarationsOf" because some
  # option default values may depends on the definition of other options.
  optionDeclarations =
    pkgs.lib.fixableDeclarationsOf configComponents {
      inherit pkgs;
    } config_;

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


{ pkgs, config, ... }:

{
  programs.ssh = {
    enable = true;
    matchBlocks = {
      "nike" = {
        hostname = "nike.cs.uga.edu";
        user = "gma";
        forwardX11 = true; };
    };
  };
}

Use trusted X11 forwarding to Nike

{ pkgs, config, ... }:

{
  programs.ssh = {
    enable = true;
    matchBlocks = {
      "nike" = {
        hostname = "nike.cs.uga.edu";
        user = "gma";
        forwardX11 = true;
        forwardX11Trusted = true;
      };
    };
  };
}


# RFC 7159, section 13.
builtins.fromJSON
  ''
    {
      "Image": {
          "Width":  800,
          "Height": 600,
          "Title":  "View from 15th Floor",
          "Thumbnail": {
              "Url":    "http://www.example.com/image/481989943",
              "Height": 125,
              "Width":  100
          },
          "Animated" : false,
          "IDs": [116, 943, 234, 38793, true  ,false,null, -100],
          "Latitude":  37.7668,
          "Longitude": -122.3959
        }
    }
  ''
==
  { Image =
    { Width = 800;
      Height = 600;
      Title = "View from 15th Floor";
      Thumbnail =
        { Url = http://www.example.com/image/481989943;
          Height = 125;
          Width = 100;
        };
      Animated = false;
      IDs = [ 116 943 234 38793 true false null (0-100) ];
      Latitude = 37.7668;
      Longitude = -122.3959;
    };
  }

Change json example to be original

builtins.fromJSON
  ''
    {
      "Video": {
          "Title":  "The Penguin Chronicles",
          "Width":  1920,
          "Height": 1080,
          "EmbeddedData": [3.14159, 23493,null, true  ,false, -10],
          "Thumb": {
              "Url":    "http://www.example.com/video/5678931",
              "Width":  200,
              "Height": 250
          },
          "Subtitle" : false,
          "Latitude":  46.2051,
          "Longitude": 6.0723
        }
    }
  ''
==
  { Video =
    { Title = "The Penguin Chronicles";
      Width = 1920;
      Height = 1080;
      EmbeddedData = [ 3.14159 23493 null true false (0-10) ];
      Thumb =
        { Url = "http://www.example.com/video/5678931";
          Width = 200;
          Height = 250;
        };
      Subtitle = false;
      Latitude = 46.2051;
      Longitude = 6.0723;
    };
  }


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

with lib;

let

  cfg = config.system;

in

{
  options = {
  };

  config = {

    system.build.applications = pkgs.buildEnv {
      name = "system-applications";
      paths = config.environment.systemPackages;
      pathsToLink = "/Applications";
    };

    system.activationScripts.applications.text = ''
      # Set up applications.
      echo "setting up ~/Applications..." >&2

      if [ ! -e ~/Applications -o -L ~/Applications ]; then
        ln -sfn ${cfg.build.applications}/Applications ~/Applications
      elif [ ! -e ~/Applications/Nix\ Apps -o -L ~/Applications/Nix\ Apps ]; then
        ln -sfn ${cfg.build.applications}/Applications ~/Applications/Nix\ Apps
      else
        echo "warning: ~/Applications and ~/Applications/Nix Apps are directories, skipping App linking..." >&2
      fi
    '';

  };
}

Disable taking control of ~/Applications folder

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

with lib;

let

  cfg = config.system;

in

{
  options = {
  };

  config = {

    system.build.applications = pkgs.buildEnv {
      name = "system-applications";
      paths = config.environment.systemPackages;
      pathsToLink = "/Applications";
    };

    system.activationScripts.applications.text = ''
      # Set up applications.
      echo "setting up ~/Applications..." >&2

      mkdir -p ~/Applications

      if [ ! -e ~/Applications/Nix\ Apps -o -L ~/Applications/Nix\ Apps ]; then
        ln -sfn ${cfg.build.applications}/Applications ~/Applications/Nix\ Apps
      else
        echo "warning: ~/Applications/Nix Apps is not owned by nix-darwin, skipping App linking..." >&2
      fi
    '';

  };
}


{stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "collectd-5.4.0";

  src = fetchurl {
    url = "http://collectd.org/files/${name}.tar.bz2";
    sha256 = "0gljf5c60q6i0nrii6addxy1p76qqixww8zy17a7a1zil6a3i5wh";
  };

  meta = {
    homepage = http://collectd.org;
    description = "collectd is a daemon which collects system performance statistics periodically";
    platforms = stdenv.lib.platforms.linux;
    license = "GPLv2";
  };
}

Fix collectd, couldn't run due to missing pthread_cancel.

{stdenv, fetchurl }:

stdenv.mkDerivation rec {
  name = "collectd-5.4.0";

  src = fetchurl {
    url = "http://collectd.org/files/${name}.tar.bz2";
    sha256 = "0gljf5c60q6i0nrii6addxy1p76qqixww8zy17a7a1zil6a3i5wh";
  };

  NIX_LDFLAGS = "-lgcc_s"; # for pthread_cancel

  meta = {
    homepage = http://collectd.org;
    description = "collectd is a daemon which collects system performance statistics periodically";
    platforms = stdenv.lib.platforms.linux;
    license = "GPLv2";
  };
}


{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc7102" }:
nixpkgs.pkgs.haskell.packages.${compiler}.callPackage ./package.nix {}

Use the local version of the library in examples.

{ nixpkgs ? import <nixpkgs> {}, compiler ? "ghc7102" }:
nixpkgs.pkgs.haskell.packages.${compiler}.callPackage ./package.nix {
  liblastfm = import ../. { inherit nixpkgs compiler; };
}


{ config, pkgs, ... }:

with pkgs.lib;

{

  options = {

    system.nixosVersion = mkOption {
      type = types.uniq types.string;
      description = "NixOS version.";
    };

    system.nixosVersionSuffix = mkOption {
      type = types.uniq types.string;
      description = "NixOS version suffix.";
    };

    system.nixosCodeName = mkOption {
      type = types.uniq types.string;
      description = "NixOS release code name.";
    };

  };

  config = {

    system.nixosVersion =
      mkDefault (builtins.readFile "${pkgs.path}/.version" + config.system.nixosVersionSuffix);

    system.nixosVersionSuffix =
      let suffixFile = "${pkgs.path}/.version-suffix"; in
      mkDefault (if builtins.pathExists suffixFile then builtins.readFile suffixFile else "pre-git");

    # Note: code names must only increase in alphabetical order.
    system.nixosCodeName = "Aardvark";

    # Generate /etc/os-release.  See
    # http://0pointer.de/public/systemd-man/os-release.html for the
    # format.
    environment.etc = singleton
      { source = pkgs.writeText "os-release"
          ''
            NAME=NixOS
            ID=nixos
            VERSION="${config.system.nixosVersion} (${config.system.nixosCodeName})"
            VERSION_ID="${config.system.nixosVersion}"
            PRETTY_NAME="NixOS ${config.system.nixosVersion} (${config.system.nixosCodeName})"
            HOME_URL="http://nixos.org/"
          '';
        target = "os-release";
      };

  };

}

Fix compatibility with Nix < 1.6

{ config, pkgs, ... }:

with pkgs.lib;

{

  options = {

    system.nixosVersion = mkOption {
      type = types.uniq types.string;
      description = "NixOS version.";
    };

    system.nixosVersionSuffix = mkOption {
      type = types.uniq types.string;
      description = "NixOS version suffix.";
    };

    system.nixosCodeName = mkOption {
      type = types.uniq types.string;
      description = "NixOS release code name.";
    };

  };

  config = {

    system.nixosVersion =
      mkDefault (builtins.readFile "${toString pkgs.path}/.version" + config.system.nixosVersionSuffix);

    system.nixosVersionSuffix =
      let suffixFile = "${toString pkgs.path}/.version-suffix"; in
      mkDefault (if builtins.pathExists suffixFile then builtins.readFile suffixFile else "pre-git");

    # Note: code names must only increase in alphabetical order.
    system.nixosCodeName = "Aardvark";

    # Generate /etc/os-release.  See
    # http://0pointer.de/public/systemd-man/os-release.html for the
    # format.
    environment.etc = singleton
      { source = pkgs.writeText "os-release"
          ''
            NAME=NixOS
            ID=nixos
            VERSION="${config.system.nixosVersion} (${config.system.nixosCodeName})"
            VERSION_ID="${config.system.nixosVersion}"
            PRETTY_NAME="NixOS ${config.system.nixosVersion} (${config.system.nixosCodeName})"
            HOME_URL="http://nixos.org/"
          '';
        target = "os-release";
      };

  };

}