mirror of
https://github.com/idris-lang/Idris2.git
synced 2024-12-18 16:51:51 +03:00
better nix-shell support via shellHook (#3243)
This commit is contained in:
parent
2c2aa85048
commit
1977dbd640
@ -13,7 +13,7 @@
|
|||||||
{ src
|
{ src
|
||||||
, ipkgName
|
, ipkgName
|
||||||
, version ? "unversioned"
|
, version ? "unversioned"
|
||||||
, idrisLibraries
|
, idrisLibraries # Other libraries built with buildIdris
|
||||||
, ... }@attrs:
|
, ... }@attrs:
|
||||||
|
|
||||||
let
|
let
|
||||||
@ -29,65 +29,69 @@ let
|
|||||||
"idrisLibraries"
|
"idrisLibraries"
|
||||||
];
|
];
|
||||||
|
|
||||||
sharedAttrs = drvAttrs // {
|
derivation = stdenv.mkDerivation (finalAttrs:
|
||||||
pname = ipkgName;
|
drvAttrs // {
|
||||||
inherit version;
|
pname = ipkgName;
|
||||||
src = src;
|
inherit version;
|
||||||
nativeBuildInputs = [ idris2 makeWrapper ] ++ attrs.nativeBuildInputs or [];
|
src = src;
|
||||||
buildInputs = propagatedIdrisLibraries ++ attrs.buildInputs or [];
|
nativeBuildInputs = [ idris2 makeWrapper ] ++ attrs.nativeBuildInputs or [];
|
||||||
|
buildInputs = propagatedIdrisLibraries ++ attrs.buildInputs or [];
|
||||||
|
|
||||||
IDRIS2_PACKAGE_PATH = libDirs;
|
IDRIS2_PACKAGE_PATH = libDirs;
|
||||||
|
|
||||||
buildPhase = ''
|
buildPhase = ''
|
||||||
runHook preBuild
|
runHook preBuild
|
||||||
idris2 --build ${ipkgFileName}
|
idris2 --build ${ipkgFileName}
|
||||||
runHook postBuild
|
runHook postBuild
|
||||||
'';
|
'';
|
||||||
|
|
||||||
passthru = {
|
passthru = {
|
||||||
inherit propagatedIdrisLibraries;
|
inherit propagatedIdrisLibraries;
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
in rec {
|
shellHook = ''
|
||||||
executable = stdenv.mkDerivation (sharedAttrs //
|
export IDRIS2_PACKAGE_PATH="${finalAttrs.IDRIS2_PACKAGE_PATH}"
|
||||||
{ 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 : ${lib.makeLibraryPath [ support ]} \
|
|
||||||
--prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath [ support ]}
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
in rec {
|
||||||
|
executable = derivation.overrideAttrs {
|
||||||
|
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 : ${lib.makeLibraryPath [ support ]} \
|
||||||
|
--prefix DYLD_LIBRARY_PATH : ${lib.makeLibraryPath [ support ]}
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
runHook postInstall
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
library = { withSource ? false }:
|
library = { withSource ? false }:
|
||||||
let installCmd = if withSource then "--install-with-src" else "--install";
|
let installCmd = if withSource then "--install-with-src" else "--install";
|
||||||
in stdenv.mkDerivation (sharedAttrs //
|
in derivation.overrideAttrs {
|
||||||
{ installPhase = ''
|
installPhase = ''
|
||||||
runHook preInstall
|
runHook preInstall
|
||||||
mkdir -p $out/${libSuffix}
|
mkdir -p $out/${libSuffix}
|
||||||
export IDRIS2_PREFIX=$out/lib
|
export IDRIS2_PREFIX=$out/lib
|
||||||
idris2 ${installCmd} ${ipkgFileName}
|
idris2 ${installCmd} ${ipkgFileName}
|
||||||
runHook postInstall
|
runHook postInstall
|
||||||
'';
|
'';
|
||||||
}
|
};
|
||||||
);
|
|
||||||
# deprecated aliases:
|
# deprecated aliases:
|
||||||
build = lib.warn "build is a deprecated alias for 'executable'." executable;
|
build = lib.warn "build is a deprecated alias for 'executable'." executable;
|
||||||
installLibrary = lib.warn "installLibrary is a deprecated alias for 'library { }'." (library { });
|
installLibrary = lib.warn "installLibrary is a deprecated alias for 'library { }'." (library { });
|
||||||
|
Loading…
Reference in New Issue
Block a user