sbcl: add purgeNixReferences option (close #13997)

... to support creating executables portable to non-NixOS.
This commit is contained in:
Vladimír Čunát 2016-03-17 18:02:53 +01:00
parent fb6786de36
commit 2d72bc1402

View file

@ -1,4 +1,10 @@
{ stdenv, fetchurl, sbclBootstrap, sbclBootstrapHost ? "${sbclBootstrap}/bin/sbcl --disable-debugger --no-userinit --no-sysinit" }: { stdenv, fetchurl, writeText, sbclBootstrap
, sbclBootstrapHost ? "${sbclBootstrap}/bin/sbcl --disable-debugger --no-userinit --no-sysinit"
# Meant for sbcl used for creating binaries portable to non-NixOS via save-lisp-and-die.
# Note that the created binaries still need `patchelf --set-interpreter ...`
# to get rid of ${glibc} dependency.
, purgeNixReferences ? false
}:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
name = "sbcl-${version}"; name = "sbcl-${version}";
@ -37,9 +43,6 @@ stdenv.mkDerivation rec {
sed -i src/code/target-load.lisp -e \ sed -i src/code/target-load.lisp -e \
'/date defaulted-source/i(or (and (= 2208988801 (file-write-date defaulted-source-truename)) (= 2208988801 (file-write-date defaulted-fasl-truename)))' '/date defaulted-source/i(or (and (= 2208988801 (file-write-date defaulted-source-truename)) (= 2208988801 (file-write-date defaulted-fasl-truename)))'
# Fix software version retrieval
sed -e "s@/bin/uname@$(command -v uname)@g" -i src/code/*-os.lisp
# Fix the tests # Fix the tests
sed -e '/deftest pwent/inil' -i contrib/sb-posix/posix-tests.lisp sed -e '/deftest pwent/inil' -i contrib/sb-posix/posix-tests.lisp
sed -e '/deftest grent/inil' -i contrib/sb-posix/posix-tests.lisp sed -e '/deftest grent/inil' -i contrib/sb-posix/posix-tests.lisp
@ -54,7 +57,21 @@ stdenv.mkDerivation rec {
substituteInPlace src/runtime/Config.x86-64-darwin \ substituteInPlace src/runtime/Config.x86-64-darwin \
--replace mmacosx-version-min=10.4 mmacosx-version-min=10.5 --replace mmacosx-version-min=10.4 mmacosx-version-min=10.5
''; ''
+ (if purgeNixReferences
then
# This is the default location to look for the core; by default in $out/lib/sbcl
''
sed 's@^\(#define SBCL_HOME\) .*$@\1 "/no-such-path"@' \
-i src/runtime/runtime.c
''
else
# Fix software version retrieval
''
sed -e "s@/bin/uname@$(command -v uname)@g" -i src/code/*-os.lisp
''
);
preBuild = '' preBuild = ''
export INSTALL_ROOT=$out export INSTALL_ROOT=$out
@ -70,6 +87,14 @@ stdenv.mkDerivation rec {
INSTALL_ROOT=$out sh install.sh INSTALL_ROOT=$out sh install.sh
''; '';
# Specifying $SBCL_HOME is only truly needed with `purgeNixReferences = true`.
setupHook = writeText "setupHook.sh" ''
envHooks+=(_setSbclHome)
_setSbclHome() {
export SBCL_HOME='@out@/lib/sbcl/'
}
'';
meta = sbclBootstrap.meta // { meta = sbclBootstrap.meta // {
inherit version; inherit version;
updateWalker = true; updateWalker = true;