parent
9e70e9f732
commit
4f5daac94e
|
@ -0,0 +1,31 @@
|
|||
From da8a4b9c1094a568f443c525ca1ce11f686be1bc Mon Sep 17 00:00:00 2001
|
||||
From: timor <timor.dd@googlemail.com>
|
||||
Date: Thu, 8 Aug 2019 14:13:09 +0200
|
||||
Subject: [PATCH] adjust unit test for finding executables in path for NixOS
|
||||
|
||||
---
|
||||
basis/io/standard-paths/unix/unix-tests.factor | 4 ++--
|
||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
||||
|
||||
diff --git a/basis/io/standard-paths/unix/unix-tests.factor b/basis/io/standard-paths/unix/unix-tests.factor
|
||||
index 986c0564d2..f0772fdcc9 100644
|
||||
--- a/basis/io/standard-paths/unix/unix-tests.factor
|
||||
+++ b/basis/io/standard-paths/unix/unix-tests.factor
|
||||
@@ -5,12 +5,12 @@ sequences tools.test ;
|
||||
|
||||
{ f } [ "" find-in-path ] unit-test
|
||||
{ t } [
|
||||
- "ls" find-in-path { "/bin/ls" "/usr/bin/ls" } member?
|
||||
+ "ls" find-in-path not not
|
||||
] unit-test
|
||||
|
||||
{ t } [
|
||||
"/sbin:" "PATH" os-env append "PATH" [
|
||||
"ps" find-in-path
|
||||
- { "/bin/ps" "/sbin/ps" "/usr/bin/ps" } member?
|
||||
+ not not
|
||||
] with-os-env
|
||||
] unit-test
|
||||
--
|
||||
2.19.2
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
{ lib, stdenv, fetchurl, glib, git,
|
||||
rlwrap, curl, pkg-config, perl, makeWrapper, tzdata, ncurses,
|
||||
pango, cairo, gtk2, gdk-pixbuf, gtkglext,
|
||||
mesa, xorg, openssl, unzip }:
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "factor-lang";
|
||||
version = "0.98";
|
||||
rev = "7999e72aecc3c5bc4019d43dc4697f49678cc3b4";
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://downloads.factorcode.org/releases/0.98/factor-src-0.98.zip";
|
||||
sha256 = "01ip9mbnar4sv60d2wcwfz62qaamdvbykxw3gbhzqa25z36vi3ri";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./staging-command-line-0.98-pre.patch
|
||||
./workdir-0.98-pre.patch
|
||||
./fuel-dir.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ makeWrapper unzip ];
|
||||
buildInputs = with xorg; [ git rlwrap curl pkg-config perl
|
||||
libX11 pango cairo gtk2 gdk-pixbuf gtkglext
|
||||
mesa libXmu libXt libICE libSM openssl ];
|
||||
|
||||
buildPhase = ''
|
||||
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
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin $out/lib/factor
|
||||
# The released image has library path info embedded, so we
|
||||
# first have to recreate the boot image with Nix paths, and
|
||||
# then use it to build the Nix release image.
|
||||
cp boot.unix-x86.64.image $out/lib/factor/factor.image
|
||||
|
||||
cp -r basis core extra $out/lib/factor
|
||||
|
||||
# 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
|
||||
|
||||
# There is no ld.so.cache in NixOS so we construct one
|
||||
# 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.
|
||||
find $(echo ${lib.makeLibraryPath (with xorg; [
|
||||
glib libX11 pango cairo gtk2 gdk-pixbuf gtkglext
|
||||
mesa libXmu libXt libICE libSM ])} | sed -e 's#:# #g') -name \*.so.\* > $TMPDIR/so.lst
|
||||
|
||||
(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
|
||||
|
||||
sed -ie 's#/usr/share/terminfo#${ncurses.out}/share/terminfo#g' \
|
||||
$out/lib/factor/extra/terminfo/terminfo.factor
|
||||
|
||||
cp ./factor $out/bin
|
||||
wrapProgram $out/bin/factor --prefix LD_LIBRARY_PATH : \
|
||||
"${lib.makeLibraryPath (with xorg; [ glib
|
||||
libX11 pango cairo gtk2 gdk-pixbuf gtkglext
|
||||
mesa libXmu libXt libICE libSM openssl])}"
|
||||
|
||||
sed -ie 's#/bin/.factor-wrapped#/lib/factor/factor#g' $out/bin/factor
|
||||
mv $out/bin/.factor-wrapped $out/lib/factor/factor
|
||||
|
||||
# build full factor image from boot image
|
||||
(cd $out/bin && ./factor -script -e='"unix-x86.64" USING: system bootstrap.image memory ; make-image save 0 exit' )
|
||||
|
||||
# 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/
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://factorcode.org";
|
||||
license = licenses.bsd2;
|
||||
description = "A concatenative, stack-based programming language";
|
||||
|
||||
maintainers = [ maintainers.vrthra maintainers.spacefrogg ];
|
||||
platforms = [ "x86_64-linux" ];
|
||||
};
|
||||
}
|
205
pkgs/development/compilers/factor-lang/factor98.nix
Normal file
205
pkgs/development/compilers/factor-lang/factor98.nix
Normal file
|
@ -0,0 +1,205 @@
|
|||
{ stdenv
|
||||
, lib
|
||||
, git
|
||||
, curl
|
||||
, makeWrapper
|
||||
, runtimeShell
|
||||
, fetchurl
|
||||
, unzip
|
||||
, runCommand
|
||||
, writeScriptBin
|
||||
, interpreter
|
||||
, glib
|
||||
, pango
|
||||
, cairo
|
||||
, gtk2-x11
|
||||
, gdk-pixbuf
|
||||
, gnome2
|
||||
, pcre
|
||||
, libGL
|
||||
, libGLU
|
||||
, freealut
|
||||
, openssl
|
||||
, udis86
|
||||
, openal
|
||||
, libogg
|
||||
, libvorbis
|
||||
, graphviz
|
||||
, librsvg
|
||||
, zlib
|
||||
, tzdata
|
||||
, ncurses
|
||||
}:
|
||||
let
|
||||
runtimeLibs = [
|
||||
glib
|
||||
pango
|
||||
cairo
|
||||
gtk2-x11
|
||||
gdk-pixbuf
|
||||
gnome2.gtkglext
|
||||
pcre
|
||||
libGL
|
||||
libGLU
|
||||
freealut
|
||||
openssl
|
||||
udis86
|
||||
openal
|
||||
libogg
|
||||
libvorbis
|
||||
graphviz
|
||||
zlib
|
||||
];
|
||||
|
||||
wrapFactorScript = { from, to ? false, runtimeLibs }: ''
|
||||
# Set Gdk pixbuf loaders file to the one from the build dependencies here
|
||||
unset GDK_PIXBUF_MODULE_FILE
|
||||
# Defined in gdk-pixbuf setup hook
|
||||
findGdkPixbufLoaders "${librsvg}"
|
||||
|
||||
${if to then "makeWrapper ${from} ${to}" else "wrapProgram ${from}"} \
|
||||
--set GDK_PIXBUF_MODULE_FILE "$GDK_PIXBUF_MODULE_FILE" \
|
||||
--argv0 factor \
|
||||
--prefix LD_LIBRARY_PATH : /run/opengl-driver/lib:${lib.makeLibraryPath runtimeLibs} \
|
||||
--prefix PATH : ${lib.makeBinPath [ graphviz ]}
|
||||
'';
|
||||
|
||||
wrapFactor = runtimeLibs:
|
||||
runCommand (lib.appendToName "with-libs" interpreter).name
|
||||
{
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
buildInputs = [ gdk-pixbuf ];
|
||||
passthru.runtimeLibs = runtimeLibs ++ interpreter.runtimeLibs;
|
||||
}
|
||||
(wrapFactorScript {
|
||||
from = "${interpreter}/lib/factor/.factor.wrapped";
|
||||
to = "$out/bin/factor";
|
||||
runtimeLibs = (runtimeLibs ++ interpreter.runtimeLibs);
|
||||
});
|
||||
|
||||
# Development helper for use in nix shell
|
||||
wrapLocalFactor = writeScriptBin "wrapFactor" ''
|
||||
#!${runtimeShell}
|
||||
${wrapFactorScript { from = "./factor"; inherit runtimeLibs; }}
|
||||
ln -sf factor.image .factor-wrapped.image
|
||||
'';
|
||||
rev = "7999e72aecc3c5bc4019d43dc4697f49678cc3b4";
|
||||
version = "0.98";
|
||||
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "factor-lang";
|
||||
inherit version;
|
||||
|
||||
src = fetchurl {
|
||||
url = "https://downloads.factorcode.org/releases/${version}/factor-src-${version}.zip";
|
||||
sha256 = "01ip9mbnar4sv60d2wcwfz62qaamdvbykxw3gbhzqa25z36vi3ri";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./staging-command-line-0.98-pre.patch
|
||||
./workdir-0.98-pre.patch
|
||||
./adjust-paths-in-unit-tests.patch
|
||||
];
|
||||
|
||||
nativeBuildInputs = [ git makeWrapper curl unzip wrapLocalFactor ];
|
||||
buildInputs = runtimeLibs;
|
||||
|
||||
postPatch = ''
|
||||
sed -ie '4i GIT_LABEL = heads/master-${rev}' GNUmakefile
|
||||
|
||||
# There is no ld.so.cache in NixOS so we patch out calls to that completely.
|
||||
# This should work as long as no application code relies on `find-library*`
|
||||
# to return a match, which currently is the case and also a justified assumption.
|
||||
|
||||
sed -ie "s#/sbin/ldconfig -p#cat $out/lib/factor/ld.so.cache#g" \
|
||||
basis/alien/libraries/finder/linux/linux.factor
|
||||
|
||||
# Some other hard-coded paths to fix:
|
||||
sed -i 's#/usr/share/zoneinfo/#${tzdata}/share/zoneinfo/#g' \
|
||||
extra/tzinfo/tzinfo.factor
|
||||
|
||||
sed -i 's#/usr/share/terminfo#${ncurses.out}/share/terminfo#g' \
|
||||
extra/terminfo/terminfo.factor
|
||||
|
||||
# De-memoize xdg-* functions, otherwise they break the image.
|
||||
sed -ie 's/^MEMO:/:/' basis/xdg/xdg.factor
|
||||
|
||||
# update default paths in factor-listener.el for fuel mode
|
||||
substituteInPlace misc/fuel/fuel-listener.el \
|
||||
--replace '(defcustom fuel-factor-root-dir nil' "(defcustom fuel-factor-root-dir \"$out/lib/factor\""
|
||||
'';
|
||||
|
||||
buildPhase = ''
|
||||
runHook preBuild
|
||||
# Necessary here, because ld.so.cache is needed in its final location during rebuild.
|
||||
mkdir -p $out/bin $out/lib/factor
|
||||
patchShebangs ./build.sh
|
||||
# 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
|
||||
|
||||
# There is no ld.so.cache in NixOS so we construct one
|
||||
# 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.
|
||||
find $(echo ${lib.makeLibraryPath runtimeLibs} | sed -e 's#:# #g') -name \*.so.\* > $TMPDIR/so.lst
|
||||
(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
|
||||
|
||||
make -j$NIX_BUILD_CORES linux-x86-64
|
||||
./build.sh bootstrap
|
||||
runHook postBuild
|
||||
'';
|
||||
|
||||
# For now, the check phase runs, but should always return 0. This way the
|
||||
# logs contain the test failures until all unit tests are fixed. Then, it
|
||||
# should return 1 if any test failures have occured.
|
||||
doCheck = false;
|
||||
checkPhase = ''
|
||||
runHook preCheck
|
||||
set +e
|
||||
./factor -e='USING: tools.test zealot.factor sequences namespaces formatting ;
|
||||
zealot-core-vocabs "compiler" suffix [ test ] each :test-failures
|
||||
test-failures get length "Number of failed Tests: %d\n" printf'
|
||||
[ $? -eq 0 ] || {
|
||||
mkdir -p "$out/nix-support"
|
||||
touch "$out/nix-support/failed"
|
||||
}
|
||||
set -e
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
cp -r factor factor.image LICENSE.txt README.md basis core extra misc $out/lib/factor
|
||||
|
||||
# Create a wrapper in bin/ and lib/factor/
|
||||
${wrapFactorScript { from = "$out/lib/factor/factor"; inherit runtimeLibs; }}
|
||||
mv $out/lib/factor/factor.image $out/lib/factor/.factor-wrapped.image
|
||||
cp $out/lib/factor/factor $out/bin/
|
||||
|
||||
# Emacs fuel expects the image being named `factor.image` in the factor base dir
|
||||
ln -s $out/lib/factor/.factor-wrapped.image $out/lib/factor/factor.image
|
||||
|
||||
# install fuel mode for emacs
|
||||
mkdir -p $out/share/emacs/site-lisp
|
||||
ln -s $out/lib/factor/misc/fuel/*.el $out/share/emacs/site-lisp/
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
inherit runtimeLibs wrapFactorScript;
|
||||
withLibs = wrapFactor;
|
||||
};
|
||||
|
||||
meta = with lib; {
|
||||
homepage = http://factorcode.org;
|
||||
license = licenses.bsd2;
|
||||
description = "A concatenative, stack-based programming language";
|
||||
maintainers = with maintainers; [ vrthra spacefrogg ];
|
||||
platforms = lib.intersectLists platforms.x86_64 platforms.linux;
|
||||
};
|
||||
}
|
|
@ -1,20 +0,0 @@
|
|||
diff --git a/misc/fuel/fuel-listener.el b/misc/fuel/fuel-listener.el
|
||||
index 2d1b182a75..bf2e573425 100644
|
||||
--- a/misc/fuel/fuel-listener.el
|
||||
+++ b/misc/fuel/fuel-listener.el
|
||||
@@ -30,13 +30,13 @@
|
||||
"Interacting with a Factor listener inside Emacs."
|
||||
:group 'fuel)
|
||||
|
||||
-(defcustom fuel-factor-root-dir nil
|
||||
+(defcustom fuel-factor-root-dir "@fuel_factor_root_dir@"
|
||||
"Full path to the factor root directory when starting a listener."
|
||||
:type 'directory
|
||||
:group 'fuel-listener)
|
||||
|
||||
;;; Is factor.com still valid on Windows...?
|
||||
-(defcustom fuel-listener-factor-binary nil
|
||||
+(defcustom fuel-listener-factor-binary "@fuel_listener_factor_binary@"
|
||||
"Full path to the factor executable to use when starting a listener."
|
||||
:type '(file :must-match t)
|
||||
:group 'fuel-listener)
|
16
pkgs/development/compilers/factor-lang/scope.nix
Normal file
16
pkgs/development/compilers/factor-lang/scope.nix
Normal file
|
@ -0,0 +1,16 @@
|
|||
{ lib, pkgs
|
||||
, overrides ? (self: super: {})}:
|
||||
|
||||
let
|
||||
inside = (self:
|
||||
let callPackage = pkgs.newScope self;
|
||||
in rec {
|
||||
interpreter = callPackage ./factor98.nix { inherit (pkgs) stdenv; };
|
||||
|
||||
# Convenience access for using the returned attribute the same way as the
|
||||
# interpreter derivation. Takes a list of runtime libraries as its only
|
||||
# argument.
|
||||
inherit (self.interpreter) withLibs;
|
||||
});
|
||||
extensible-self = lib.makeExtensible (lib.extends overrides inside);
|
||||
in extensible-self
|
|
@ -16025,9 +16025,8 @@ with pkgs;
|
|||
|
||||
faad2 = callPackage ../development/libraries/faad2 { };
|
||||
|
||||
factor-lang = callPackage ../development/compilers/factor-lang {
|
||||
inherit (gnome2) gtkglext;
|
||||
};
|
||||
factor-lang-scope = callPackage ../development/compilers/factor-lang/scope.nix { };
|
||||
factor-lang = factor-lang-scope.interpreter;
|
||||
|
||||
far2l = callPackage ../applications/misc/far2l {
|
||||
stdenv = if stdenv.cc.isClang then llvmPackages.stdenv else stdenv;
|
||||
|
|
Loading…
Reference in a new issue