diff --git a/CHANGELOG_NEXT.md b/CHANGELOG_NEXT.md index b61848bed5..91ba4c96b1 100644 --- a/CHANGELOG_NEXT.md +++ b/CHANGELOG_NEXT.md @@ -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`. diff --git a/flake.nix b/flake.nix index 910a63e213..83b9a68655 100644 --- a/flake.nix +++ b/flake.nix @@ -47,6 +47,7 @@ buildIdris = pkgs.callPackage ./nix/buildIdris.nix { inherit idris2-version; idris2 = idris2Pkg; + support = idris2Support; }; idris2ApiPkg = buildIdris { src = ./.; diff --git a/nix/buildIdris.nix b/nix/buildIdris.nix index b5356c4d67..5e0c953c3e 100644 --- a/nix/buildIdris.nix +++ b/nix/buildIdris.nix @@ -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 ''; });