nixpkgs/pkgs/development/idris-modules/with-packages.nix
Matthew Pickering b8a7c455f6 Fix idrisPackages.with-packages
1. The ln step was failing due to a file already existing
2. gcc was invoked directly which caused failure on OS X.
2017-10-30 12:25:33 +01:00

47 lines
1.0 KiB
Nix

# Build a version of idris with a set of packages visible
# packages: The packages visible to idris
{ stdenv, idris }: packages: stdenv.mkDerivation {
inherit (idris) name;
buildInputs = packages;
preHook = ''
mkdir -p $out/lib/${idris.name}
installIdrisLib () {
if [ -d $1/lib/${idris.name} ]; then
ln -fsv $1/lib/${idris.name}/* $out/lib/${idris.name}
fi
}
envHooks+=(installIdrisLib)
'';
unpackPhase = ''
cat >idris.c <<EOF
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
int main (int argc, char ** argv) {
/* idris currently only supports a single library path, so respect it if the user set it */
setenv("IDRIS_LIBRARY_PATH", "$out/lib/${idris.name}", 0);
execv("${idris}/bin/idris", argv);
perror("executing ${idris}/bin/idris");
return 127;
}
EOF
'';
buildPhase = ''
$CC -O3 -o idris idris.c
'';
installPhase = ''
mkdir -p $out/bin
mv idris $out/bin
'';
stripAllList = [ "bin" ];
}