2021-01-22 12:25:31 +01:00
|
|
|
{ lib, stdenv, fetchurl, glib, git,
|
2021-01-19 07:50:56 +01:00
|
|
|
rlwrap, curl, pkg-config, perl, makeWrapper, tzdata, ncurses,
|
2019-05-22 13:03:39 +02:00
|
|
|
pango, cairo, gtk2, gdk-pixbuf, gtkglext,
|
2018-10-20 02:38:49 +02:00
|
|
|
mesa, xorg, openssl, unzip }:
|
2016-06-08 07:47:33 +02:00
|
|
|
|
2019-06-16 21:59:06 +02:00
|
|
|
stdenv.mkDerivation rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "factor-lang";
|
2018-10-20 02:38:49 +02:00
|
|
|
version = "0.98";
|
|
|
|
rev = "7999e72aecc3c5bc4019d43dc4697f49678cc3b4";
|
2016-06-08 07:47:33 +02:00
|
|
|
|
2018-10-20 02:38:49 +02:00
|
|
|
src = fetchurl {
|
2020-04-01 03:11:51 +02:00
|
|
|
url = "https://downloads.factorcode.org/releases/0.98/factor-src-0.98.zip";
|
2018-10-20 02:38:49 +02:00
|
|
|
sha256 = "01ip9mbnar4sv60d2wcwfz62qaamdvbykxw3gbhzqa25z36vi3ri";
|
2016-06-08 07:47:33 +02:00
|
|
|
};
|
|
|
|
|
2018-10-20 02:38:49 +02:00
|
|
|
patches = [
|
|
|
|
./staging-command-line-0.98-pre.patch
|
|
|
|
./workdir-0.98-pre.patch
|
|
|
|
./fuel-dir.patch
|
|
|
|
];
|
|
|
|
|
2021-02-20 22:01:53 +01:00
|
|
|
nativeBuildInputs = [ makeWrapper unzip ];
|
2021-02-07 10:17:39 +01:00
|
|
|
buildInputs = with xorg; [ git rlwrap curl pkg-config perl
|
2019-05-22 13:03:39 +02:00
|
|
|
libX11 pango cairo gtk2 gdk-pixbuf gtkglext
|
2021-02-20 22:01:53 +01:00
|
|
|
mesa libXmu libXt libICE libSM openssl ];
|
2016-06-08 07:47:33 +02:00
|
|
|
|
|
|
|
buildPhase = ''
|
2018-10-20 02:38:49 +02:00
|
|
|
sed -ie '4i GIT_LABEL = heads/master-${rev}' GNUmakefile
|
|
|
|
make linux-x86-64
|
|
|
|
# De-memoize xdg-* functions, otherwise they break the image.
|
|
|
|
sed -ie 's/^MEMO:/:/' basis/xdg/xdg.factor
|
2016-06-08 07:47:33 +02:00
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir -p $out/bin $out/lib/factor
|
|
|
|
# The released image has library path info embedded, so we
|
2018-10-20 02:38:49 +02:00
|
|
|
# first have to recreate the boot image with Nix paths, and
|
2016-06-08 07:47:33 +02:00
|
|
|
# then use it to build the Nix release image.
|
2018-10-20 02:38:49 +02:00
|
|
|
cp boot.unix-x86.64.image $out/lib/factor/factor.image
|
2016-06-08 07:47:33 +02:00
|
|
|
|
2018-10-20 02:38:49 +02:00
|
|
|
cp -r basis core extra $out/lib/factor
|
2016-06-08 07:47:33 +02:00
|
|
|
|
2018-10-20 02:38:49 +02:00
|
|
|
# Factor uses XDG_CACHE_HOME for cache during compilation.
|
|
|
|
# We can't have that. So set it to $TMPDIR/.cache
|
|
|
|
export XDG_CACHE_HOME=$TMPDIR/.cache && mkdir -p $XDG_CACHE_HOME
|
2016-06-08 07:47:33 +02:00
|
|
|
|
2018-10-20 02:38:49 +02:00
|
|
|
# There is no ld.so.cache in NixOS so we construct one
|
2016-06-08 07:47:33 +02:00
|
|
|
# out of known libraries. The side effect is that find-lib
|
|
|
|
# will work only on the known libraries. There does not seem
|
|
|
|
# to be a generic solution here.
|
2021-01-22 12:25:31 +01:00
|
|
|
find $(echo ${lib.makeLibraryPath (with xorg; [
|
2019-05-22 13:03:39 +02:00
|
|
|
glib libX11 pango cairo gtk2 gdk-pixbuf gtkglext
|
2018-10-20 02:38:49 +02:00
|
|
|
mesa libXmu libXt libICE libSM ])} | sed -e 's#:# #g') -name \*.so.\* > $TMPDIR/so.lst
|
2016-06-08 07:47:33 +02:00
|
|
|
|
|
|
|
(echo $(cat $TMPDIR/so.lst | wc -l) "libs found in cache \`/etc/ld.so.cache'";
|
|
|
|
for l in $(<$TMPDIR/so.lst);
|
|
|
|
do
|
|
|
|
echo " $(basename $l) (libc6,x86-64) => $l";
|
|
|
|
done)> $out/lib/factor/ld.so.cache
|
|
|
|
|
|
|
|
sed -ie "s#/sbin/ldconfig -p#cat $out/lib/factor/ld.so.cache#g" \
|
|
|
|
$out/lib/factor/basis/alien/libraries/finder/linux/linux.factor
|
|
|
|
|
|
|
|
sed -ie 's#/usr/share/zoneinfo/#${tzdata}/share/zoneinfo/#g' \
|
|
|
|
$out/lib/factor/extra/tzinfo/tzinfo.factor
|
|
|
|
|
2016-08-23 03:36:40 +02:00
|
|
|
sed -ie 's#/usr/share/terminfo#${ncurses.out}/share/terminfo#g' \
|
2016-06-08 07:47:33 +02:00
|
|
|
$out/lib/factor/extra/terminfo/terminfo.factor
|
|
|
|
|
|
|
|
cp ./factor $out/bin
|
|
|
|
wrapProgram $out/bin/factor --prefix LD_LIBRARY_PATH : \
|
2021-01-22 12:25:31 +01:00
|
|
|
"${lib.makeLibraryPath (with xorg; [ glib
|
2019-05-22 13:03:39 +02:00
|
|
|
libX11 pango cairo gtk2 gdk-pixbuf gtkglext
|
2018-10-20 02:38:49 +02:00
|
|
|
mesa libXmu libXt libICE libSM openssl])}"
|
2016-06-08 07:47:33 +02:00
|
|
|
|
|
|
|
sed -ie 's#/bin/.factor-wrapped#/lib/factor/factor#g' $out/bin/factor
|
|
|
|
mv $out/bin/.factor-wrapped $out/lib/factor/factor
|
|
|
|
|
2018-10-20 02:38:49 +02:00
|
|
|
# build full factor image from boot image
|
2016-06-08 07:47:33 +02:00
|
|
|
(cd $out/bin && ./factor -script -e='"unix-x86.64" USING: system bootstrap.image memory ; make-image save 0 exit' )
|
2018-10-20 02:38:49 +02:00
|
|
|
|
|
|
|
# make a new bootstrap image
|
|
|
|
(cd $out/bin && ./factor -script -e='"unix-x86.64" USING: system tools.deploy.backend ; make-boot-image 0 exit' )
|
|
|
|
|
|
|
|
# rebuild final full factor image to include all patched sources
|
|
|
|
(cd $out/lib/factor && ./factor -i=boot.unix-x86.64.image)
|
|
|
|
|
|
|
|
# install fuel mode for emacs
|
|
|
|
mkdir -p $out/share/emacs/site-lisp
|
|
|
|
# update default paths in factor-listener.el for fuel mode
|
|
|
|
substituteInPlace misc/fuel/fuel-listener.el \
|
|
|
|
--subst-var-by fuel_factor_root_dir $out/lib/factor \
|
|
|
|
--subst-var-by fuel_listener_factor_binary $out/bin/factor
|
|
|
|
cp misc/fuel/*.el $out/share/emacs/site-lisp/
|
2016-06-08 07:47:33 +02:00
|
|
|
'';
|
|
|
|
|
2021-01-22 12:25:31 +01:00
|
|
|
meta = with lib; {
|
2020-04-01 03:11:51 +02:00
|
|
|
homepage = "https://factorcode.org";
|
2016-06-08 07:47:33 +02:00
|
|
|
license = licenses.bsd2;
|
|
|
|
description = "A concatenative, stack-based programming language";
|
|
|
|
|
2018-10-20 02:38:49 +02:00
|
|
|
maintainers = [ maintainers.vrthra maintainers.spacefrogg ];
|
2016-06-09 13:19:00 +02:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2016-06-08 07:47:33 +02:00
|
|
|
};
|
|
|
|
}
|