about summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
author7c6f434c <7c6f434c@mail.ru>2024-06-20 20:03:51 +0000
committerGitHub <noreply@github.com>2024-06-20 20:03:51 +0000
commit0c45511b4fa455b8191343cc5f7b48ebcd6e0394 (patch)
treea0a6da72ca2a7f7608d97f2164d5bc32dbc04bf5 /pkgs
parenta8e819d72379c40c713d4583f7bd83267ba69065 (diff)
parentee7cf64d90544e1de0ebc65d777cd3c925a10eaf (diff)
Merge pull request #317746 from hraban/fix/sbcl-overridable-options
sbcl: make deriv options overridable attributes
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/compilers/sbcl/default.nix53
-rw-r--r--pkgs/development/interpreters/acl2/default.nix2
2 files changed, 29 insertions, 26 deletions
diff --git a/pkgs/development/compilers/sbcl/default.nix b/pkgs/development/compilers/sbcl/default.nix
index 0eec40b2bd4c7..a2b5cf46b54d6 100644
--- a/pkgs/development/compilers/sbcl/default.nix
+++ b/pkgs/development/compilers/sbcl/default.nix
@@ -1,13 +1,4 @@
 { lib, stdenv, callPackage, ecl, coreutils, fetchurl, strace, texinfo, which, writeText, zstd
-, threadSupport ? (stdenv.hostPlatform.isx86 || "aarch64-linux" == stdenv.hostPlatform.system || "aarch64-darwin" == stdenv.hostPlatform.system)
-, linkableRuntime ? stdenv.hostPlatform.isx86
-, disableImmobileSpace ? false
-  # 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
-, coreCompression ? true
-, markRegionGC ? threadSupport
 , version
   # Set this to a lisp binary to use a custom bootstrap lisp compiler for SBCL.
   # Leave as null to use the default.  This is useful for local development of
@@ -65,12 +56,14 @@ let
 
 in
 
-stdenv.mkDerivation (self: rec {
+stdenv.mkDerivation (self: {
   pname = "sbcl";
   inherit version;
 
   src = fetchurl {
-    url = "mirror://sourceforge/project/sbcl/sbcl/${version}/${pname}-${version}-source.tar.bz2";
+    # Changing the version shouldn’t change the source for the
+    # derivation. Override the src entirely if desired.
+    url = "mirror://sourceforge/project/sbcl/sbcl/${version}/sbcl-${version}-source.tar.bz2";
     inherit (versionMap.${version}) sha256;
   };
 
@@ -83,15 +76,25 @@ stdenv.mkDerivation (self: rec {
       strace
     ]
   );
-  buildInputs = lib.optionals coreCompression (
+  buildInputs = lib.optionals self.coreCompression (
     # Declare at the point of actual use in case the caller wants to override
     # buildInputs to sidestep this.
-    assert lib.assertMsg (!purgeNixReferences) ''
+    assert lib.assertMsg (!self.purgeNixReferences) ''
       Cannot enable coreCompression when purging Nix references, because compression requires linking in zstd
     '';
     [ zstd ]
   );
 
+  threadSupport = (stdenv.hostPlatform.isx86 || "aarch64-linux" == stdenv.hostPlatform.system || "aarch64-darwin" == stdenv.hostPlatform.system);
+  # 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;
+  coreCompression = true;
+  markRegionGC = self.threadSupport;
+  disableImmobileSpace = false;
+  linkableRuntime = stdenv.hostPlatform.isx86;
+
   # I don’t know why these are failing (on ofBorg), and I’d rather just disable
   # them and move forward with the succeeding tests than block testing
   # altogether. One by one hopefully we can fix these (on ofBorg,
@@ -125,7 +128,7 @@ stdenv.mkDerivation (self: rec {
   postPatch = lib.optionalString (self.disabledTestFiles != [ ]) ''
     (cd tests ; rm -f ${lib.concatStringsSep " " self.disabledTestFiles})
   ''
-  + lib.optionalString purgeNixReferences ''
+  + lib.optionalString self.purgeNixReferences ''
     # 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
@@ -137,7 +140,7 @@ stdenv.mkDerivation (self: rec {
       # binary. There are some tricky files in nested directories which should
       # definitely NOT be patched this way, hence just a single * (and no
       # globstar).
-      substituteInPlace ${if purgeNixReferences then "tests" else "{tests,src/code}"}/*.{lisp,sh} \
+      substituteInPlace ${if self.purgeNixReferences then "tests" else "{tests,src/code}"}/*.{lisp,sh} \
         --replace-quiet /usr/bin/env "${coreutils}/bin/env" \
         --replace-quiet /bin/uname "${coreutils}/bin/uname" \
         --replace-quiet /bin/sh "${stdenv.shell}"
@@ -146,7 +149,7 @@ stdenv.mkDerivation (self: rec {
     # want to override { src = ... } it might not exist. It’s required for
     # building, so create a mock version as a backup.
     if [[ ! -a version.lisp-expr ]]; then
-      echo '"${version}.nixos"' > version.lisp-expr
+      echo '"${self.version}.nixos"' > version.lisp-expr
     fi
   '';
 
@@ -157,16 +160,16 @@ stdenv.mkDerivation (self: rec {
   '';
 
   enableFeatures = with lib;
-    assert assertMsg (markRegionGC -> threadSupport) "SBCL mark region GC requires thread support";
-    optional threadSupport "sb-thread" ++
-    optional linkableRuntime "sb-linkable-runtime" ++
-    optional coreCompression "sb-core-compression" ++
+    assert assertMsg (self.markRegionGC -> self.threadSupport) "SBCL mark region GC requires thread support";
+    optional self.threadSupport "sb-thread" ++
+    optional self.linkableRuntime "sb-linkable-runtime" ++
+    optional self.coreCompression "sb-core-compression" ++
     optional stdenv.isAarch32 "arm" ++
-    optional markRegionGC "mark-region-gc";
+    optional self.markRegionGC "mark-region-gc";
 
   disableFeatures = with lib;
-    optional (!threadSupport) "sb-thread" ++
-    optionals disableImmobileSpace [ "immobile-space" "immobile-code" "compact-instance-header" ];
+    optional (!self.threadSupport) "sb-thread" ++
+    optionals self.disableImmobileSpace [ "immobile-space" "immobile-code" "compact-instance-header" ];
 
   buildArgs = [
     "--prefix=$out"
@@ -210,7 +213,7 @@ stdenv.mkDerivation (self: rec {
     INSTALL_ROOT=$out sh install.sh
 
   ''
-  + lib.optionalString (!purgeNixReferences) ''
+  + lib.optionalString (!self.purgeNixReferences) ''
     cp -r src $out/lib/sbcl
     cp -r contrib $out/lib/sbcl
     cat >$out/lib/sbcl/sbclrc <<EOF
@@ -222,7 +225,7 @@ stdenv.mkDerivation (self: rec {
     runHook postInstall
   '';
 
-  setupHook = lib.optional purgeNixReferences (writeText "setupHook.sh" ''
+  setupHook = lib.optional self.purgeNixReferences (writeText "setupHook.sh" ''
     addEnvHooks "$targetOffset" _setSbclHome
     _setSbclHome() {
       export SBCL_HOME='@out@/lib/sbcl/'
diff --git a/pkgs/development/interpreters/acl2/default.nix b/pkgs/development/interpreters/acl2/default.nix
index d1f64918c8249..12fc8f228b7ff 100644
--- a/pkgs/development/interpreters/acl2/default.nix
+++ b/pkgs/development/interpreters/acl2/default.nix
@@ -9,7 +9,7 @@ let
   # supply 2GB of dynamic space to avoid exhausting the heap while building the
   # ACL2 system itself; see
   # https://www.cs.utexas.edu/users/moore/acl2/current/HTML/installation/requirements.html#Obtaining-SBCL
-  sbcl' = args.sbcl.override { disableImmobileSpace = true; };
+  sbcl' = args.sbcl.overrideAttrs { disableImmobileSpace = true; };
   sbcl = runCommandLocal args.sbcl.name { nativeBuildInputs = [ makeWrapper ]; } ''
     makeWrapper ${sbcl'}/bin/sbcl $out/bin/sbcl \
       --add-flags "--dynamic-space-size 2000"