sapling: fix nodejs path, add enableMinimal option

This change fixes the path to 'nodejs' in the Sapling scripts, so that
the 'sl web' command works OOTB even if the user has a fresh `$PATH`
without node itself.

However, this is really a developer-only tool, and isn't needed just to
e.g. clone repositories. In particular, a 'fetchSapling' codepath would
not need it; therefore we make it optional, but turned on by default.
The intention is to have a 'saplingMinimal' expression which can be used
for that path.

NOTE: this does NOT add a 'saplingMinimal' expression to
all-packages.nix; that would just result in more Hydra churn, so we
avoid it for now.

Signed-off-by: Austin Seipp <aseipp@pobox.com>
This commit is contained in:
Austin Seipp 2022-12-09 09:22:19 -06:00
parent 21e7ab0afc
commit c847a43b67

View File

@ -17,6 +17,8 @@
, CoreFoundation
, CoreServices
, Security
, enableMinimal ? false
}:
let
@ -129,10 +131,17 @@ let
# 1) This applies on all systems (so no conditional a la postFixup)
# 2) This doesn't require any kind of fixup itself, so we leave it out
# of postFixup for that reason, too
# 3) If asked, we optionally patch in a hardcoded path to the 'nodejs' package,
# so that 'sl web' always works
# 4) 'sl web' will still work if 'nodejs' is in $PATH, just not OOTB
preFixup = ''
sitepackages=$out/lib/${python38Packages.python.libPrefix}/site-packages
chmod +w $sitepackages
cp -r ${isl} $sitepackages/edenscm-isl
'' + lib.optionalString (!enableMinimal) ''
chmod +w $sitepackages/edenscm-isl/run-isl
substituteInPlace $sitepackages/edenscm-isl/run-isl \
--replace 'NODE=node' 'NODE=${nodejs}/bin/node'
'';
postFixup = lib.optionalString stdenv.isLinux ''