Browse code
feat(nix): add sbcl 2.0.10 build, add untar and default packages
Showing 4 changed files
- nix/common.nix
- nix/elangley-overlay/.default.nix.swp
- nix/elangley-overlay/default.nix
- nix/elangley-overlay/sbcl.nix
1 | 1 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,15 @@ |
1 |
+{ pkgs }: |
|
2 |
+let |
|
3 |
+ packages = extras: |
|
4 |
+ (with pkgs; [ dtach nixpkgs-fmt nixfmt glibcLocales ]) ++ extras; |
|
5 |
+ |
|
6 |
+ utils = { |
|
7 |
+ untar = path: |
|
8 |
+ pkgs.runCommand "untar" { buildInputs = [ pkgs.gnutar ]; } '' |
|
9 |
+ mkdir -p "$out" |
|
10 |
+ cd "$out" |
|
11 |
+ tar --strip-components=1 -xf "${path}" |
|
12 |
+ ''; |
|
13 |
+ }; |
|
14 |
+in |
|
15 |
+{ inherit packages utils; } |
8 | 12 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,118 @@ |
1 |
+{ stdenv, fetchurl, writeText, sbclBootstrap |
|
2 |
+, sbclBootstrapHost ? "${sbclBootstrap}/bin/sbcl --disable-debugger --no-userinit --no-sysinit" |
|
3 |
+, threadSupport ? (stdenv.isi686 || stdenv.isx86_64 || "aarch64-linux" == stdenv.hostPlatform.system) |
|
4 |
+, disableImmobileSpace ? false |
|
5 |
+# Meant for sbcl used for creating binaries portable to non-NixOS via save-lisp-and-die. |
|
6 |
+# Note that the created binaries still need `patchelf --set-interpreter ...` |
|
7 |
+# to get rid of ${glibc} dependency. |
|
8 |
+, purgeNixReferences ? false |
|
9 |
+, texinfo |
|
10 |
+, version |
|
11 |
+, sha |
|
12 |
+}: |
|
13 |
+ |
|
14 |
+let |
|
15 |
+ theVersion = version; |
|
16 |
+ theSha = sha; |
|
17 |
+ |
|
18 |
+in |
|
19 |
+ |
|
20 |
+stdenv.mkDerivation rec { |
|
21 |
+ pname = "sbcl"; |
|
22 |
+ version = theVersion; |
|
23 |
+ |
|
24 |
+ src = fetchurl { |
|
25 |
+ url = "mirror://sourceforge/project/sbcl/sbcl/${version}/${pname}-${version}-source.tar.bz2"; |
|
26 |
+ sha256 = theSha; |
|
27 |
+ }; |
|
28 |
+ |
|
29 |
+ buildInputs = [texinfo]; |
|
30 |
+ |
|
31 |
+ patchPhase = '' |
|
32 |
+ echo '"${version}.nixos"' > version.lisp-expr |
|
33 |
+ pwd |
|
34 |
+ # SBCL checks whether files are up-to-date in many places.. |
|
35 |
+ # Unfortunately, same timestamp is not good enough |
|
36 |
+ sed -e 's@> x y@>= x y@' -i contrib/sb-aclrepl/repl.lisp |
|
37 |
+ #sed -e '/(date)/i((= date 2208988801) 2208988800)' -i contrib/asdf/asdf.lisp |
|
38 |
+ sed -i src/cold/slam.lisp -e \ |
|
39 |
+ '/file-write-date input/a)' |
|
40 |
+ sed -i src/cold/slam.lisp -e \ |
|
41 |
+ '/file-write-date output/i(or (and (= 2208988801 (file-write-date output)) (= 2208988801 (file-write-date input)))' |
|
42 |
+ sed -i src/code/target-load.lisp -e \ |
|
43 |
+ '/date defaulted-fasl/a)' |
|
44 |
+ sed -i src/code/target-load.lisp -e \ |
|
45 |
+ '/date defaulted-source/i(or (and (= 2208988801 (file-write-date defaulted-source-truename)) (= 2208988801 (file-write-date defaulted-fasl-truename)))' |
|
46 |
+ # Fix the tests |
|
47 |
+ sed -e '5,$d' -i contrib/sb-bsd-sockets/tests.lisp |
|
48 |
+ sed -e '5,$d' -i contrib/sb-simple-streams/*test*.lisp |
|
49 |
+ # Use whatever `cc` the stdenv provides |
|
50 |
+ substituteInPlace src/runtime/Config.x86-64-darwin --replace gcc cc |
|
51 |
+ substituteInPlace src/runtime/Config.x86-64-darwin \ |
|
52 |
+ --replace mmacosx-version-min=10.4 mmacosx-version-min=10.5 |
|
53 |
+ '' |
|
54 |
+ + (if purgeNixReferences |
|
55 |
+ then |
|
56 |
+ # This is the default location to look for the core; by default in $out/lib/sbcl |
|
57 |
+ '' |
|
58 |
+ sed 's@^\(#define SBCL_HOME\) .*$@\1 "/no-such-path"@' \ |
|
59 |
+ -i src/runtime/runtime.c |
|
60 |
+ '' |
|
61 |
+ else |
|
62 |
+ # Fix software version retrieval |
|
63 |
+ '' |
|
64 |
+ sed -e "s@/bin/uname@$(command -v uname)@g" -i src/code/*-os.lisp \ |
|
65 |
+ src/code/run-program.lisp |
|
66 |
+ '' |
|
67 |
+ ); |
|
68 |
+ |
|
69 |
+ |
|
70 |
+ preBuild = '' |
|
71 |
+ export INSTALL_ROOT=$out |
|
72 |
+ mkdir -p test-home |
|
73 |
+ export HOME=$PWD/test-home |
|
74 |
+ ''; |
|
75 |
+ |
|
76 |
+ enableFeatures = with stdenv.lib; |
|
77 |
+ optional threadSupport "sb-thread" ++ |
|
78 |
+ optional stdenv.isAarch32 "arm"; |
|
79 |
+ |
|
80 |
+ disableFeatures = with stdenv.lib; |
|
81 |
+ optional (!threadSupport) "sb-thread" ++ |
|
82 |
+ optionals disableImmobileSpace [ "immobile-space" "immobile-code" "compact-instance-header" ]; |
|
83 |
+ |
|
84 |
+ buildPhase = '' |
|
85 |
+ sh make.sh --prefix=$out --xc-host="${sbclBootstrapHost}" ${ |
|
86 |
+ stdenv.lib.concatStringsSep " " |
|
87 |
+ (builtins.map (x: "--with-${x}") enableFeatures ++ |
|
88 |
+ builtins.map (x: "--without-${x}") disableFeatures) |
|
89 |
+ } |
|
90 |
+ (cd doc/manual ; make info) |
|
91 |
+ ''; |
|
92 |
+ |
|
93 |
+ installPhase = '' |
|
94 |
+ INSTALL_ROOT=$out sh install.sh |
|
95 |
+ '' |
|
96 |
+ + stdenv.lib.optionalString (!purgeNixReferences) '' |
|
97 |
+ cp -r src $out/lib/sbcl |
|
98 |
+ cp -r contrib $out/lib/sbcl |
|
99 |
+ cat >$out/lib/sbcl/sbclrc <<EOF |
|
100 |
+ (setf (logical-pathname-translations "SYS") |
|
101 |
+ '(("SYS:SRC;**;*.*.*" #P"$out/lib/sbcl/src/**/*.*") |
|
102 |
+ ("SYS:CONTRIB;**;*.*.*" #P"$out/lib/sbcl/contrib/**/*.*"))) |
|
103 |
+EOF |
|
104 |
+ ''; |
|
105 |
+ |
|
106 |
+ setupHook = stdenv.lib.optional purgeNixReferences (writeText "setupHook.sh" '' |
|
107 |
+ addEnvHooks "$targetOffset" _setSbclHome |
|
108 |
+ _setSbclHome() { |
|
109 |
+ export SBCL_HOME='@out@/lib/sbcl/' |
|
110 |
+ } |
|
111 |
+ ''); |
|
112 |
+ |
|
113 |
+ meta = sbclBootstrap.meta // { |
|
114 |
+ inherit version; |
|
115 |
+ updateWalker = true; |
|
116 |
+ }; |
|
117 |
+ } |
|
118 |
+ |