Add factor-lang from pdconfig

master
Michael Raitza 2020-12-06 13:31:05 +01:00
parent 56a686a071
commit d5adb9f392
7 changed files with 287 additions and 3 deletions

View File

@ -31,9 +31,9 @@ let
# l3pp = callPackage ./l3pp { };
# mathsat = callPackage ./mathsat { };
foxitreader = callPackage ./foxitreader.nix { openssl = super.openssl_1_0_2; };
# Used to run diskover file crawler
rq = callPackage ./rq { };
factor-lang = callPackage ./factor-lang/scope.nix { };
foxitreader = callPackage ./foxitreader.nix { openssl = prev.openssl_1_0_2; };
pharo-with-libs = callPackage ./pharo.nix { libgit2_32 = prev.pkgsi686Linux.libgit2; };

View File

@ -0,0 +1,33 @@
From 812d79ccfa1d702afc12561aa8c05a9b4a158620 Mon Sep 17 00:00:00 2001
From: timor <timor.dd@googlemail.com>
Date: Thu, 7 Mar 2019 13:49:41 +0100
Subject: [PATCH] pathnames: redirect "work" prefix to ~/.local/share/factor
---
core/io/pathnames/pathnames.factor | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/core/io/pathnames/pathnames.factor b/core/io/pathnames/pathnames.factor
index d1aed3ad82..6104a0c94b 100644
--- a/core/io/pathnames/pathnames.factor
+++ b/core/io/pathnames/pathnames.factor
@@ -136,7 +136,8 @@ HOOK: resolve-symlinks os ( path -- path' )
M: object resolve-symlinks normalize-path ;
: resource-path ( path -- newpath )
- "resource-path" get prepend-path ;
+ dup "work" = [ drop "work/" ] when
+ "work/" ?head [ "~/.local/share/factor" ] [ "resource-path" get ] if prepend-path ;
HOOK: home io-backend ( -- dir )
@@ -219,4 +220,4 @@ C: <pathname> pathname
M: pathname absolute-path string>> absolute-path ;
-M: pathname <=> [ string>> ] compare ;
\ No newline at end of file
+M: pathname <=> [ string>> ] compare ;
--
2.18.1

View File

@ -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

152
factor-lang/default.nix Normal file
View File

@ -0,0 +1,152 @@
{ stdenv, lib, fetchurl, glib, git,
rlwrap, curl, pkgconfig, perl, makeWrapper, tzdata, ncurses,
pango, cairo, gtk2, gdk_pixbuf, gtkglext, pcre, openal,
mesa_glu, xorg, openssl, unzip, udis86, runCommand, interpreter,
blas, zlib }:
let
inherit (stdenv.lib) optional;
wrapFactor = runtimeLibs:
runCommand (lib.appendToName "with-libs" interpreter).name {
buildInputs = [ makeWrapper ];} ''
mkdir -p $out/bin
makeWrapper ${interpreter}/bin/factor $out/bin/factor \
--prefix LD_LIBRARY_PATH : ${lib.makeLibraryPath runtimeLibs}
'';
in
stdenv.mkDerivation rec {
name = "factor-lang-${version}";
version = "0.98";
rev = "7999e72aecc3c5bc4019d43dc4697f49678cc3b4";
src = fetchurl {
url = http://downloads.factorcode.org/releases/0.98/factor-src-0.98.zip;
sha256 = "01ip9mbnar4sv60d2wcwfz62qaamdvbykxw3gbhzqa25z36vi3ri";
};
patches = [
./staging-command-line-0.98-pre.patch
./0001-pathnames-redirect-work-prefix-to-.local-share-facto.patch
./0002-adjust-unit-test-for-finding-executables-in-path-for.patch
# preempt https://github.com/factor/factor/pull/2139
./fuel-dont-jump-to-using.patch
];
postPatch = ''
# 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.
# TODO: put stuff below into patches like above
sed -i 's#"lib" prepend load-ldconfig-cache#"lib" prepend { }#' \
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 -i 's/^MEMO:/:/' basis/xdg/xdg.factor
sed -i '4i GIT_LABEL = heads/master-${rev}' GNUmakefile
# 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\""
'';
runtimeLibs = with xorg; [
stdenv.glibc.out
glib
libX11 pango cairo gtk2 gdk_pixbuf gtkglext pcre
mesa_glu libXmu libXt libICE libSM openssl udis86
openal blas zlib
];
buildInputs = with xorg; [
git rlwrap curl pkgconfig perl makeWrapper
unzip
] ++ runtimeLibs;
runtimeLibPath = stdenv.lib.makeLibraryPath runtimeLibs;
configurePhase = "true";
buildPhase = ''
make linux-x86-64
# 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
# 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 factor.image
# Expose libraries in LD_LIBRARY_PATH for factor
export LD_LIBRARY_PATH=${lib.makeLibraryPath runtimeLibs}:$LD_LIBRARY_PATH
echo "=== Building first full image from boot image..."
# build full factor image from boot image, saving the state for the next call
./factor -script -e='"unix-x86.64" USING: system bootstrap.image memory ; make-image save 0 exit'
echo "=== Building new boot image..."
# make a new bootstrap image
./factor -script -e='"unix-x86.64" USING: system bootstrap.image ; make-image 0 exit'
echo "=== Building final full image..."
# rebuild final full factor image to include all patched sources
./factor -i=boot.unix-x86.64.image
'';
doCheck = true;
# 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.
checkPhase = ''
./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'
'';
installPhase = ''
mkdir -p $out/bin $out/lib/factor
cp -r factor factor.image LICENSE.txt README.md basis core extra misc $out/lib/factor
# Create a wrapper in bin/
wrapProgram $out/lib/factor/factor --prefix LD_LIBRARY_PATH : \
"${runtimeLibPath}"
mv $out/lib/factor/factor.image $out/lib/factor/.factor-wrapped.image
mv $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
# Create a wrapper in lib/factor
makeWrapper $out/lib/factor/.factor-wrapped $out/lib/factor/factor --prefix LD_LIBRARY_PATH : \
"${runtimeLibPath}"
# 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/
'';
meta = with stdenv.lib; {
homepage = http://factorcode.org;
license = licenses.bsd2;
description = "A concatenative, stack-based programming language";
maintainers = [ maintainers.vrthra maintainers.spacefrogg ];
platforms = [ "x86_64-linux" ];
};
passthru.withLibs = wrapFactor;
}

View File

@ -0,0 +1,40 @@
diff --git a/misc/fuel/fuel-debug.el b/misc/fuel/fuel-debug.el
index 7f9dc3ea41..0ee277ede8 100644
--- a/misc/fuel/fuel-debug.el
+++ b/misc/fuel/fuel-debug.el
@@ -308,20 +308,21 @@ the debugger."
(defun fuel-debug--replace-usings (file uses)
(pop-to-buffer (find-file-noselect file))
- (goto-char (point-min))
- (if (re-search-forward "^USING: " nil t)
- (let ((begin (point))
- (end (or (and (re-search-forward ";\\( \\|$\\)") (point))
- (point))))
- (kill-region begin end))
- (re-search-forward "^IN: " nil t)
- (beginning-of-line)
- (open-line 2)
- (insert "USING: "))
- (let ((start (point))
- (tokens (append uses '(";"))))
- (insert (mapconcat 'substring-no-properties tokens " "))
- (fill-region start (point) nil)))
+ (save-excursion
+ (goto-char (point-min))
+ (if (re-search-forward "^USING: " nil t)
+ (let ((begin (point))
+ (end (or (and (re-search-forward ";\\( \\|$\\)") (point))
+ (point))))
+ (kill-region begin end))
+ (re-search-forward "^IN: " nil t)
+ (beginning-of-line)
+ (open-line 2)
+ (insert "USING: "))
+ (let ((start (point))
+ (tokens (append uses '(";"))))
+ (insert (mapconcat 'substring-no-properties tokens " "))
+ (fill-region start (point) nil))))
(defun fuel-debug-update-usings ()
(interactive)

15
factor-lang/scope.nix Normal file
View File

@ -0,0 +1,15 @@
{ stdenv, pkgs, lib, gnome2,
overrides ? (self: super: {})}:
let
inside = (self:
let callPackage = pkgs.newScope self ;
in rec {
recurseForDerivations = true;
interpreter = callPackage ./default.nix { inherit (gnome2) gtkglext; };
# Convenience access for using the returned attribute the same way as the interpreter derivation
withLibs = self.interpreter.withLibs;
});
extensible-self = lib.makeExtensible (lib.extends overrides inside);
in extensible-self

View File

@ -0,0 +1,13 @@
diff --git a/basis/tools/deploy/backend/backend.factor b/basis/tools/deploy/backend/backend.factor
index ec86089dbe..b146168ec9 100644
--- a/basis/tools/deploy/backend/backend.factor
+++ b/basis/tools/deploy/backend/backend.factor
@@ -69,7 +69,7 @@ ERROR: can't-deploy-library-file library ;
[ staging-image-name "-output-image=" prepend , ]
[ " " join "-include=" prepend , ] bi
] [
- input-image-name "-i=" prepend ,
+ input-image-name resource-path "-i=" prepend ,
"-resource-path=" "" resource-path append ,
"-run=tools.deploy.restage" ,
] bi