diff options
author | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2024-01-27 04:17:36 +0100 |
---|---|---|
committer | Weijia Wang <9713184+wegank@users.noreply.github.com> | 2024-01-27 04:17:36 +0100 |
commit | 43545381393695f722344b085620937fa3367a8a (patch) | |
tree | e2b7bdf1f0d5453341a4619f8a63948c6e6b2f76 /pkgs/development/compilers/idris2/build-idris.nix | |
parent | 4757f0e68df99bc7177c68dcc7c523e391d213cf (diff) | |
parent | 741c01dfc130418b134d48dfbb68f9462f853e32 (diff) |
Merge branch 'staging-next' into staging
Diffstat (limited to 'pkgs/development/compilers/idris2/build-idris.nix')
-rw-r--r-- | pkgs/development/compilers/idris2/build-idris.nix | 89 |
1 files changed, 51 insertions, 38 deletions
diff --git a/pkgs/development/compilers/idris2/build-idris.nix b/pkgs/development/compilers/idris2/build-idris.nix index c299128aa5260..3ad0956e3a081 100644 --- a/pkgs/development/compilers/idris2/build-idris.nix +++ b/pkgs/development/compilers/idris2/build-idris.nix @@ -1,9 +1,9 @@ -{ stdenv, lib, idris2 +{ stdenv, lib, idris2, makeWrapper }: # Usage: let # pkg = idris2Packages.buildIdris { # src = ...; -# projectName = "my-pkg"; +# ipkgName = "my-pkg"; # idrisLibraries = [ ]; # }; # in { @@ -12,62 +12,75 @@ # } # { src -, projectName +, ipkgName +, version ? "unversioned" , idrisLibraries # Other libraries built with buildIdris , ... }@attrs: let - ipkgName = projectName + ".ipkg"; + ipkgFileName = ipkgName + ".ipkg"; idrName = "idris2-${idris2.version}"; libSuffix = "lib/${idrName}"; libDirs = - lib.makeSearchPath libSuffix idrisLibraries; - drvAttrs = builtins.removeAttrs attrs [ "idrisLibraries" ]; + (lib.makeSearchPath libSuffix idrisLibraries) + + ":${idris2}/${idrName}"; + supportDir = "${idris2}/${idrName}/lib"; + drvAttrs = builtins.removeAttrs attrs [ + "ipkgName" + "idrisLibraries" + ]; - sharedAttrs = { - name = projectName; + sharedAttrs = drvAttrs // { + pname = ipkgName; + inherit version; src = src; - nativeBuildInputs = [ idris2 ]; + nativeBuildInputs = [ idris2 makeWrapper ] ++ attrs.nativeBuildInputs or []; + buildInputs = idrisLibraries ++ attrs.buildInputs or []; IDRIS2_PACKAGE_PATH = libDirs; - configurePhase = '' - runHook preConfigure - runHook postConfigure - ''; - buildPhase = '' runHook preBuild - idris2 --build ${ipkgName} + idris2 --build ${ipkgFileName} runHook postBuild ''; }; in { - executable = stdenv.mkDerivation (lib.attrsets.mergeAttrsList [ - sharedAttrs - { installPhase = '' + executable = stdenv.mkDerivation (sharedAttrs // { + installPhase = '' + runHook preInstall + mkdir -p $out/bin + scheme_app="$(find ./build/exec -name '*_app')" + if [ "$scheme_app" = ''' ]; then + mv -- build/exec/* $out/bin/ + chmod +x $out/bin/* + # ^ remove after Idris2 0.8.0 is released. will be superfluous: + # https://github.com/idris-lang/Idris2/pull/3189 + else + cd build/exec/*_app + rm -f ./libidris2_support.so + for file in *.so; do + bin_name="''${file%.so}" + mv -- "$file" "$out/bin/$bin_name" + wrapProgram "$out/bin/$bin_name" \ + --prefix LD_LIBRARY_PATH : ${supportDir} \ + --prefix DYLD_LIBRARY_PATH : ${supportDir} + done + fi + runHook postInstall + ''; + }); + + library = { withSource ? false }: + let installCmd = if withSource then "--install-with-src" else "--install"; + in stdenv.mkDerivation (sharedAttrs // { + installPhase = '' runHook preInstall - mkdir -p $out/bin - mv build/exec/* $out/bin + mkdir -p $out/${libSuffix} + export IDRIS2_PREFIX=$out/lib + idris2 ${installCmd} ${ipkgFileName} runHook postInstall ''; - } - drvAttrs - ]); - library = { withSource ? false }: - let installCmd = if withSource then "--install-with-src" else "--install"; - in stdenv.mkDerivation (lib.attrsets.mergeAttrsList [ - sharedAttrs - { - installPhase = '' - runHook preInstall - mkdir -p $out/${libSuffix} - export IDRIS2_PREFIX=$out/lib - idris2 ${installCmd} ${ipkgName} - runHook postInstall - ''; - } - drvAttrs - ]); + }); } |