{ discere ? { outPath = ./..; name = "discere"; }
, pkgs ? import <nixpkgs> {}
}:
let
  nodePackages = import "${pkgs.path}/pkgs/top-level/node-packages.nix" {
    inherit pkgs;
    inherit (pkgs) stdenv nodejs fetchurl fetchgit;
    neededNatives = [ pkgs.python ] ++ pkgs.lib.optional pkgs.stdenv.isLinux pkgs.utillinux;
    self = nodePackages;
    generated = ./discere.generated.nix;
  };
in rec {
  # WARNING:
  # This won't work unless you've pulled in the database generated by
  # the latin-db-builder package.
  tarball = pkgs.runCommand "discere-0.0.2.tgz" { buildInputs = [ pkgs.nodejs ]; } ''
    mv `HOME=$PWD npm pack ${discere}` $out
  '';
  build = nodePackages.buildNodePackage {
    name = "discere-0.0.2";
    src = [ tarball ];
    buildInputs = nodePackages.nativeDeps."discere" or [];
    deps = [ nodePackages.by-spec."async"."^0.9.0" nodePackages.by-spec."cookie-parser"."^1.3.3" nodePackages.by-spec."debug"."^2.1.1" nodePackages.by-spec."errorhandler"."^1.3.2" nodePackages.by-spec."express"."^4.10.7" nodePackages.by-spec."jade"."^1.5.0" nodePackages.by-spec."morgan"."^1.5.1" nodePackages.by-spec."serve-favicon"."^2.2.0" nodePackages.by-spec."sqlite3"."^3.0.4" nodePackages.by-spec."underscore"."^1.7.0" ];
    peerDependencies = [];
    passthru.names = [ "discere" ];
  };
}
