From 4f7b92848dc8bd65950d9c32d5017bf32e2cadb6 Mon Sep 17 00:00:00 2001 From: Parnell Springmeyer Date: Fri, 18 May 2018 13:49:15 -0500 Subject: [PATCH] Unset NIX_LDFLAGS, fixing "Argument list too long" errors I suspect this doesn't correctly fix #132 but I did want to open a PR with our (Awake Security) temporary workaround so that anyone else with this problem can find the temporary solution and so that we can discuss whether this suffices or if we want to approach solving this with the suggested `passAsFile` approach. Credit for this workaround goes entirely to @intractable (Joel Stanley). --- nix-libs/nodeLib/buildNodePackage.nix | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/nix-libs/nodeLib/buildNodePackage.nix b/nix-libs/nodeLib/buildNodePackage.nix index 44da114..b513c49 100644 --- a/nix-libs/nodeLib/buildNodePackage.nix +++ b/nix-libs/nodeLib/buildNodePackage.nix @@ -442,8 +442,23 @@ let # Define some environment variables that we will use in the build. setVariables = '' - # In case this was set by an upstream derivation. + # In case these were set by an upstream derivation. + # + # Upstream unsets only `NODE_PATH`, we have added + # the unset of `NIX_LDFLAGS` because: + # + # With a large number of deps, these env vars can + # be large (>128k), such that leaving them exported and + # attempting to invoke shell commands can lead to + # misleading "Argument list too long" errors, which + # actually indicate that kernel-limited env space has + # been exceeded. If unsetting `NIX_LDFLAGS` is problematic + # or cannot be upstreamed, an alternate approach is to + # toggle the exported property on the large env variables + # and/or trying to use something like `passAsFile`. + unset NODE_PATH + unset NIX_LDFLAGS # This creates a string for this package which is unique but # deterministic. We can use it to create temporary directories