Skip to content

Commit

Permalink
nodePackages.expo-cli: use .override
Browse files Browse the repository at this point in the history
generate.sh seems to remove changes to node-env.nix, fortunately
.override seems to work so .overrideNodeAttrs does not actually
seem necessary. Not sure why I did not use it before.
  • Loading branch information
jtojnar committed Oct 8, 2020
1 parent 4f36ce4 commit 94447e0
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
3 changes: 1 addition & 2 deletions pkgs/development/node-packages/default.nix
Expand Up @@ -59,8 +59,7 @@ let
buildInputs = [ pkgs.phantomjs2 ];
};

expo-cli = super."expo-cli".overrideNodeAttrs (attrs: {
__acceptOverrideNodeAttrsCanBeDroppedAnytime = true;
expo-cli = super."expo-cli".override (attrs: {
# The traveling-fastlane-darwin optional dependency aborts build on Linux.
dependencies = builtins.filter (d: d.packageName != "@expo/traveling-fastlane-${if stdenv.isLinux then "darwin" else "linux"}") attrs.dependencies;
});
Expand Down
33 changes: 2 additions & 31 deletions pkgs/development/node-packages/node-env.nix
Expand Up @@ -372,37 +372,8 @@ let
fi
'';

# Derivations built with `buildNodePackage` can already be overriden with `override`, `overrideAttrs`, and `overrideDerivation`.
# This function introduces `overrideNodeAttrs` and it overrides the call to `buildNodePackage`.
#
# THIS FUNCTION IS TEMPORARY until we have a better mechanism in place:
# https://github.com/NixOS/nixpkgs/pull/96509#issuecomment-682381592
# YOU SHOULD NOT USE IT UNLESS YOU ACCEPT THAT.
makeOverridableNodePackage = f: origArgs:
let
ff = f origArgs;
overrideWith = newArgs: origArgs // (
let args = if stdenv.lib.isFunction newArgs then newArgs origArgs else newArgs;
in
assert stdenv.lib.assertMsg (args.__acceptOverrideNodeAttrsCanBeDroppedAnytime or false) ''
overrideNodeAttrs is temporary function that will be removed once a better mechanism exists.
Pass it `__acceptOverrideNodeAttrsCanBeDroppedAnytime = true;` to aknowledge the fact.
'';
builtins.removeAttrs args [ "__acceptOverrideNodeAttrsCanBeDroppedAnytime" ]
);
in
if builtins.isAttrs ff then (ff // {
overrideNodeAttrs = newArgs: makeOverridableNodePackage f (overrideWith newArgs);
})
else if builtins.isFunction ff then {
overrideNodeAttrs = newArgs: makeOverridableNodePackage f (overrideWith newArgs);
__functor = self: ff;
}
else ff;


# Builds and composes an NPM package including all its dependencies
buildNodePackage = makeOverridableNodePackage (
buildNodePackage =
{ name
, packageName
, version
Expand Down Expand Up @@ -472,7 +443,7 @@ let
# Run post install hook, if provided
runHook postInstall
'';
} // extraArgs));
} // extraArgs);

# Builds a development shell
buildNodeShell =
Expand Down

0 comments on commit 94447e0

Please sign in to comment.