Skip to content

Commit

Permalink
Fix executable output of buildIdris nix helper (#3188)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattpolzin committed Jan 9, 2024
1 parent 2b5030a commit da6f0b0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG_NEXT.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.

Expand Down
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
buildIdris = pkgs.callPackage ./nix/buildIdris.nix {
inherit idris2-version;
idris2 = idris2Pkg;
support = idris2Support;
};
idris2ApiPkg = buildIdris {
src = ./.;
Expand Down
20 changes: 17 additions & 3 deletions nix/buildIdris.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ stdenv, lib, idris2-version, idris2 }:
{ stdenv, lib, idris2-version, idris2, support, makeWrapper }:
{ src, projectName, idrisLibraries, ... }@attrs:

let
Expand All @@ -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}
Expand All @@ -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
'';
});
Expand Down

0 comments on commit da6f0b0

Please sign in to comment.