summary refs log tree commit diff
path: root/pkgs
diff options
context:
space:
mode:
authorKasper Gałkowski <k@galkowski.xyz>2023-03-10 23:13:53 +0100
committerKasper Gałkowski <k@galkowski.xyz>2023-03-11 15:11:38 +0100
commit84eea85ad99ac2dd4c30d22dc32004888ea73b03 (patch)
tree0f77951c06b0cb94ef8a7e7d6d0dc1a5fecd2592 /pkgs
parent653ba458347e33ce31fce1c7402678bcdb5bed87 (diff)
downloadnixpkgs-84eea85ad99ac2dd4c30d22dc32004888ea73b03.tar
nixpkgs-84eea85ad99ac2dd4c30d22dc32004888ea73b03.tar.gz
nixpkgs-84eea85ad99ac2dd4c30d22dc32004888ea73b03.tar.bz2
nixpkgs-84eea85ad99ac2dd4c30d22dc32004888ea73b03.tar.lz
nixpkgs-84eea85ad99ac2dd4c30d22dc32004888ea73b03.tar.xz
nixpkgs-84eea85ad99ac2dd4c30d22dc32004888ea73b03.tar.zst
nixpkgs-84eea85ad99ac2dd4c30d22dc32004888ea73b03.zip
lisp-modules: use wrapLisp to wrap Lisps
The previous approach of manually repeating a complex pattern inside Common Lisp
implementation package declarations was fragile and hard to change. After
reading python and lua modules code in Nixpkgs, I was able to come up with
something better.

The function `wrapLisp` doesn't need to be inside package declarations so all
the code for wrapping Lisps can be in `all-packages.nix`.

This works by wrapping the `override` function created from `mkDerivation` to
accept a new argument `packageOverrides`.

