Fix executable output of buildIdris nix helper (#3188)

This commit is contained in:
Mathew Polzin 2024-01-08 23:58:17 -06:00 committed by GitHub
parent 2b5030a325
commit da6f0b0e4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 25 additions and 3 deletions

View File

@ -14,6 +14,13 @@ This CHANGELOG describes the merged but unreleased changes. Please see [CHANGELO
installed with sourcecode files or not; other than that, `library`
functionally replaces `installLibrary`.
* The Nix flake's `buildIdris` `executable` property (previously `build`) has
been fixed in a few ways. It used to output a non-executable file for NodeJS
builds (now the file has the executable bit set). It used to output the
default Idris2 wrapper for Scheme builds which relies on utilities not
guaranteed at runtime by the Nix derivation; now it rewraps the output to only
depend on the directory containing Idris2's runtime support library.
* The Nix flake now exposes the Idris2 API package as `idris2-api` and Idris2's
C support library as `support`.

View File

@ -47,6 +47,7 @@
buildIdris = pkgs.callPackage ./nix/buildIdris.nix {
inherit idris2-version;
idris2 = idris2Pkg;
support = idris2Support;
};
idris2ApiPkg = buildIdris {
src = ./.;

View File

@ -1,4 +1,4 @@
{ stdenv, lib, idris2-version, idris2 }:
{ stdenv, lib, idris2-version, idris2, support, makeWrapper }:
{ src, projectName, idrisLibraries, ... }@attrs:
let
@ -12,7 +12,8 @@ in rec {
executable = stdenv.mkDerivation (drvAttrs // {
name = projectName;
src = src;
nativeBuildInputs = [ idris2 ];
buildInputs = idrisLibraries ++ attrs.buildInputs or [];
nativeBuildInputs = [ idris2 makeWrapper ] ++ attrs.nativeBuildInputs or [];
configurePhase = ''
runHook preConfigure
export IDRIS2_PACKAGE_PATH=${lib-dirs}
@ -26,7 +27,20 @@ in rec {
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mv build/exec/* $out/bin
scheme_app="$(find ./build/exec -name '*_app')"
if [ "$scheme_app" = ''' ]; then
mv -- build/exec/* $out/bin/
chmod +x $out/bin/*
else
cd build/exec/*_app
for file in *.so; do
bin_name="''${file%.so}"
mv -- "$file" "$out/bin/$bin_name"
wrapProgram "$out/bin/$bin_name" \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath [ support ]} \
--prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath [ support ]}
done
fi
runHook postInstall
'';
});