summaryrefslogtreecommitdiffstats
path: root/pkgs
diff options
context:
space:
mode:
authorgithub-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>2020-12-03 12:18:45 +0000
committerGitHub <noreply@github.com>2020-12-03 12:18:45 +0000
commit5b73e3087ae63d404f94a76781b281e73a33922b (patch)
treeb102caf1088da9353710b3252e45ab3e61bdb453 /pkgs
parent594ee544b61ff8a026d3d98af90b46d60e67769c (diff)
parent84f417d29beab8e5045a4471a3a288ca3c10c0b9 (diff)
Merge master into staging-next
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/applications/audio/mellowplayer/default.nix4
-rw-r--r--pkgs/applications/networking/browsers/firefox/wrapper.nix170
-rw-r--r--pkgs/applications/networking/cluster/tilt/default.nix4
-rw-r--r--pkgs/build-support/fetchfirefoxaddon/default.nix37
-rw-r--r--pkgs/development/compilers/elm/default.nix14
-rwxr-xr-xpkgs/development/compilers/elm/packages/generate-node-packages.sh4
-rw-r--r--pkgs/development/compilers/elm/packages/node-composition.nix4
-rw-r--r--pkgs/development/compilers/elm/packages/node-env.nix542
-rw-r--r--pkgs/development/compilers/elm/packages/node-packages.json23
-rw-r--r--pkgs/development/compilers/elm/packages/node-packages.nix1048
-rw-r--r--pkgs/development/libraries/libewf/default.nix4
-rw-r--r--pkgs/development/libraries/libslirp/default.nix16
-rw-r--r--pkgs/development/libraries/nco/default.nix4
-rw-r--r--pkgs/development/ocaml-modules/mirage/runtime.nix4
-rw-r--r--pkgs/development/ocaml-modules/mirage/types-lwt.nix13
-rw-r--r--pkgs/development/ocaml-modules/mirage/types.nix19
-rw-r--r--pkgs/development/php-packages/phpstan/default.nix4
-rw-r--r--pkgs/development/php-packages/yaml/default.nix4
-rw-r--r--pkgs/development/ruby-modules/rbenv/default.nix41
-rw-r--r--pkgs/misc/emulators/dolphin-emu/default.nix4
-rw-r--r--pkgs/misc/emulators/dolphin-emu/master.nix2
-rw-r--r--pkgs/servers/mail/postsrsd/default.nix4
-rw-r--r--pkgs/servers/pounce/default.nix4
-rw-r--r--pkgs/shells/oil/default.nix4
-rw-r--r--pkgs/tools/audio/playerctl/default.nix4
-rw-r--r--pkgs/tools/filesystems/mtools/default.nix7
-rw-r--r--pkgs/tools/graphics/oxipng/default.nix6
-rw-r--r--pkgs/tools/networking/slirp4netns/default.nix4
-rw-r--r--pkgs/tools/system/thermald/default.nix4
-rw-r--r--pkgs/top-level/all-packages.nix4
-rw-r--r--pkgs/top-level/ocaml-packages.nix4
31 files changed, 1659 insertions, 351 deletions
diff --git a/pkgs/applications/audio/mellowplayer/default.nix b/pkgs/applications/audio/mellowplayer/default.nix
index 26736ea3e8a3..37c384967737 100644
--- a/pkgs/applications/audio/mellowplayer/default.nix
+++ b/pkgs/applications/audio/mellowplayer/default.nix
@@ -14,13 +14,13 @@
mkDerivation rec {
pname = "MellowPlayer";
- version = "3.6.6";
+ version = "3.6.7";
src = fetchFromGitLab {
owner = "ColinDuquesnoy";
repo = "MellowPlayer";
rev = version;
- sha256 = "14y175fl6wg04fz0fhx553r8z3nwqrs2lr3rdls70bhwx5x6lavw";
+ sha256 = "1p0z8hkbxaxrqjmknjwxb0mpf3xdssik3m5cwrsv1881k1x2x5qs";
};
nativeBuildInputs = [ cmake pkgconfig ];
diff --git a/pkgs/applications/networking/browsers/firefox/wrapper.nix b/pkgs/applications/networking/browsers/firefox/wrapper.nix
index cc6cc72e27be..f9b7f2bb8a2e 100644
--- a/pkgs/applications/networking/browsers/firefox/wrapper.nix
+++ b/pkgs/applications/networking/browsers/firefox/wrapper.nix
@@ -1,4 +1,5 @@
{ stdenv, lib, makeDesktopItem, makeWrapper, lndir, config
+, replace, fetchurl, zip, unzip, jq
## various stuff that can be plugged in
, flashplayer, hal-flash
@@ -31,6 +32,16 @@ let
, forceWayland ? false
, useGlvnd ? true
, cfg ? config.${browserName} or {}
+
+ ## Following options are needed for extra prefs & policies
+ # For more information about anti tracking (german website)
+ # visit https://wiki.kairaven.de/open/app/firefox
+ , extraPrefs ? ""
+ # For more information about policies visit
+ # https://github.com/mozilla/policy-templates#enterprisepoliciesenabled
+ , extraPolicies ? {}
+ , firefoxLibName ? "firefox" # Important for tor package or the like
+ , extraExtensions ? [ ]
}:
assert forceWayland -> (browser ? gtk3); # Can only use the wayland backend if gtk3 is being used
@@ -81,6 +92,61 @@ let
++ pkcs11Modules;
gtk_modules = [ libcanberra-gtk2 ];
+ #########################
+ # #
+ # EXTRA PREF CHANGES #
+ # #
+ #########################
+ policiesJson = builtins.toFile "policies.json"
+ (builtins.toJSON enterprisePolicies);
+
+ extensions = builtins.map (a:
+ if ! (builtins.hasAttr "extid" a) then
+ throw "extraExtensions has an invalid entry. Missing extid attribute. Please use fetchfirefoxaddon"
+ else
+ a
+ ) extraExtensions;
+
+ enterprisePolicies =
+ {
+ policies = {
+ DisableAppUpdate = true;
+ } //
+ {
+ ExtensionSettings = {
+ "*" = {
+ blocked_install_message = "You can't have manual extension mixed with nix extensions";
+ installation_mode = "blocked";
+ };
+
+ } // lib.foldr (e: ret:
+ ret // {
+ "${e.extid}" = {
+ installation_mode = "allowed";
+ };
+ }
+ ) {} extensions;
+ }
+ // extraPolicies;
+ };
+
+ mozillaCfg = builtins.toFile "mozilla.cfg" ''
+// First line must be a comment
+
+ // Disables addon signature checking
+ // to be able to install addons that do not have an extid
+ // Security is maintained because only user whitelisted addons
+ // with a checksum can be installed
+ lockPref("xpinstall.signatures.required", false);
+ ${extraPrefs}
+ '';
+
+ #############################
+ # #
+ # END EXTRA PREF CHANGES #
+ # #
+ #############################
+
in stdenv.mkDerivation {
inherit pname version;
@@ -106,6 +172,7 @@ let
nativeBuildInputs = [ makeWrapper lndir ];
buildInputs = lib.optional (browser ? gtk3) browser.gtk3;
+
buildCommand = lib.optionalString stdenv.isDarwin ''
mkdir -p $out/Applications
cp -R --no-preserve=mode,ownership ${browser}/Applications/${browserName}.app $out/Applications
@@ -117,7 +184,66 @@ let
exit 1
fi
- makeWrapper "$(readlink -v --canonicalize-existing "${browser}${browser.execdir or "/bin"}/${browserName}")" \
+ #########################
+ # #
+ # EXTRA PREF CHANGES #
+ # #
+ #########################
+ # Link the runtime. The executable itself has to be copied,
+ # because it will resolve paths relative to its true location.
+ # Any symbolic links have to be replicated as well.
+ cd "${browser}"
+ find . -type d -exec mkdir -p "$out"/{} \;
+
+ find . -type f \( -not -name "${browserName}" \) -exec ln -sT "${browser}"/{} "$out"/{} \;
+
+ find . -type f -name "${browserName}" -print0 | while read -d $'\0' f; do
+ cp -P --no-preserve=mode,ownership "${browser}/$f" "$out/$f"
+ chmod a+rwx "$out/$f"
+ done
+
+ # fix links and absolute references
+ cd "${browser}"
+
+ find . -type l -print0 | while read -d $'\0' l; do
+ target="$(readlink "$l" | ${replace}/bin/replace-literal -es -- "${browser}" "$out")"
+ ln -sfT "$target" "$out/$l"
+ done
+
+ # This will not patch binaries, only "text" files.
+ # Its there for the wrapper mostly.
+ cd "$out"
+ ${replace}/bin/replace-literal -esfR -- "${browser}" "$out"
+
+ # create the wrapper
+
+ executablePrefix="$out${browser.execdir or "/bin"}"
+ executablePath="$executablePrefix/${browserName}"
+
+ if [ ! -x "$executablePath" ]
+ then
+ echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${browserName}'"
+ exit 1
+ fi
+
+ if [ ! -L "$executablePath" ]
+ then
+ # Careful here, the file at executablePath may already be
+ # a wrapper. That is why we postfix it with -old instead
+ # of -wrapped.
+ oldExe="$executablePrefix"/".${browserName}"-old
+ mv "$executablePath" "$oldExe"
+ else
+ oldExe="$(readlink -v --canonicalize-existing "$executablePath")"
+ fi
+
+ if [ ! -x "${browser}${browser.execdir or "/bin"}/${browserName}" ]
+ then
+ echo "cannot find executable file \`${browser}${browser.execdir or "/bin"}/${browserName}'"
+ exit 1
+ fi
+
+ makeWrapper "$oldExe" \
"$out${browser.execdir or "/bin"}/${browserName}${nameSuffix}" \
--suffix-each MOZ_PLUGIN_PATH ':' "$plugins" \
--suffix LD_LIBRARY_PATH ':' "$libs" \
@@ -137,6 +263,11 @@ let
--suffix XDG_DATA_DIRS : '${gnome3.adwaita-icon-theme}/share'
''
}
+ #############################
+ # #
+ # END EXTRA PREF CHANGES #
+ # #
+ #############################
if [ -e "${browser}/share/icons" ]; then
mkdir -p "$out/share"
@@ -166,6 +297,43 @@ let
# For manpages, in case the program supplies them
mkdir -p $out/nix-support
echo ${browser} > $out/nix-support/propagated-user-env-packages
+
+
+ #########################
+ # #
+ # EXTRA PREF CHANGES #
+ # #
+ #########################
+ # user customization
+ mkdir -p $out/lib/${firefoxLibName}
+
+ # creating policies.json
+ mkdir -p "$out/lib/${firefoxLibName}/distribution"
+
+ POL_PATH="$out/lib/${firefoxLibName}/distribution/policies.json"
+ rm -f "$POL_PATH"
+ cat ${policiesJson} >> "$POL_PATH"
+
+ # preparing for autoconfig
+ mkdir -p "$out/lib/${firefoxLibName}/defaults/pref"
+
+ cat > "$out/lib/${firefoxLibName}/defaults/pref/autoconfig.js" <<EOF
+ pref("general.config.filename", "mozilla.cfg");
+ pref("general.config.obscure_value", 0);
+ EOF
+
+ cat > "$out/lib/${firefoxLibName}/mozilla.cfg" < ${mozillaCfg}
+
+ mkdir -p $out/lib/${firefoxLibName}/distribution/extensions
+
+ for i in ${toString extensions}; do
+ ln -s -t $out/lib/${firefoxLibName}/distribution/extensions $i/*
+ done
+ #############################
+ # #
+ # END EXTRA PREF CHANGES #
+ # #
+ #############################
'';
preferLocalBuild = true;
diff --git a/pkgs/applications/networking/cluster/tilt/default.nix b/pkgs/applications/networking/cluster/tilt/default.nix
index d362500ff598..40ba3530c8af 100644
--- a/pkgs/applications/networking/cluster/tilt/default.nix
+++ b/pkgs/applications/networking/cluster/tilt/default.nix
@@ -5,13 +5,13 @@ buildGoModule rec {
/* Do not use "dev" as a version. If you do, Tilt will consider itself
running in development environment and try to serve assets from the
source tree, which is not there once build completes. */
- version = "0.17.12";
+ version = "0.17.13";
src = fetchFromGitHub {
owner = "tilt-dev";
repo = pname;
rev = "v${version}";
- sha256 = "0l70nmxvk30h56bs46cgakddzdf3laj1y88d0jchij0yy7ixa61f";
+ sha256 = "sha256-x3U5OF8T3z9kHcYe7SwKVEKNiEsi8AEvA1rlOma4y+8=";
};
vendorSha256 = null;
diff --git a/pkgs/build-support/fetchfirefoxaddon/default.nix b/pkgs/build-support/fetchfirefoxaddon/default.nix
new file mode 100644
index 000000000000..3426743b2cf1
--- /dev/null
+++ b/pkgs/build-support/fetchfirefoxaddon/default.nix
@@ -0,0 +1,37 @@
+{stdenv, lib, coreutils, unzip, jq, zip, fetchurl,writeScript, ...}:
+{ name
+, url
+, md5 ? ""
+, sha1 ? ""
+, sha256 ? ""
+, sha512 ? ""
+}:
+stdenv.mkDerivation rec {
+
+ inherit name;
+ extid = "${src.outputHash}@${name}";
+ passthru = {
+ exitd=extid;
+ };
+
+ builder = writeScript "xpibuilder" ''
+ source $stdenv/setup
+
+ header "firefox addon $name into $out"
+
+ UUID="${extid}"
+ mkdir -p "$out/$UUID"
+ unzip -q ${src} -d "$out/$UUID"
+ NEW_MANIFEST=$(jq '. + {"applications": { "gecko": { "id": "${extid}" }}, "browser_specific_settings":{"gecko":{"id": "${extid}"}}}' "$out/$UUID/manifest.json")
+ echo "$NEW_MANIFEST" > "$out/$UUID/manifest.json"
+ cd "$out/$UUID"
+ zip -r -q -FS "$out/$UUID.xpi" *
+ rm -r "$out/$UUID"
+ '';
+ src = fetchurl {
+ url = url;
+ inherit md5 sha1 sha256 sha512;
+ };
+ nativeBuildInputs = [ coreutils unzip zip jq ];
+}
+
diff --git a/pkgs/development/compilers/elm/default.nix b/pkgs/development/compilers/elm/default.nix
index 369ea8626204..0dbf1a3306f3 100644
--- a/pkgs/development/compilers/elm/default.nix
+++ b/pkgs/development/compilers/elm/default.nix
@@ -74,6 +74,12 @@ let
inherit (hsPkgs.elmPkgs) elm;
};
+ elmRustPackages = {
+ elm-json = import ./packages/elm-json.nix {
+ inherit rustPlatform fetchurl openssl stdenv pkg-config;
+ };
+ };
+
elmNodePackages = with elmLib;
let
nodePkgs = import ./packages/node-composition.nix {
@@ -110,6 +116,9 @@ let
create-elm-app = patchNpmElm (patchBinwrap [elmi-to-json]
nodePkgs.create-elm-app);
+ elm-review = patchBinwrap [elmRustPackages.elm-json]
+ nodePkgs.elm-review;
+
elm-language-server = nodePkgs."@elm-tooling/elm-language-server";
elm-optimize-level-2 = nodePkgs."elm-optimize-level-2";
@@ -117,9 +126,6 @@ let
inherit (nodePkgs) elm-doc-preview elm-live elm-upgrade elm-xref elm-analyse;
};
-in hsPkgs.elmPkgs // elmNodePackages // {
- elm-json = import ./packages/elm-json.nix {
- inherit rustPlatform fetchurl openssl stdenv pkg-config;
- };
+in hsPkgs.elmPkgs // elmNodePackages // elmRustPackages // {
lib = elmLib;
}
diff --git a/pkgs/development/compilers/elm/packages/generate-node-packages.sh b/pkgs/development/compilers/elm/packages/generate-node-packages.sh
index 0ffa56eae90a..d805fe3827dd 100755
--- a/pkgs/development/compilers/elm/packages/generate-node-packages.sh
+++ b/pkgs/development/compilers/elm/packages/generate-node-packages.sh
@@ -10,4 +10,6 @@ $(nix-build $ROOT -A nodePackages.node2nix --no-out-link)/bin/node2nix \
-i node-packages.json \
-o node-packages.nix \
-c node-composition.nix \
- --no-copy-node-env -e ../../../node-packages/node-env.nix
+ # TODO: Switch to the commented out version once nodejs package set gets updated to new node2nix
+ -e node-env.nix
+ # --no-copy-node-env -e ../../../node-packages/node-env.nix
diff --git a/pkgs/development/compilers/elm/packages/node-composition.nix b/pkgs/development/compilers/elm/packages/node-composition.nix
index 1b2e11782cd1..c970861a86f0 100644
--- a/pkgs/development/compilers/elm/packages/node-composition.nix
+++ b/pkgs/development/compilers/elm/packages/node-composition.nix
@@ -5,8 +5,8 @@
}, system ? builtins.currentSystem, nodejs ? pkgs."nodejs-12_x"}:
let
- nodeEnv = import ../../../node-packages/node-env.nix {
- inherit (pkgs) stdenv python2 util-linux runCommand writeTextFile;
+ nodeEnv = import ./node-env.nix {
+ inherit (pkgs) stdenv python2 utillinux runCommand writeTextFile;
inherit nodejs;
libtool = if pkgs.stdenv.isDarwin then pkgs.darwin.cctools else null;
};
diff --git a/pkgs/development/compilers/elm/packages/node-env.nix b/pkgs/development/compilers/elm/packages/node-env.nix
new file mode 100644
index 000000000000..e1abf5304935
--- /dev/null
+++ b/pkgs/development/compilers/elm/packages/node-env.nix
@@ -0,0 +1,542 @@
+# This file originates from node2nix
+
+{stdenv, nodejs, python2, utillinux, libtool, runCommand, writeTextFile}:
+
+let
+ python = if nodejs ? python then nodejs.python else python2;
+
+ # Create a tar wrapper that filters all the 'Ignoring unknown extended header keyword' noise
+ tarWrapper = runCommand "tarWrapper" {} ''
+ mkdir -p $out/bin
+
+ cat > $out/bin/tar <<EOF
+ #! ${stdenv.shell} -e
+ $(type -p tar) "\$@" --warning=no-unknown-keyword --delay-directory-restore
+ EOF
+
+ chmod +x $out/bin/tar
+ '';
+
+ # Function that generates a TGZ file from a NPM project
+ buildNodeSourceDist =
+ { name, version, src, ... }:
+
+ stdenv.mkDerivation {
+ name = "node-tarball-${name}-${version}";
+ inherit src;
+ buildInputs = [ nodejs ];
+ buildPhase = ''
+ export HOME=$TMPDIR
+ tgzFile=$(npm pack | tail -n 1) # Hooks to the pack command will add output (https://docs.npmjs.com/misc/scripts)
+ '';
+ installPhase = ''
+ mkdir -p $out/tarballs
+ mv $tgzFile $out/tarballs
+ mkdir -p $out/nix-support
+ echo "file source-dist $out/tarballs/$tgzFile" >> $out/nix-support/hydra-build-products
+ '';
+ };
+
+ includeDependencies = {dependencies}:
+ stdenv.lib.optionalString (dependencies != [])
+ (stdenv.lib.concatMapStrings (dependency:
+ ''
+ # Bundle the dependencies of the package
+ mkdir -p node_modules
+ cd node_modules
+
+ # Only include dependencies if they don't exist. They may also be bundled in the package.
+ if [ ! -e "${dependency.name}" ]
+ then
+ ${composePackage dependency}
+ fi
+
+ cd ..
+ ''
+ ) dependencies);
+
+ # Recursively composes the dependencies of a package
+ composePackage = { name, packageName, src, dependencies ? [], ... }@args:
+ builtins.addErrorContext "while evaluating node package '${packageName}'" ''
+ DIR=$(pwd)
+ cd $TMPDIR
+
+ unpackFile ${src}
+
+ # Make the base dir in which the target dependency resides first
+ mkdir -p "$(dirname "$DIR/${packageName}")"
+
+ if [ -f "${src}" ]
+ then
+ # Figure out what directory has been unpacked
+ packageDir="$(find . -maxdepth 1 -type d | tail -1)"
+
+ # Restore write permissions to make building work
+ find "$packageDir" -type d -exec chmod u+x {} \;
+ chmod -R u+w "$packageDir"
+
+ # Move the extracted tarball into the output folder
+ mv "$packageDir" "$DIR/${packageName}"
+ elif [ -d "${src}" ]
+ then
+ # Get a stripped name (without hash) of the source directory.
+ # On old nixpkgs it's already set internally.
+ if [ -z "$strippedName" ]
+ then
+ strippedName="$(stripHash ${src})"
+ fi
+
+ # Restore write permissions to make building work
+ chmod -R u+w "$strippedName"
+
+ # Move the extracted directory into the output folder
+ mv "$strippedName" "$DIR/${packageName}"
+ fi
+
+ # Unset the stripped name to not confuse the next unpack step
+ unset strippedName
+
+ # Include the dependencies of the package
+ cd "$DIR/${packageName}"
+ ${includeDependencies { inherit dependencies; }}
+ cd ..
+ ${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
+ '';
+
+ pinpointDependencies = {dependencies, production}:
+ let
+ pinpointDependenciesFromPackageJSON = writeTextFile {
+ name = "pinpointDependencies.js";
+ text = ''
+ var fs = require('fs');
+ var path = require('path');
+
+ function resolveDependencyVersion(location, name) {
+ if(location == process.env['NIX_STORE']) {
+ return null;
+ } else {
+ var dependencyPackageJSON = path.join(location, "node_modules", name, "package.json");
+
+ if(fs.existsSync(dependencyPackageJSON)) {
+ var dependencyPackageObj = JSON.parse(fs.readFileSync(dependencyPackageJSON));
+
+ if(dependencyPackageObj.name == name) {
+ return dependencyPackageObj.version;
+ }
+ } else {
+ return resolveDependencyVersion(path.resolve(location, ".."), name);
+ }
+ }
+ }
+
+ function replaceDependencies(dependencies) {
+ if(typeof dependencies == "object" && dependencies !== null) {
+ for(var dependency in dependencies) {
+ var resolvedVersion = resolveDependencyVersion(process.cwd(), dependency);
+
+ if(resolvedVersion === null) {
+ process.stderr.write("WARNING: cannot pinpoint dependency: "+dependency+", context: "+process.cwd()+"\n");
+ } else {
+ dependencies[dependency] = resolvedVersion;
+ }
+ }
+ }
+ }
+
+ /* Read the package.json configuration */
+ var packageObj = JSON.parse(fs.readFileSync('./package.json'));
+
+ /* Pinpoint all dependencies */
+ replaceDependencies(packageObj.dependencies);
+ if(process.argv[2] == "development") {
+ replaceDependencies(packageObj.devDependencies);
+ }
+ replaceDependencies(packageObj.optionalDependencies);
+
+ /* Write the fixed package.json file */
+ fs.writeFileSync("package.json", JSON.stringify(packageObj, null, 2));
+ '';
+ };
+ in
+ ''
+ node ${pinpointDependenciesFromPackageJSON} ${if production then "production" else "development"}
+
+ ${stdenv.lib.optionalString (dependencies != [])
+ ''
+ if [ -d node_modules ]
+ then
+ cd node_modules
+ ${stdenv.lib.concatMapStrings (dependency: pinpointDependenciesOfPackage dependency) dependencies}
+ cd ..
+ fi
+ ''}
+ '';
+
+ # Recursively traverses all dependencies of a package and pinpoints all
+ # dependencies in the package.json file to the versions that are actually
+ # being used.
+
+ pinpointDependenciesOfPackage = { packageName, dependencies ? [], production ? true, ... }@args:
+ ''
+ if [ -d "${packageName}" ]
+ then
+ cd "${packageName}"
+ ${pinpointDependencies { inherit dependencies production; }}
+ cd ..
+ ${stdenv.lib.optionalString (builtins.substring 0 1 packageName == "@") "cd .."}
+ fi
+ '';
+
+ # Extract the Node.js source code which is used to compile packages with
+ # native bindings
+ nodeSources = runCommand "node-sources" {} ''
+ tar --no-same-owner --no-same-permissions -xf ${nodejs.src}
+ mv node-* $out
+ '';
+
+ # Script that adds _integrity fields to all package.json files to prevent NPM from consulting the cache (that is empty)
+ addIntegrityFieldsScript = writeTextFile {
+ name = "addintegrityfields.js";
+ text = ''
+ var fs = require('fs');
+ var path = require('path');
+
+ function augmentDependencies(baseDir, dependencies) {
+ for(var dependencyName in dependencies) {
+ var dependency = dependencies[dependencyName];
+
+ // Open package.json and augment metadata fields
+ var packageJSONDir = path.join(baseDir, "node_modules", dependencyName);
+ var packageJSONPath = path.join(packageJSONDir, "package.json");
+
+ if(fs.existsSync(packageJSONPath)) { // Only augment packages that exist. Sometimes we may have production installs in which development dependencies can be ignored
+ console.log("Adding metadata fields to: "+packageJSONPath);
+ var packageObj = JSON.parse(fs.readFileSync(packageJSONPath));
+
+ if(dependency.integrity) {
+ packageObj["_integrity"] = dependency.integrity;
+ } else {
+ packageObj["_integrity"] = "sha1-000000000000000000000000000="; // When no _integrity string has been provided (e.g. by Git dependencies), add a dummy one. It does not seem to harm and it bypasses downloads.
+ }
+
+ if(dependency.resolved) {
+ packageObj["_resolved"] = dependency.resolved; // Adopt the resolved property if one has been provided
+ } else {
+ packageObj["_resolved"] = dependency.version; // Set the resolved version to the version identifier. This prevents NPM from cloning Git repositories.
+ }
+
+ if(dependency.from !== undefined) { // Adopt from property if one has been provided
+ packageObj["_from"] = dependency.from;
+ }
+
+ fs.writeFileSync(packageJSONPath, JSON.stringify(packageObj, null, 2));
+ }
+
+ // Augment transitive dependencies
+ if(dependency.dependencies !== undefined) {
+ augmentDependencies(packageJSONDir, dependency.dependencies);
+ }
+ }
+ }
+
+ if(fs.existsSync("./package-lock.json")) {
+ var packageLock = JSON.parse(fs.readFileSync("./package-lock.json"));
+
+ if(packageLock.lockfileVersion !== 1) {
+ process.stderr.write("Sorry, I only understand lock file version 1!\n");
+ process.exit(1);
+ }
+
+ if(packageLock.dependencies !== undefined) {
+ augmentDependencies(".", packageLock.dependencies);
+ }
+ }
+ '';
+ };
+
+ # Reconstructs a package-lock file from the node_modules/ folder structure and package.json files with dummy sha1 hashes
+ reconstructPackageLock = writeTextFile {
+ name = "addintegrityfields.js";
+ text = ''
+ var fs = require('fs');
+ var path = require('path');
+
+ var packageObj = JSON.parse(fs.readFileSync("package.json"));
+
+ var lockObj = {
+ name: packageObj.name,
+ version: packageObj.version,
+ lockfileVersion: 1,
+ requires: true,
+ dependencies: {}
+ };
+
+ function augmentPackageJSON(filePath, dependencies) {
+ var packageJSON = path.join(filePath, "package.json");
+ if(fs.existsSync(packageJSON)) {
+ var packageObj = JSON.parse(fs.readFileSync(packageJSON));
+ dependencies[packageObj.name] = {
+ version: packageObj.version,
+ integrity: "sha1-000000000000000000000000000=",
+ dependencies: {}
+ };
+ processDependencies(path.join(filePath, "node_modules"), dependencies[packageObj.name].dependencies);
+ }
+ }
+
+ function processDependencies(dir, dependencies) {
+ if(fs.existsSync(dir)) {
+ var files = fs.readdirSync(dir);
+
+ files.forEach(function(entry) {
+ var filePath = path.join(dir, entry);
+ var stats = fs.statSync(filePath);
+
+ if(stats.isDirectory()) {
+ if(entry.substr(0, 1) == "@") {
+ // When we encounter a namespace folder, augment all packages belonging to the scope
+ var pkgFiles = fs.readdirSync(filePath);
+
+ pkgFiles.forEach(function(entry) {
+ if(stats.isDirectory()) {
+ var pkgFilePath = path.join(filePa