One problem with this is that `override.__functionArgs` disappears. But one can
look at the source code of a package to discover what can be overridden.
Diffstat (limited to 'pkgs')
-rw-r--r--pkgs/development/compilers/abcl/default.nix24
-rw-r--r--pkgs/development/compilers/ccl/default.nix26
-rw-r--r--pkgs/development/compilers/ecl/16.1.2.nix23
-rw-r--r--pkgs/development/compilers/ecl/default.nix24
-rw-r--r--pkgs/development/compilers/sbcl/2.x.nix24
-rw-r--r--pkgs/development/interpreters/clisp/default.nix23
-rw-r--r--pkgs/development/interpreters/clisp/hg.nix23
-rw-r--r--pkgs/development/lisp-modules/import/database/sqlite.lisp2
-rw-r--r--pkgs/development/lisp-modules/nix-cl.nix27
-rw-r--r--pkgs/top-level/all-packages.nix119
10 files changed, 136 insertions, 179 deletions
diff --git a/pkgs/development/compilers/abcl/default.nix b/pkgs/development/compilers/abcl/default.nix
index f94503b40a3..dcc9893dc74 100644
--- a/pkgs/development/compilers/abcl/default.nix
+++ b/pkgs/development/compilers/abcl/default.nix
@@ -1,12 +1,5 @@
-{lib, stdenv, fetchurl, ant, jre, jdk
-# For packages
-, asdf_3_3
-, commonLispPackagesFor
-, lispWithPackages
-, build-asdf-system
-, spec ? { faslExt = "abcl"; program = "abcl"; flags = []; asdf = asdf_3_3; }
-, packageOverrides ? (self: super: {})}:
-let abcl = stdenv.mkDerivation rec {
+{lib, stdenv, fetchurl, ant, jre, jdk, ...}:
+stdenv.mkDerivation rec {
   pname = "abcl";
   version = "1.9.0";
   # or fetchFromGitHub(owner,repo,rev) or fetchgit(rev)
@@ -47,15 +40,4 @@ let abcl = stdenv.mkDerivation rec {
     platforms = lib.platforms.linux;
     homepage = "https://common-lisp.net/project/armedbear/";
   };
-
-  # For packages
-  passthru = let
-    spec' = spec // { pkg = abcl; };
-    pkgs = (commonLispPackagesFor spec').overrideScope' packageOverrides;
-  in {
-    inherit pkgs;
-    withPackages = lispWithPackages pkgs;
-    buildASDFSystem = args: build-asdf-system (args // spec');
-  };
-};
-in abcl
+}
diff --git a/pkgs/development/compilers/ccl/default.nix b/pkgs/development/compilers/ccl/default.nix
index 7e29b3e286f..80be9a474b9 100644
--- a/pkgs/development/compilers/ccl/default.nix
+++ b/pkgs/development/compilers/ccl/default.nix
@@ -1,12 +1,4 @@
-{ lib, stdenv, fetchurl, fetchpatch, runCommand, bootstrap_cmds, coreutils, glibc, m4, runtimeShell
-# For packages
-, asdf_3_3
-, commonLispPackagesFor
-, lispWithPackages
-, build-asdf-system
-, spec ? { faslExt = "lx64fsl"; program = "ccl"; flags = ""; asdf = asdf_3_3; }
-, packageOverrides ? (self: super: {})
-}:
+{ lib, stdenv, fetchurl, fetchpatch, runCommand, bootstrap_cmds, coreutils, glibc, m4, runtimeShell, ... }:
 
 let
   options = rec {
@@ -56,7 +48,9 @@ let
     tar czf $out ccl
   '';
 
-ccl = stdenv.mkDerivation rec {
+in
+
+stdenv.mkDerivation rec {
   pname = "ccl";
   version  = "1.12";
 
@@ -131,14 +125,4 @@ ccl = stdenv.mkDerivation rec {
     broken      = (stdenv.isDarwin && stdenv.isx86_64);
     license     = licenses.asl20;
   };
-
-  passthru = let
-    spec' = spec // { pkg = ccl; };
-    pkgs = (commonLispPackagesFor spec').overrideScope' packageOverrides;
-  in {
-    inherit pkgs;
-    withPackages = lispWithPackages pkgs;
-    buildASDFSystem = args: build-asdf-system (args // spec');
-  };
-
-}; in ccl
+}
diff --git a/pkgs/development/compilers/ecl/16.1.2.nix b/pkgs/development/compilers/ecl/16.1.2.nix
index 32e3d387261..2cd7a739b2f 100644
--- a/pkgs/development/compilers/ecl/16.1.2.nix
+++ b/pkgs/development/compilers/ecl/16.1.2.nix
@@ -14,16 +14,9 @@
 , threadSupport ? false
 , useBoehmgc ? true
 , boehmgc
-# For packages
-, asdf_3_3
-, commonLispPackagesFor
-, lispWithPackages
-, build-asdf-system
-, spec ? { faslExt = "fas"; program = "ecl"; flags = []; asdf = asdf_3_3; }
-, packageOverrides ? (self: super: {})
-}:
+, ... }:
 
-let ecl = stdenv.mkDerivation rec {
+stdenv.mkDerivation rec {
   pname = "ecl";
   version = "16.1.2";
 
@@ -103,14 +96,4 @@ let ecl = stdenv.mkDerivation rec {
     # never built on aarch64-darwin since first introduction in nixpkgs
     broken = stdenv.isDarwin && stdenv.isAarch64;
   };
-
-  passthru = let
-    spec' = spec // { pkg = ecl; };
-    pkgs = (commonLispPackagesFor spec').overrideScope' packageOverrides;
-  in {
-    inherit pkgs;
-    withPackages = lispWithPackages pkgs;
-    buildASDFSystem = args: build-asdf-system (args // spec');
-  };
-};
-in ecl
+}
diff --git a/pkgs/development/compilers/ecl/default.nix b/pkgs/development/compilers/ecl/default.nix
index 4ae4182c52f..bcab15b4ab0 100644
--- a/pkgs/development/compilers/ecl/default.nix
+++ b/pkgs/development/compilers/ecl/default.nix
@@ -15,16 +15,9 @@
 , threadSupport ? true
 , useBoehmgc ? false
 , boehmgc
-# For packages
-, asdf_3_3
-, commonLispPackagesFor
-, lispWithPackages
-, build-asdf-system
-, spec ? { faslExt = "fas"; program = "ecl"; flags = []; asdf = asdf_3_3; }
-, packageOverrides ? (self: super: {})
-}:
+, ... }:
 
-let ecl = stdenv.mkDerivation rec {
+stdenv.mkDerivation rec {
   pname = "ecl";
   version = "21.2.1";
 
@@ -90,15 +83,4 @@ let ecl = stdenv.mkDerivation rec {
     platforms = platforms.unix;
     changelog = "https://gitlab.com/embeddable-common-lisp/ecl/-/raw/${version}/CHANGELOG";
   };
-
-  # For packages
-  passthru = let
-    spec' = spec // { pkg = ecl; };
-    pkgs = (commonLispPackagesFor spec').overrideScope' packageOverrides;
-  in {
-    inherit pkgs;
-    withPackages = lispWithPackages pkgs;
-    buildASDFSystem = args: build-asdf-system (args // spec');
-  };
-
-}; in ecl
+}
diff --git a/pkgs/development/compilers/sbcl/2.x.nix b/pkgs/development/compilers/sbcl/2.x.nix
index c4bc52b085e..be5522ded29 100644
--- a/pkgs/development/compilers/sbcl/2.x.nix
+++ b/pkgs/development/compilers/sbcl/2.x.nix
@@ -10,14 +10,7 @@
 , coreCompression ? lib.versionAtLeast version "2.2.6"
 , texinfo
 , version
-# For packages
-, asdf_3_3
-, commonLispPackagesFor
-, lispWithPackages
-, build-asdf-system
-, spec ? { faslExt = "fasl"; program = "sbcl"; flags = []; asdf = asdf_3_3; }
-, packageOverrides ? (self: super: {})
-}:
+, ... }:
 
 let
   versionMap = {
@@ -74,7 +67,7 @@ let
     };
   };
 
-sbcl = with versionMap.${version};
+in with versionMap.${version};
 
 stdenv.mkDerivation rec {
   pname = "sbcl";
@@ -226,15 +219,4 @@ stdenv.mkDerivation rec {
   '');
 
   meta = sbclBootstrap.meta;
-
-  # For packages
-  passthru = let
-    spec' = spec // { pkg = sbcl; };
-    pkgs = (commonLispPackagesFor spec').overrideScope' packageOverrides;
-  in {
-    inherit pkgs;
-    withPackages = lispWithPackages pkgs;
-    buildASDFSystem = args: build-asdf-system (args // spec');
-  };
-};
-in sbcl
+}
diff --git a/pkgs/development/interpreters/clisp/default.nix b/pkgs/development/interpreters/clisp/default.nix
index 1d529335172..ab6d12dbe71 100644
--- a/pkgs/development/interpreters/clisp/default.nix
+++ b/pkgs/development/interpreters/clisp/default.nix
@@ -18,19 +18,12 @@
   ]
   ++ lib.optionals stdenv.isLinux [ "bindings/glibc" "zlib" "wildcard" ]
   ++ lib.optional x11Support "clx/new-clx"
-# For packages
-, asdf_3_3
-, commonLispPackagesFor
-, lispWithPackages
-, build-asdf-system
-, spec ? { faslExt = "fas"; program = "clisp"; flags = ["-E" "UTF-8"]; asdf = asdf_3_3; }
-, packageOverrides ? (self: super: {})
-}:
+, ... }:
 
 assert x11Support -> (libX11 != null && libXau != null && libXt != null
   && libXpm != null && xorgproto != null && libXext != null);
 
