1
0
Fork 1
mirror of https://github.com/NixOS/nixpkgs.git synced 2024-11-25 15:11:35 +00:00
nixpkgs/pkgs/development/idris-modules/with-packages.nix

47 lines
1 KiB
Nix
Raw Normal View History

2015-11-27 18:17:17 +00:00
# Build a version of idris with a set of packages visible
# packages: The packages visible to idris
{ stdenv, idris }: packages: stdenv.mkDerivation {
2015-11-27 12:56:11 +00:00
inherit (idris) name;
2015-11-27 18:17:17 +00:00
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
}
envHostTargetHooks+=(installIdrisLib)
'';
2015-11-27 12:56:11 +00:00
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
2015-11-27 12:56:11 +00:00
'';
installPhase = ''
mkdir -p $out/bin
mv idris $out/bin
'';
stripAllList = [ "bin" ];
}