From a087122db97e3bc63d95a0cc3d2d9745ef9179a3 Mon Sep 17 00:00:00 2001 From: Sander van der Burg Date: Wed, 7 Sep 2016 20:13:01 +0000 Subject: [PATCH] Only include supplement expression when it has been requested --- default.nix | 6 +---- lib/generator/composition.js | 5 +++-- lib/node2nix.js | 2 +- node-packages.nix | 21 +++++++++++++----- tests/default-v4.nix | 6 +---- tests/default-v5.nix | 6 +---- tests/grunt/node-packages.nix | 26 +++++++++++----------- tests/grunt/supplement.nix | 18 +++++++-------- tests/node-packages-v4.nix | 41 +++++++++++++++++++++------------- tests/node-packages-v5.nix | 42 ++++++++++++++++++++++------------- 10 files changed, 95 insertions(+), 78 deletions(-) diff --git a/default.nix b/default.nix index 62aeb35..b69cd60 100644 --- a/default.nix +++ b/default.nix @@ -5,10 +5,6 @@ }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs"}: let - globalBuildInputs = pkgs.lib.attrValues (import ./supplement.nix { - inherit nodeEnv; - inherit (pkgs) fetchurl fetchgit; - }); nodeEnv = import ./nix/node-env.nix { inherit (pkgs) stdenv python utillinux runCommand writeTextFile; inherit nodejs; @@ -16,5 +12,5 @@ let in import ./node-packages.nix { inherit (pkgs) fetchurl fetchgit; - inherit nodeEnv globalBuildInputs; + inherit nodeEnv; } \ No newline at end of file diff --git a/lib/generator/composition.js b/lib/generator/composition.js index b6e617e..3a596f7 100644 --- a/lib/generator/composition.js +++ b/lib/generator/composition.js @@ -16,10 +16,11 @@ function mustPrefix(target) { * @param {String} nodePackage Name of the Node.js package to use from Nixpkgs * @param {String} packagesExpr Path to the package expression that defines how packages are built from source and their dependencies * @param {String} supplementNix Path to which the generated supplement expression is written + * @param {Boolean} generateSupplement Indicates whether to include supplemental packages * @return {NixFunction} Nix function that composes the NPM packages */ -function generateCompositionExpr(nodeEnvNix, nodePackage, packagesNix, supplementNix) { +function generateCompositionExpr(nodeEnvNix, nodePackage, packagesNix, supplementNix, generateSupplement) { /* Prefix relative paths if needed */ var nodeEnvNixPath; var packagesNixPath; @@ -37,7 +38,7 @@ function generateCompositionExpr(nodeEnvNix, nodePackage, packagesNix, supplemen packagesNixPath = packagesNix; } - if(supplementNix) { + if(generateSupplement) { var supplementNixPath; if(mustPrefix(supplementNix)) { diff --git a/lib/node2nix.js b/lib/node2nix.js index 075f451..7e65cd3 100644 --- a/lib/node2nix.js +++ b/lib/node2nix.js @@ -122,7 +122,7 @@ function npmToNix(inputJSON, outputNix, compositionNix, nodeEnvNix, supplementJS /* Generate and write a Nix composition expression to the specified output file */ function(callback) { - var compositionExpr = compositionGenerator.generateCompositionExpr(nodeEnvNix, nodePackage, outputNix, supplementNix); + var compositionExpr = compositionGenerator.generateCompositionExpr(nodeEnvNix, nodePackage, outputNix, supplementNix, (supplementJSON !== undefined)); fs.writeFile(compositionNix, disclaimer + nijs.jsToNix(compositionExpr, true), callback); } ], callback); diff --git a/node-packages.nix b/node-packages.nix index 8bbb0ff..ab84715 100644 --- a/node-packages.nix +++ b/node-packages.nix @@ -148,13 +148,13 @@ let sha1 = "809bc61cabf54bd5ff94f6165c89ba8ee88c115c"; }; }; - "once-1.3.3" = { + "once-1.4.0" = { name = "once"; packageName = "once"; - version = "1.3.3"; + version = "1.4.0"; src = fetchurl { - url = "https://registry.npmjs.org/once/-/once-1.3.3.tgz"; - sha1 = "b2e261557ce4c314ec8304f3fa82663e4297ca20"; + url = "https://registry.npmjs.org/once/-/once-1.4.0.tgz"; + sha1 = "583b1aa775961d4b113ac17d9c50baef9dd76bd1"; }; }; "request-2.74.0" = { @@ -1174,6 +1174,15 @@ let sha1 = "c6465dbf08abcd4db359317f79ac68a646b28ff9"; }; }; + "once-1.3.3" = { + name = "once"; + packageName = "once"; + version = "1.3.3"; + src = fetchurl { + url = "https://registry.npmjs.org/once/-/once-1.3.3.tgz"; + sha1 = "b2e261557ce4c314ec8304f3fa82663e4297ca20"; + }; + }; "osenv-0.1.3" = { name = "osenv"; packageName = "osenv"; @@ -1386,7 +1395,7 @@ let sources."semver-5.3.0" ]; }) - (sources."once-1.3.3" // { + (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" ]; @@ -1668,7 +1677,7 @@ let }) ]; }) - (sources."once-1.3.3" // { + (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" ]; diff --git a/tests/default-v4.nix b/tests/default-v4.nix index 022275e..9140dec 100644 --- a/tests/default-v4.nix +++ b/tests/default-v4.nix @@ -5,10 +5,6 @@ }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs"}: let - globalBuildInputs = pkgs.lib.attrValues (import ./supplement.nix { - inherit nodeEnv; - inherit (pkgs) fetchurl fetchgit; - }); nodeEnv = import ../nix/node-env.nix { inherit (pkgs) stdenv python utillinux runCommand writeTextFile; inherit nodejs; @@ -16,5 +12,5 @@ let in import ./node-packages-v4.nix { inherit (pkgs) fetchurl fetchgit; - inherit nodeEnv globalBuildInputs; + inherit nodeEnv; } \ No newline at end of file diff --git a/tests/default-v5.nix b/tests/default-v5.nix index eff36d2..2c2e3ef 100644 --- a/tests/default-v5.nix +++ b/tests/default-v5.nix @@ -5,10 +5,6 @@ }, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-5_x"}: let - globalBuildInputs = pkgs.lib.attrValues (import ./supplement.nix { - inherit nodeEnv; - inherit (pkgs) fetchurl fetchgit; - }); nodeEnv = import ../nix/node-env.nix { inherit (pkgs) stdenv python utillinux runCommand writeTextFile; inherit nodejs; @@ -16,5 +12,5 @@ let in import ./node-packages-v5.nix { inherit (pkgs) fetchurl fetchgit; - inherit nodeEnv globalBuildInputs; + inherit nodeEnv; } \ No newline at end of file diff --git a/tests/grunt/node-packages.nix b/tests/grunt/node-packages.nix index a33576c..d2e6349 100644 --- a/tests/grunt/node-packages.nix +++ b/tests/grunt/node-packages.nix @@ -589,13 +589,13 @@ let sha1 = "b17d08d326b4423e568eff719f91b0b1cbdf69f1"; }; }; - "once-1.3.3" = { + "once-1.4.0" = { name = "once"; packageName = "once"; - version = "1.3.3"; + version = "1.4.0"; src = fetchurl { - url = "https://registry.npmjs.org/once/-/once-1.3.3.tgz"; - sha1 = "b2e261557ce4c314ec8304f3fa82663e4297ca20"; + url = "https://registry.npmjs.org/once/-/once-1.4.0.tgz"; + sha1 = "583b1aa775961d4b113ac17d9c50baef9dd76bd1"; }; }; "wrappy-1.0.2" = { @@ -760,13 +760,13 @@ let sha1 = "047a449789fa160d018f5486ed91320b6ec7885c"; }; }; - "which-1.2.10" = { + "which-1.2.11" = { name = "which"; packageName = "which"; - version = "1.2.10"; + version = "1.2.11"; src = fetchurl { - url = "https://registry.npmjs.org/which/-/which-1.2.10.tgz"; - sha1 = "91cd9bd0751322411b659b40f054b21de957ab2d"; + url = "https://registry.npmjs.org/which/-/which-1.2.11.tgz"; + sha1 = "c8b2eeea6b8c1659fa7c1dd4fdaabe9533dc5e8b"; }; }; "isexe-1.1.2" = { @@ -1408,7 +1408,7 @@ let ]; }) sources."inherits-2.0.1" - (sources."once-1.3.3" // { + (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" ]; @@ -1426,7 +1426,7 @@ let ]; }) sources."inherits-2.0.1" - (sources."once-1.3.3" // { + (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" ]; @@ -1476,7 +1476,7 @@ let sources."hooker-0.2.3" sources."lodash-4.3.0" sources."underscore.string-3.2.3" - (sources."which-1.2.10" // { + (sources."which-1.2.11" // { dependencies = [ sources."isexe-1.1.2" ]; @@ -1546,7 +1546,7 @@ let ]; }) sources."inherits-2.0.1" - (sources."once-1.3.3" // { + (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" ]; @@ -1620,7 +1620,7 @@ let ]; }) sources."inherits-2.0.1" - (sources."once-1.3.3" // { + (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" ]; diff --git a/tests/grunt/supplement.nix b/tests/grunt/supplement.nix index 286517c..5d8decf 100644 --- a/tests/grunt/supplement.nix +++ b/tests/grunt/supplement.nix @@ -589,13 +589,13 @@ let sha1 = "b17d08d326b4423e568eff719f91b0b1cbdf69f1"; }; }; - "once-1.3.3" = { + "once-1.4.0" = { name = "once"; packageName = "once"; - version = "1.3.3"; + version = "1.4.0"; src = fetchurl { - url = "https://registry.npmjs.org/once/-/once-1.3.3.tgz"; - sha1 = "b2e261557ce4c314ec8304f3fa82663e4297ca20"; + url = "https://registry.npmjs.org/once/-/once-1.4.0.tgz"; + sha1 = "583b1aa775961d4b113ac17d9c50baef9dd76bd1"; }; }; "wrappy-1.0.2" = { @@ -760,13 +760,13 @@ let sha1 = "047a449789fa160d018f5486ed91320b6ec7885c"; }; }; - "which-1.2.10" = { + "which-1.2.11" = { name = "which"; packageName = "which"; - version = "1.2.10"; + version = "1.2.11"; src = fetchurl { - url = "https://registry.npmjs.org/which/-/which-1.2.10.tgz"; - sha1 = "91cd9bd0751322411b659b40f054b21de957ab2d"; + url = "https://registry.npmjs.org/which/-/which-1.2.11.tgz"; + sha1 = "c8b2eeea6b8c1659fa7c1dd4fdaabe9533dc5e8b"; }; }; "isexe-1.1.2" = { @@ -1296,7 +1296,7 @@ in }) ]; }) - (sources."once-1.3.3" // { + (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" ]; diff --git a/tests/node-packages-v4.nix b/tests/node-packages-v4.nix index f4d056f..cbbd320 100644 --- a/tests/node-packages-v4.nix +++ b/tests/node-packages-v4.nix @@ -685,13 +685,13 @@ let sha1 = "2a4e4090b96b2db06a9d7df01055a62a77c9b774"; }; }; - "once-1.3.3" = { + "once-1.4.0" = { name = "once"; packageName = "once"; - version = "1.3.3"; + version = "1.4.0"; src = fetchurl { - url = "https://registry.npmjs.org/once/-/once-1.3.3.tgz"; - sha1 = "b2e261557ce4c314ec8304f3fa82663e4297ca20"; + url = "https://registry.npmjs.org/once/-/once-1.4.0.tgz"; + sha1 = "583b1aa775961d4b113ac17d9c50baef9dd76bd1"; }; }; "path-is-absolute-1.0.0" = { @@ -1756,6 +1756,15 @@ let sha1 = "9c31dae34767018fe1d249b24dada67d092da105"; }; }; + "once-1.3.3" = { + name = "once"; + packageName = "once"; + version = "1.3.3"; + src = fetchurl { + url = "https://registry.npmjs.org/once/-/once-1.3.3.tgz"; + sha1 = "b2e261557ce4c314ec8304f3fa82663e4297ca20"; + }; + }; "uid-number-0.0.6" = { name = "uid-number"; packageName = "uid-number"; @@ -1819,13 +1828,13 @@ let sha1 = "1343955edaf2e37d9b9e7ee7241e27c4b9fb72be"; }; }; - "which-1.2.10" = { + "which-1.2.11" = { name = "which"; packageName = "which"; - version = "1.2.10"; + version = "1.2.11"; src = fetchurl { - url = "https://registry.npmjs.org/which/-/which-1.2.10.tgz"; - sha1 = "91cd9bd0751322411b659b40f054b21de957ab2d"; + url = "https://registry.npmjs.org/which/-/which-1.2.11.tgz"; + sha1 = "c8b2eeea6b8c1659fa7c1dd4fdaabe9533dc5e8b"; }; }; "pseudomap-1.0.2" = { @@ -2271,8 +2280,8 @@ in version = "4.16.0-pre"; src = fetchgit { url = "git://github.com/lodash/lodash"; - rev = "d1abde7d1af1bb4cb2423286a54313220c0d8f31"; - sha256 = "0770f5a9aaf8fb13a3f6d2096bfa737d75f7ea735b39b70118b0e0767113d520"; + rev = "8176d56c725489156e19d68aeaf8851d313f4446"; + sha256 = "92205818347cc8d1880152f87d25ddc28308d2b584a1ba2c135b9fa2664b6018"; }; buildInputs = globalBuildInputs; meta = { @@ -2352,7 +2361,7 @@ in }) ]; }) - (sources."once-1.3.3" // { + (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" ]; @@ -2413,10 +2422,10 @@ in floomatic = nodeEnv.buildNodePackage { name = "floomatic"; packageName = "floomatic"; - version = "0.5.3"; + version = "0.5.4"; src = fetchurl { - url = "https://registry.npmjs.org/floomatic/-/floomatic-0.5.3.tgz"; - sha1 = "d7a5aa8709300758d51f4de4be1f4e6fa1389050"; + url = "https://registry.npmjs.org/floomatic/-/floomatic-0.5.4.tgz"; + sha1 = "03706cfb435b4a4912cbea325438f509606e6750"; }; dependencies = [ sources."async-1.5.2" @@ -2656,7 +2665,7 @@ in ]; }) sources."inherits-2.0.1" - (sources."once-1.3.3" // { + (sources."once-1.4.0" // { dependencies = [ sources."wrappy-1.0.2" ]; @@ -2748,7 +2757,7 @@ in sources."yallist-2.0.0" ]; }) - (sources."which-1.2.10" // { + (sources."which-1.2.11" // { dependencies = [ sources."isexe-1.1.2" ]; diff --git a/tests/node-packages-v5.nix b/tests/node-packages-v5.nix index ae80c8a..ee2b39d 100644 --- a/tests/node-packages-v5.nix +++ b/tests/node-packages-v5.nix @@ -685,13 +685,13 @@ let sha1 = "2a4e4090b96b2db06a9d7df01055a62a77c9b774"; }; }; - "once-1.3.3" = { + "once-1.4.0" = { name = "once"; packageName = "once"; - version = "1.3.3"; + version = "1.4.0"; src = fetchurl { - url = "https://registry.npmjs.org/once/-/once-1.3.3.tgz"; - sha1 = "b2e261557ce4c314ec8304f3fa82663e4297ca20"; + url = "https://registry.npmjs.org/once/-/once-1.4.0.tgz"; + sha1 = "583b1aa775961d4b113ac17d9c50baef9dd76bd1"; }; }; "path-is-absolute-1.0.0" = { @@ -1729,6 +1729,15 @@ let sha1 = "9c31dae34767018fe1d249b24dada67d092da105"; }; }; + "once-1.3.3" = { + name = "once"; + packageName = "once"; + version = "1.3.3"; + src = fetchurl { + url = "https://registry.npmjs.org/once/-/once-1.3.3.tgz"; + sha1 = "b2e261557ce4c314ec8304f3fa82663e4297ca20"; + }; + }; "readable-stream-2.1.5" = { name = "readable-stream"; packageName = "readable-stream"; @@ -1810,13 +1819,13 @@ let sha1 = "1343955edaf2e37d9b9e7ee7241e27c4b9fb72be"; }; }; - "which-1.2.10" = { + "which-1.2.11" = { name = "which"; packageName = "which"; - version = "1.2.10"; + version = "1.2.11"; src = fetchurl { - url = "https://registry.npmjs.org/which/-/which-1.2.10.tgz"; - sha1 = "91cd9bd0751322411b659b40f054b21de957ab2d"; + url = "https://registry.npmjs.org/which/-/which-1.2.11.tgz"; + sha1 = "c8b2eeea6b8c1659fa7c1dd4fdaabe9533dc5e8b"; }; }; "pseudomap-1.0.2" = { @@ -2150,8 +2159,8 @@ in version = "4.16.0-pre"; src = fetchgit { url = "git://github.com/lodash/lodash"; - rev = "d1abde7d1af1bb4cb2423286a54313220c0d8f31"; - sha256 = "0770f5a9aaf8fb13a3f6d2096bfa737d75f7ea735b39b70118b0e0767113d520"; + rev = "8176d56c725489156e19d68aeaf8851d313f4446"; + sha256 = "92205818347cc8d1880152f87d25ddc28308d2b584a1ba2c135b9fa2664b6018"; }; buildInputs = globalBuildInputs; meta = { @@ -2211,7 +2220,7 @@ in sources."inflight-1.0.5" sources."inherits-2.0.1" sources."minimatch-3.0.3" - sources."once-1.3.3" + sources."once-1.4.0" sources."path-is-absolute-1.0.0" sources."wrappy-1.0.2" sources."brace-expansion-1.1.6" @@ -2262,10 +2271,10 @@ in floomatic = nodeEnv.buildNodePackage { name = "floomatic"; packageName = "floomatic"; - version = "0.5.3"; + version = "0.5.4"; src = fetchurl { - url = "https://registry.npmjs.org/floomatic/-/floomatic-0.5.3.tgz"; - sha1 = "d7a5aa8709300758d51f4de4be1f4e6fa1389050"; + url = "https://registry.npmjs.org/floomatic/-/floomatic-0.5.4.tgz"; + sha1 = "03706cfb435b4a4912cbea325438f509606e6750"; }; dependencies = [ sources."async-1.5.2" @@ -2384,6 +2393,7 @@ in sources."tar-2.2.1" (sources."tar-pack-3.1.4" // { dependencies = [ + sources."once-1.3.3" sources."readable-stream-2.1.5" ]; }) @@ -2409,7 +2419,7 @@ in sources."glob-7.0.6" sources."fs.realpath-1.0.0" sources."inflight-1.0.5" - sources."once-1.3.3" + sources."once-1.4.0" sources."path-is-absolute-1.0.0" sources."wrappy-1.0.2" sources."block-stream-0.0.9" @@ -2445,7 +2455,7 @@ in sources."path-key-1.0.0" sources."strip-eof-1.0.0" sources."lru-cache-4.0.1" - sources."which-1.2.10" + sources."which-1.2.11" sources."pseudomap-1.0.2" sources."yallist-2.0.0" sources."isexe-1.1.2"