-let clisp = stdenv.mkDerivation rec {
+stdenv.mkDerivation rec {
   version = "2.49";
   pname = "clisp";
 
@@ -112,14 +105,4 @@ let clisp = stdenv.mkDerivation rec {
     broken = stdenv.hostPlatform.isDarwin || stdenv.hostPlatform.isAarch64;
     license = lib.licenses.gpl2;
   };
-
-  passthru = let
-    spec' = spec // { pkg = clisp; };
-    pkgs = (commonLispPackagesFor spec').overrideScope' packageOverrides;
-  in {
-    inherit pkgs;
-    withPackages = lispWithPackages pkgs;
-    buildASDFSystem = args: build-asdf-system (args // spec');
-  };
-
-}; in clisp
+}
diff --git a/pkgs/development/interpreters/clisp/hg.nix b/pkgs/development/interpreters/clisp/hg.nix
index 53ccbcef558..fe8ff2b0d67 100644
--- a/pkgs/development/interpreters/clisp/hg.nix
+++ b/pkgs/development/interpreters/clisp/hg.nix
@@ -17,19 +17,12 @@
   ]
   ++ lib.optionals stdenv.isLinux [ "bindings/glibc" "zlib" ]
   ++ lib.optional x11Support "clx/new-clx"
-# For packages
-, asdf_3_3
-, commonLispPackagesFor
-, lispWithPackages
-, build-asdf-system
-, spec ? { faslExt = "fas"; program = "clisp"; flags = "-E UTF-8"; asdf = asdf_3_3; }
-, packageOverrides ? (self: super: {})
-}:
+, ... }:
 
 assert x11Support -> (libX11 != null && libXau != null && libXt != null
   && libXpm != null && xorgproto != null && libXext != null);
 
