Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions manifests/build-support/mkDerivation.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
darwin,
nodePackages,
buildNpmPackage,
installShellFiles,
makeWrapper,
}:
version: source:
let
Expand All @@ -29,6 +31,7 @@ let
# build issues with Node 22+. Spago 0.93.45+ works with the standard nodejs.
# See: https://github.com/purescript/registry-dev/blob/87c5900ff6fb7090cf2b085b7eb3f75371560522/nix/overlay.nix#L152
isLegacySpago = isSpago && builtins.compareVersions version "0.93.45" < 0;

in
# Simple tarball without dependencies - just extract and link
if isSimpleTarball then
Expand Down Expand Up @@ -74,6 +77,8 @@ else
spagoNativeBuildInputs = [
nodePackages.node-gyp
python3
makeWrapper
installShellFiles
]
++ lib.optionals stdenv.isDarwin [ darwin.cctools ];
in
Expand Down Expand Up @@ -101,5 +106,21 @@ else
"--omit=optional"
];

# For spago: Replace the symlink with a wrapper that invokes node directly
# with the script renamed via a symlink. This fixes spago displaying
# "Usage: bundle.js" instead of "Usage: spago" (Node.js uses the script
# path for the program name). Also generate shell completions.
postInstall = lib.optionalString isSpago ''
rm $out/bin/${name}
ln -s $out/lib/node_modules/${name}/${js} $out/lib/node_modules/${name}/bin/${name}
makeWrapper ${selectedNodejs}/bin/node $out/bin/${name} \
--add-flags $out/lib/node_modules/${name}/bin/${name}
installShellCompletion --cmd ${name} \
--bash <($out/bin/${name} --bash-completion-script $out/bin/${name}) \
--zsh <($out/bin/${name} --zsh-completion-script $out/bin/${name}) \
--fish <($out/bin/${name} --fish-completion-script $out/bin/${name})
'';

meta = commonMeta;
}