Skip to content

Commit

Permalink
idris: Move library setup to the setup hook.
Browse files Browse the repository at this point in the history
This was broken in preHook because addEnvHooks isn't defined yet.
  • Loading branch information
shlevy committed Jan 21, 2018
1 parent 58ff18b commit 69d4ade
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
27 changes: 4 additions & 23 deletions pkgs/development/idris-modules/build-idris-package.nix
Expand Up @@ -3,40 +3,21 @@
# args: Additional arguments to pass to mkDerivation. Generally should include at least
# name and src.
{ stdenv, idris, gmp }: args: stdenv.mkDerivation ({
preHook = ''
# Library import path
export IDRIS_LIBRARY_PATH=$PWD/idris-libs
mkdir -p $IDRIS_LIBRARY_PATH
# Library install path
export IBCSUBDIR=$out/lib/${idris.name}
mkdir -p $IBCSUBDIR
addIdrisLibs () {
if [ -d $1/lib/${idris.name} ]; then
ln -sv $1/lib/${idris.name}/* $IDRIS_LIBRARY_PATH
fi
}
# All run-time deps
addEnvHooks 0 addIdrisLibs
'';

buildPhase = ''
${idris}/bin/idris --build *.ipkg
idris --build *.ipkg
'';

doCheck = true;

checkPhase = ''
if grep -q test *.ipkg; then
${idris}/bin/idris --testpkg *.ipkg
idris --testpkg *.ipkg
fi
'';

installPhase = ''
${idris}/bin/idris --install *.ipkg --ibcsubdir $IBCSUBDIR
idris --install *.ipkg --ibcsubdir $IBCSUBDIR
'';

buildInputs = [ gmp ];
buildInputs = [ gmp idris ];
} // args)
3 changes: 3 additions & 0 deletions pkgs/development/idris-modules/idris-wrapper.nix
Expand Up @@ -9,6 +9,9 @@ symlinkJoin {
wrapProgram $out/bin/idris \
--suffix PATH : ${ stdenv.lib.makeBinPath path } \
--suffix LIBRARY_PATH : ${stdenv.lib.makeLibraryPath lib}
mkdir -p $out/nix-support
substituteAll ${./setup-hook.sh} $out/nix-support/setup-hook
'';
}

16 changes: 16 additions & 0 deletions pkgs/development/idris-modules/setup-hook.sh
@@ -0,0 +1,16 @@
# Library import path
export IDRIS_LIBRARY_PATH=$PWD/idris-libs
mkdir -p $IDRIS_LIBRARY_PATH

# Library install path
export IBCSUBDIR=$out/lib/@name@
mkdir -p $IBCSUBDIR

addIdrisLibs () {
if [ -d $1/lib/@name@ ]; then
ln -sv $1/lib/@name@/* $IDRIS_LIBRARY_PATH
fi
}

# All run-time deps
addEnvHooks 1 addIdrisLibs

2 comments on commit 69d4ade

@shlevy
Copy link
Member Author

@shlevy shlevy commented on 69d4ade Jan 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ericson2314 Is it intentional that addEnvHooks is defined after preHook is run?

@Ericson2314
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No it is not. Meant to make a mass rebuild about this but didn't yet.

Please sign in to comment.