Skip to content

Commit

Permalink
Only include supplement expression when it has been requested
Browse files Browse the repository at this point in the history
  • Loading branch information
svanderburg committed Sep 7, 2016
1 parent 5b5727b commit a087122
Show file tree
Hide file tree
Showing 10 changed files with 95 additions and 78 deletions.
6 changes: 1 addition & 5 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
}, 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;
};
in
import ./node-packages.nix {
inherit (pkgs) fetchurl fetchgit;
inherit nodeEnv globalBuildInputs;
inherit nodeEnv;
}
5 changes: 3 additions & 2 deletions lib/generator/composition.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -37,7 +38,7 @@ function generateCompositionExpr(nodeEnvNix, nodePackage, packagesNix, supplemen
packagesNixPath = packagesNix;
}

if(supplementNix) {
if(generateSupplement) {
var supplementNixPath;

if(mustPrefix(supplementNix)) {
Expand Down
2 changes: 1 addition & 1 deletion lib/node2nix.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
21 changes: 15 additions & 6 deletions node-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" = {
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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"
];
Expand Down Expand Up @@ -1668,7 +1677,7 @@ let
})
];
})
(sources."once-1.3.3" // {
(sources."once-1.4.0" // {
dependencies = [
sources."wrappy-1.0.2"
];
Expand Down
6 changes: 1 addition & 5 deletions tests/default-v4.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
}, 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;
};
in
import ./node-packages-v4.nix {
inherit (pkgs) fetchurl fetchgit;
inherit nodeEnv globalBuildInputs;
inherit nodeEnv;
}
6 changes: 1 addition & 5 deletions tests/default-v5.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,12 @@
}, 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;
};
in
import ./node-packages-v5.nix {
inherit (pkgs) fetchurl fetchgit;
inherit nodeEnv globalBuildInputs;
inherit nodeEnv;
}
26 changes: 13 additions & 13 deletions tests/grunt/node-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down Expand Up @@ -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"
];
Expand All @@ -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"
];
Expand Down Expand Up @@ -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"
];
Expand Down Expand Up @@ -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"
];
Expand Down Expand Up @@ -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"
];
Expand Down
18 changes: 9 additions & 9 deletions tests/grunt/supplement.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" = {
Expand Down Expand Up @@ -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" = {
Expand Down Expand Up @@ -1296,7 +1296,7 @@ in
})
];
})
(sources."once-1.3.3" // {
(sources."once-1.4.0" // {
dependencies = [
sources."wrappy-1.0.2"
];
Expand Down
41 changes: 25 additions & 16 deletions tests/node-packages-v4.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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" = {
Expand Down Expand Up @@ -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";
Expand Down Expand Up @@ -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" = {
Expand Down Expand Up @@ -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 = {
Expand Down Expand Up @@ -2352,7 +2361,7 @@ in
})
];
})
(sources."once-1.3.3" // {
(sources."once-1.4.0" // {
dependencies = [
sources."wrappy-1.0.2"
];
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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"
];
Expand Down Expand Up @@ -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"
];
Expand Down
Loading

0 comments on commit a087122

Please sign in to comment.