-let clisp = stdenv.mkDerivation rec {
+stdenv.mkDerivation rec {
   version = "2.50pre20171114";
   pname = "clisp";
 
@@ -102,14 +95,4 @@ let clisp = stdenv.mkDerivation rec {
     # problems on Darwin: https://github.com/NixOS/nixpkgs/issues/20062
     platforms = lib.platforms.linux;
   };
-
-  passthru = let
-    spec' = spec // { pkg = clisp; };
-    pkgs = (commonLispPackagesFor spec').overrideScope' packageOverrides;
-  in {
-    inherit pkgs;
-    withPackages = lispWithPackages pkgs;
-    buildASDFSystem = args: build-asdf-system (args // spec');
-  };
-
-}; in clisp
+}
diff --git a/pkgs/development/lisp-modules/import/database/sqlite.lisp b/pkgs/development/lisp-modules/import/database/sqlite.lisp
index c25c5c7d47c..fb502e42452 100644
--- a/pkgs/development/lisp-modules/import/database/sqlite.lisp
+++ b/pkgs/development/lisp-modules/import/database/sqlite.lisp
@@ -170,4 +170,4 @@ in lib.makeScope pkgs.newScope (self: {")
                  ,@(when (or (find #\/ name)
                             (find name +broken-packages+ :test #'string=))
                     '(("meta" (:attrs ("broken" (:symbol "true")))))))))))))
-      (format f "~%})"))))
+      (format f "~%})~%"))))
diff --git a/pkgs/development/lisp-modules/nix-cl.nix b/pkgs/development/lisp-modules/nix-cl.nix
index 208ca7559d8..7e671e7cc63 100644
--- a/pkgs/development/lisp-modules/nix-cl.nix
+++ b/pkgs/development/lisp-modules/nix-cl.nix
@@ -286,8 +286,25 @@ let
       '';
     });
 
-in {
-  inherit commonLispPackagesFor;
-  inherit lispWithPackages;
-  inherit build-asdf-system;
-}
+  wrapLisp = { pkg, faslExt, program ? pkg.pname, flags ? [], asdf ? pkgs.asdf_3_3 }:
+    let
+      spec = { inherit pkg faslExt program flags asdf; };
+      pkgs = commonLispPackagesFor spec;
+      withPackages = lispWithPackages pkgs;
+      override =
+        { packageOverrides ? (self: super: {}) , ... } @ attrs:
+        let
+          pkg' = spec.pkg.override attrs;
+          spec' = spec // { pkg = pkg'; };
+          pkgs = (commonLispPackagesFor spec').overrideScope' packageOverrides;
+          withPackages = lispWithPackages pkgs;
+        in pkg' // {
+          inherit pkgs withPackages override;
+          buildASDFSystem = args: build-asdf-system (args // spec');
+        };
+    in pkg // {
+      inherit pkgs withPackages override;
+      buildASDFSystem = args: build-asdf-system (args // spec);
+    };
+
+in wrapLisp
diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix
index e7b83d9dda5..2dacba2d7bb 100644
--- a/pkgs/top-level/all-packages.nix
+++ b/pkgs/top-level/all-packages.nix
@@ -24177,55 +24177,116 @@ with pkgs;
     texLive = null;
   };
 
