aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIgor Pashev <pashev.igor@gmail.com>2019-10-03 16:46:33 +0200
committerIgor Pashev <pashev.igor@gmail.com>2019-10-03 16:47:47 +0200
commit63bf277a01a4fd4df692bf319b6d6ef0dc2c0ec8 (patch)
treee711087211349321f1f4b0ddf38e36afae57e235
parent2cd4baddb208f759178846564d1789567b1417d0 (diff)
downloadnpm.nix-63bf277a01a4fd4df692bf319b6d6ef0dc2c0ec8.tar.gz
Make package set extensible and use this feature
-rw-r--r--npmPackages/bootstrap.nix67
-rw-r--r--npmPackages/default.nix83
-rw-r--r--npmPackages/index.nix15
3 files changed, 90 insertions, 75 deletions
diff --git a/npmPackages/bootstrap.nix b/npmPackages/bootstrap.nix
new file mode 100644
index 0000000..0e15374
--- /dev/null
+++ b/npmPackages/bootstrap.nix
@@ -0,0 +1,67 @@
+{ pkgs }:
+
+self: super:
+ let
+ _mkDummy = name: version: pkgs.runCommand "${name}-${version}-dummy" {} ''
+ mkdir -p $out
+ cat <<PKG > $out/package.json
+ {
+ "name": "${name}",
+ "version": "${version}-dummy",
+ "description": "A dummy package to ease bootstrapping",
+ "main": "index.js",
+ "license": "PUBLIC DOMAIN",
+ "files": ["index.js"]
+ }
+ PKG
+
+ cat <<SRC > $out/index.js
+ SRC
+ '';
+
+ inherit (import ./lib.nix) dontCheck;
+ inherit (super) callPackage;
+in rec {
+ # XXX dummy package are to help bootstrapping.
+ # XXX Usually these are devDependencies needed to run tests.
+
+ _dummy_chalk = _mkDummy "chalk" "2.4.2";
+ _dummy_covert = _mkDummy "covert" "1.1.1";
+ _dummy_mock-fs = _mkDummy "mock-fs" "4.10.1";
+ _dummy_tap = _mkDummy "tap" "14.6.5";
+ _dummy_tape = _mkDummy "tape" "4.11.0";
+ _dummy_xo = _mkDummy "xo" "0.25.3";
+
+
+ # XXX packages with underscore are "incomplete".
+ # XXX Should only be used to resolve circular dependencies.
+
+ _color-convert = dontCheck (callPackage ./color-convert {
+ chalk = _dummy_chalk;
+ xo = _dummy_xo;
+ });
+
+ _fs-realpath = dontCheck(callPackage ./fs.realpath {
+ tap = _dummy_tap;
+ });
+
+ _minimist = dontCheck (callPackage ./minimist {
+ covert = _dummy_covert;
+ tap = _dummy_tap;
+ tape = _dummy_tape;
+ });
+
+ _mkdirp = dontCheck (callPackage ./mkdirp {
+ minimist = _minimist;
+ mock-fs = _dummy_mock-fs;
+ tap = _dummy_tap;
+ });
+
+ _semver = dontCheck (callPackage ./semver {
+ tap = _dummy_tap;
+ });
+
+ _wrappy = dontCheck (callPackage ./wrappy {
+ tap = _dummy_tap;
+ });
+}
diff --git a/npmPackages/default.nix b/npmPackages/default.nix
index 581d747..0f32191 100644
--- a/npmPackages/default.nix
+++ b/npmPackages/default.nix
@@ -1,92 +1,25 @@
{ pkgs ? (import <nixpkgs> {})
, stdenv ? pkgs.stdenv
, nodejs ? pkgs.nodejs
-, overrides ? (self: super: {})
}:
let
inherit (stdenv) lib;
- _mkDummy = name: version: pkgs.runCommand "${name}-${version}-dummy" {} ''
- mkdir -p $out
- cat <<PKG > $out/package.json
- {
- "name": "${name}",
- "version": "${version}-dummy",
- "description": "A dummy package to ease bootstrapping",
- "main": "index.js",
- "license": "PUBLIC DOMAIN",
- "files": ["index.js"]
- }
- PKG
-
- cat <<SRC > $out/index.js
- SRC
- '';
-
- inherit (import ./lib.nix) dontCheck;
-
- packages = (self:
+ set0 = lib.makeExtensible (self:
let
callPackage = pkgs.newScope self;
-
- buildNpmPackageImpl = callPackage ./buildNpmPackage.nix { };
-
+ buildNpmPackageImpl = callPackage ./buildNpmPackage.nix {};
buildNpmPackage = lib.makeOverridable buildNpmPackageImpl;
- in rec {
- inherit
- buildNpmPackage nodejs
- ;
-
+ in {
+ inherit buildNpmPackage callPackage nodejs;
npmPackages = self;
-
- # XXX dummy package are to help bootstrapping.
- # XXX Usually these are devDependencies needed to run tests.
-
- _dummy_chalk = _mkDummy "chalk" "2.4.2";
- _dummy_covert = _mkDummy "covert" "1.1.1";
- _dummy_mock-fs = _mkDummy "mock-fs" "4.10.1";
- _dummy_tap = _mkDummy "tap" "14.6.5";
- _dummy_tape = _mkDummy "tape" "4.11.0";
- _dummy_xo = _mkDummy "xo" "0.25.3";
-
-
- # XXX packages with underscore are "incomplete".
- # XXX Should only be used to resolve circular dependencies.
-
- _color-convert = dontCheck (callPackage ./color-convert {
- chalk = _dummy_chalk;
- xo = _dummy_xo;
- });
-
- _minimist = dontCheck (callPackage ./minimist {
- covert = _dummy_covert;
- tap = _dummy_tap;
- tape = _dummy_tape;
- });
-
- _mkdirp = dontCheck (callPackage ./mkdirp {
- minimist = _minimist;
- mock-fs = _dummy_mock-fs;
- tap = _dummy_tap;
- });
-
- _semver = dontCheck (callPackage ./semver {
- tap = _dummy_tap;
- });
-
- _wrappy = dontCheck (callPackage ./wrappy {
- tap = _dummy_tap;
- });
-
- async-foreach = callPackage ./async-foreach {};
- chartjs-color-string = callPackage ./chartjs-color-string { };
- color-name = callPackage ./color-name {};
- npm4nix = callPackage ./npm4nix {};
- posix-getopt = callPackage ./posix-getopt {};
}
);
-in lib.fix' (lib.extends overrides packages)
+ set1 = set0.extend (import ./index.nix);
+ set = set1.extend (import ./bootstrap.nix { inherit pkgs; });
+
+in set
diff --git a/npmPackages/index.nix b/npmPackages/index.nix
new file mode 100644
index 0000000..27880b5
--- /dev/null
+++ b/npmPackages/index.nix
@@ -0,0 +1,15 @@
+self: super:
+let
+ inherit (super) callPackage;
+in {
+ async-foreach = callPackage ./async-foreach {};
+ chartjs-color-string = callPackage ./chartjs-color-string {};
+ color-convert = callPackage ./color-convert {};
+ color-name = callPackage ./color-name {};
+ minimist = callPackage ./minimist {};
+ mkdirp = callPackage ./mkdirp {};
+ npm4nix = callPackage ./npm4nix {};
+ posix-getopt = callPackage ./posix-getopt {};
+ semver = callPackage ./semver {};
+ wrappy = callPackage ./wrappy {};
+}