Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
at release-18.03 95 lines 3.7 kB view raw
1{ stdenv, fetchurl, fetchFromGitHub, glib, glibc, git, 2 rlwrap, curl, pkgconfig, perl, makeWrapper, tzdata, ncurses, 3 libX11, pango, cairo, gtk2, gdk_pixbuf, gtkglext, 4 libGLU, libXmu, libXt, libICE, libSM }: 5 6stdenv.mkDerivation rec { 7 name = "factor-lang-${version}"; 8 version = "0.97"; 9 rev = "eb3ca179740e6cfba696b55a999caa13369e6182"; 10 11 src = fetchFromGitHub { 12 owner = "factor"; 13 repo = "factor"; 14 rev = rev; 15 sha256 = "16zlbxbad3d19jq01nk824i19bypqzn8l3yfxys40z06vjjncapd"; 16 }; 17 18 factorimage = fetchurl { 19 url = http://downloads.factorcode.org/releases/0.97/factor-linux-x86-64-0.97.tar.gz; 20 sha256 = "06y125c8vbng54my5fxdr3crpxkvhhcng2n35cxddd3wcg6vhxhp"; 21 name = "factorimage"; 22 }; 23 24 nativeBuildInputs = [ pkgconfig ]; 25 buildInputs = [ git rlwrap curl perl makeWrapper 26 libX11 pango cairo gtk2 gdk_pixbuf gtkglext 27 libGLU libXmu libXt libICE libSM ]; 28 29 buildPhase = '' 30 make $(bash ./build-support/factor.sh make-target) GIT_LABEL=heads/master-${rev} 31 ''; 32 33 installPhase = '' 34 mkdir -p $out/bin $out/lib/factor 35 # First, get a workable image. Unfortunately, no boot-image 36 # is available with release info. So fetch a released image. 37 # The released image has library path info embedded, so we 38 # have to first recreate the boot image with Nix paths, and 39 # then use it to build the Nix release image. 40 zcat ${factorimage} | (cd $out/lib && tar -xvpf - factor/factor.image ) 41 42 cp -r basis core extra unmaintained $out/lib/factor 43 44 # Factor uses the home directory for cache during compilation. 45 # We cant have that. So set it to $TMPDIR/.home 46 export HOME=$TMPDIR/.home && mkdir -p $HOME 47 48 # there is no ld.so.cache in NixOS so we construct one 49 # out of known libraries. The side effect is that find-lib 50 # will work only on the known libraries. There does not seem 51 # to be a generic solution here. 52 find $(echo ${stdenv.lib.makeLibraryPath [ 53 glib libX11 pango cairo gtk2 gdk_pixbuf gtkglext 54 libGLU libXmu libXt libICE libSM ]} | sed -e 's#:# #g') -name \*.so.\* > $TMPDIR/so.lst 55 56 (echo $(cat $TMPDIR/so.lst | wc -l) "libs found in cache \`/etc/ld.so.cache'"; 57 for l in $(<$TMPDIR/so.lst); 58 do 59 echo " $(basename $l) (libc6,x86-64) => $l"; 60 done)> $out/lib/factor/ld.so.cache 61 62 sed -ie "s#/sbin/ldconfig -p#cat $out/lib/factor/ld.so.cache#g" \ 63 $out/lib/factor/basis/alien/libraries/finder/linux/linux.factor 64 65 sed -ie 's#/usr/share/zoneinfo/#${tzdata}/share/zoneinfo/#g' \ 66 $out/lib/factor/extra/tzinfo/tzinfo.factor 67 68 sed -ie 's#/usr/share/terminfo#${ncurses.out}/share/terminfo#g' \ 69 $out/lib/factor/extra/terminfo/terminfo.factor 70 71 cp ./factor $out/bin 72 wrapProgram $out/bin/factor --prefix LD_LIBRARY_PATH : \ 73 "${stdenv.lib.makeLibraryPath [ glib 74 libX11 pango cairo gtk2 gdk_pixbuf gtkglext 75 libGLU libXmu libXt libICE libSM ]}" 76 77 sed -ie 's#/bin/.factor-wrapped#/lib/factor/factor#g' $out/bin/factor 78 mv $out/bin/.factor-wrapped $out/lib/factor/factor 79 80 # make a new bootstrap image 81 (cd $out/bin && ./factor -script -e='"unix-x86.64" USING: system bootstrap.image memory ; make-image save 0 exit' ) 82 mv $out/lib/factor/boot.unix-x86.64.image $out/lib/factor/factor.image 83 # now make the full system image, it overwrites $out/lib/factor/factor.image 84 $out/bin/factor -i=$out/lib/factor/factor.image 85 ''; 86 87 meta = with stdenv.lib; { 88 homepage = http://factorcode.org; 89 license = licenses.bsd2; 90 description = "A concatenative, stack-based programming language"; 91 92 maintainers = [ maintainers.vrthra ]; 93 platforms = [ "x86_64-linux" ]; 94 }; 95}