-  inherit (callPackage ../development/lisp-modules/nix-cl.nix {})
-    commonLispPackagesFor
-    lispWithPackages
-    build-asdf-system
-  ;
+  wrapLisp = callPackage ../development/lisp-modules/nix-cl.nix {};
 
   # Armed Bear Common Lisp
-  abcl = callPackage ../development/compilers/abcl { };
+  abcl = wrapLisp {
+    pkg = callPackage ../development/compilers/abcl { };
+    faslExt = "abcl";
+  };
 
   # Clozure Common Lisp
-  ccl = callPackage ../development/compilers/ccl {
-    inherit (buildPackages.darwin) bootstrap_cmds;
+  ccl = wrapLisp {
+    pkg = callPackage ../development/compilers/ccl {
+      inherit (buildPackages.darwin) bootstrap_cmds;
+    };
+    faslExt = "lx64fsl";
   };
 
   # Clasp Common Lisp
-  clasp-common-lisp = callPackage ../development/compilers/clasp {
-    llvmPackages = llvmPackages_15;
-    stdenv = llvmPackages_15.stdenv;
+  clasp-common-lisp = wrapLisp {
+    pkg = callPackage ../development/compilers/clasp {
+      llvmPackages = llvmPackages_15;
+      stdenv = llvmPackages_15.stdenv;
+    };
+    faslExt = "fasp";
   };
 
   # CLISP
-  clisp = callPackage ../development/interpreters/clisp {
+  clisp = wrapLisp {
+    pkg = callPackage ../development/interpreters/clisp {
     # On newer readline8 fails as:
     #  #<FOREIGN-VARIABLE "rl_readline_state" #x...>
     #   does not have the required size or alignment
     readline = readline63;
+    };
+    faslExt = "fas";
+    flags = ["-E" "UTF-8"];
   };
 
-  clisp-tip = callPackage ../development/interpreters/clisp/hg.nix { };
+  clisp-tip = wrapLisp {
+    pkg = callPackage ../development/interpreters/clisp/hg.nix { };
+    faslExt = "fas";
+    flags = ["-E" "UTF-8"];
+  };
 
   # Embeddable Common Lisp
-  ecl = callPackage ../development/compilers/ecl { };
-  ecl_16_1_2 = callPackage ../development/compilers/ecl/16.1.2.nix { };
+  ecl = wrapLisp {
+    pkg = callPackage ../development/compilers/ecl { };
+    faslExt = "fas";
+  };
+  ecl_16_1_2 = wrapLisp {
+    pkg = callPackage ../development/compilers/ecl/16.1.2.nix { };
+    faslExt = "fas";
+  };
 
   # Steel Bank Common Lisp
-  sbclBootstrap = callPackage ../development/compilers/sbcl/bootstrap.nix {};
-  sbcl_2_0_8 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.0.8"; };
-  sbcl_2_0_9 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.0.9"; };
-  sbcl_2_1_1 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.1.1"; };
-  sbcl_2_1_2 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.1.2"; };
-  sbcl_2_1_9 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.1.9"; };
-  sbcl_2_1_10 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.1.10"; };
-  sbcl_2_1_11 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.1.11"; };
-  sbcl_2_2_4 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.2.4"; };
-  sbcl_2_2_6 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.2.6"; };
-  sbcl_2_2_9 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.2.9"; };
-  sbcl_2_2_10 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.2.10"; };
-  sbcl_2_2_11 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.2.11"; };
-  sbcl_2_3_0 = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.3.0"; };
+  sbclBootstrap = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/bootstrap.nix {};
+    faslExt = "fasl";
+  };
+  sbcl_2_0_8 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.0.8"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_0_9 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.0.9"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_1_1 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.1.1"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_1_2 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.1.2"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_1_9 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.1.9"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_1_10 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.1.10"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_1_11 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.1.11"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_2_4 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.2.4"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_2_6 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.2.6"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_2_9 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.2.9"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_2_10 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.2.10"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_2_11 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.2.11"; };
+    faslExt = "fasl";
+  };
+  sbcl_2_3_0 = wrapLisp {
+    pkg = callPackage ../development/compilers/sbcl/2.x.nix { version = "2.3.0"; };
+    faslExt = "fasl";
+  };
   sbcl = sbcl_2_3_0;
 
   sbclPackages = recurseIntoAttrs sbcl.pkgs;