about summary refs log tree commit diff
path: root/pkgs/development/interpreters
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/development/interpreters')
-rw-r--r--pkgs/development/interpreters/bqn/cbqn/cbqn-bytecode.nix35
-rw-r--r--pkgs/development/interpreters/bqn/cbqn/default.nix108
-rw-r--r--pkgs/development/interpreters/bqn/cbqn/replxx.nix37
-rw-r--r--pkgs/development/interpreters/bqn/cbqn/singeli.nix37
-rw-r--r--pkgs/development/interpreters/bqn/cbqn/sources.nix60
-rw-r--r--pkgs/development/interpreters/bqn/mlochbaum-bqn/001-libbqn-path.patch12
-rw-r--r--pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix64
7 files changed, 119 insertions, 234 deletions
diff --git a/pkgs/development/interpreters/bqn/cbqn/cbqn-bytecode.nix b/pkgs/development/interpreters/bqn/cbqn/cbqn-bytecode.nix
deleted file mode 100644
index d311f3d61ebd4..0000000000000
--- a/pkgs/development/interpreters/bqn/cbqn/cbqn-bytecode.nix
+++ /dev/null
@@ -1,35 +0,0 @@
-{ lib
-, fetchFromGitHub
-, stdenvNoCC
-}:
-
-stdenvNoCC.mkDerivation {
-  pname = "cbqn-bytecode";
-  version = "unstable-2023-05-17";
-
-  src = fetchFromGitHub {
-    owner = "dzaima";
-    repo = "cbqnBytecode";
-    rev = "32db4dfbfc753835bf112f3d8ae2991d8aebbe3d";
-    hash = "sha256-9uBPrEESn/rB9u0xXwKaQ7ABveQWPc8LRMPlnI/79kg=";
-  };
-
-  dontConfigure = true;
-  dontBuild = true;
-
-  installPhase = ''
-    runHook preInstall
-
-    install -D $src/gen/{compiles,explain,formatter,runtime0,runtime1,runtime1x,src} -t $out/dev
-
-    runHook postInstall
-  '';
-
-  meta = with lib; {
-    homepage = "https://github.com/dzaima/cbqnBytecode";
-    description = "CBQN precompiled bytecode";
-    license = licenses.gpl3Plus;
-    maintainers = with maintainers; [ AndersonTorres sternenseemann synthetica shnarazk detegr ];
-    platforms = platforms.all;
-  };
-}
diff --git a/pkgs/development/interpreters/bqn/cbqn/default.nix b/pkgs/development/interpreters/bqn/cbqn/default.nix
index 6f5b889883910..f78eb807b4cfe 100644
--- a/pkgs/development/interpreters/bqn/cbqn/default.nix
+++ b/pkgs/development/interpreters/bqn/cbqn/default.nix
@@ -1,53 +1,36 @@
-{ callPackage
-, lib
-, stdenv
-, stdenvNoCC
+{ lib
+, callPackage
 , fetchFromGitHub
 , fixDarwinDylibNames
-, genBytecode ? false
-, bqn-path ? null
+, libffi
 , mbqn-source
+, pkg-config
+, stdenv
+# Boolean flags
 , enableReplxx ? false
 , enableLibcbqn ? ((stdenv.hostPlatform.isLinux || stdenv.hostPlatform.isDarwin) && !enableReplxx)
-, libffi
-, pkg-config
+, generateBytecode ? false
+# "Configurable" options
+, bqn-interpreter
 }:
 
 let
-  cbqn-bytecode-submodule =
-    callPackage ./cbqn-bytecode.nix { inherit lib fetchFromGitHub stdenvNoCC; };
-  replxx-submodule = callPackage ./replxx.nix { inherit lib fetchFromGitHub stdenvNoCC; };
-  singeli-submodule = callPackage ./singeli.nix { inherit lib fetchFromGitHub stdenvNoCC; };
+  sources = callPackage ./sources.nix { };
 in
-assert genBytecode -> ((bqn-path != null) && (mbqn-source != null));
-
 stdenv.mkDerivation rec {
-  pname = "cbqn" + lib.optionalString (!genBytecode) "-standalone";
-  version = "0.5.0";
-
-  src = fetchFromGitHub {
-    owner = "dzaima";
-    repo = "CBQN";
-    rev = "v${version}";
-    hash = "sha256-PCpePevWQ+aPG6Yx3WqBZ4yTeyJsCGkYMSY6kzGDL1U=";
-  };
+  pname = "cbqn" + lib.optionalString (!generateBytecode) "-standalone";
+  inherit (sources.cbqn) version src;
 
   nativeBuildInputs = [
     pkg-config
-  ] ++ lib.optional stdenv.hostPlatform.isDarwin fixDarwinDylibNames;
+  ] ++ lib.optionals stdenv.hostPlatform.isDarwin [
+    fixDarwinDylibNames
+  ];
 
   buildInputs = [
     libffi
   ];
 
-  dontConfigure = true;
-  doInstallCheck = true;
-
-  postPatch = ''
-    sed -i '/SHELL =.*/ d' makefile
-    patchShebangs build/build
-  '';
-
   makeFlags = [
     "CC=${stdenv.cc.targetPrefix}cc"
   ];
@@ -64,19 +47,6 @@ stdenv.mkDerivation rec {
     "shared-o3"
   ];
 
-  preBuild = ''
-    # Purity: avoids git downloading bytecode files
-    mkdir -p build/bytecodeLocal/gen
-    cp -r ${singeli-submodule}/dev/* build/singeliLocal/
-  '' + (if genBytecode then ''
-    ${bqn-path} ./build/genRuntime ${mbqn-source} build/bytecodeLocal/
-  '' else ''
-    cp -r ${cbqn-bytecode-submodule}/dev/* build/bytecodeLocal/gen/
-  '')
-  + lib.optionalString enableReplxx ''
-    cp -r ${replxx-submodule}/dev/* build/replxxLocal/
-  '';
-
   outputs = [
     "out"
   ] ++ lib.optionals enableLibcbqn [
@@ -84,6 +54,32 @@ stdenv.mkDerivation rec {
     "dev"
   ];
 
+  dontConfigure = true;
+
+  doInstallCheck = true;
+
+  strictDeps = true;
+
+  postPatch = ''
+    sed -i '/SHELL =.*/ d' makefile
+    patchShebangs build/build
+  '';
+
+  preBuild = ''
+    mkdir -p build/singeliLocal/
+    cp -r ${sources.singeli.src}/* build/singeliLocal/
+  '' + (if generateBytecode then ''
+    mkdir -p build/bytecodeLocal/gen
+    ${bqn-interpreter} ./build/genRuntime ${mbqn-source} build/bytecodeLocal/
+  '' else ''
+    mkdir -p build/bytecodeLocal/gen
+    cp -r ${sources.cbqn-bytecode.src}/* build/bytecodeLocal/
+  '')
+  + lib.optionalString enableReplxx ''
+    mkdir -p build/replxxLocal/
+    cp -r ${sources.replxx.src}/* build/replxxLocal/
+  '';
+
   installPhase = ''
     runHook preInstall
 
@@ -121,12 +117,26 @@ stdenv.mkDerivation rec {
     runHook postInstallCheck
   '';
 
-  meta = with lib; {
+  meta = {
     homepage = "https://github.com/dzaima/CBQN/";
     description = "BQN implementation in C";
-    license = licenses.gpl3Plus;
-    maintainers = with maintainers; [ AndersonTorres sternenseemann synthetica shnarazk detegr ];
-    platforms = platforms.all;
+    license = with lib.licenses; [
+      # https://github.com/dzaima/CBQN?tab=readme-ov-file#licensing
+      asl20
+      boost
+      gpl3Only
+      lgpl3Only
+      mit
+      mpl20
+    ];
     mainProgram = "cbqn";
+    maintainers = with lib.maintainers; [
+      AndersonTorres
+      detegr
+      shnarazk
+      sternenseemann
+      synthetica
+    ];
+    platforms = lib.platforms.all;
   };
 }
diff --git a/pkgs/development/interpreters/bqn/cbqn/replxx.nix b/pkgs/development/interpreters/bqn/cbqn/replxx.nix
deleted file mode 100644
index 71b479a4cda48..0000000000000
--- a/pkgs/development/interpreters/bqn/cbqn/replxx.nix
+++ /dev/null
@@ -1,37 +0,0 @@
-{ lib
-, fetchFromGitHub
-, stdenvNoCC
-}:
-
-stdenvNoCC.mkDerivation {
-  pname = "replxx";
-  version = "unstable-2023-10-31";
-
-  src = fetchFromGitHub {
-    owner = "dzaima";
-    repo = "replxx";
-    rev = "13f7b60f4f79c2f14f352a76d94860bad0fc7ce9";
-    hash = "sha256-xPuQ5YBDSqhZCwssbaN/FcTZlc3ampYl7nfl2bbsgBA=";
-  };
-
-  dontConfigure = true;
-  # The CBQN derivation will build replxx, here we just provide the source files.
-  dontBuild = true;
-
-  installPhase = ''
-    runHook preInstall
-
-    mkdir -p $out/dev
-    cp -r $src $out/dev
-
-    runHook postInstall
-  '';
-
-  meta = with lib; {
-    homepage = "https://github.com/dzaima/replxx";
-    description = "A replxx fork for CBQN";
-    license = licenses.free;
-    maintainers = with maintainers; [ AndersonTorres sternenseemann synthetica shnarazk detegr ];
-    platforms = platforms.all;
-  };
-}
diff --git a/pkgs/development/interpreters/bqn/cbqn/singeli.nix b/pkgs/development/interpreters/bqn/cbqn/singeli.nix
deleted file mode 100644
index 212b96b6cb3f0..0000000000000
--- a/pkgs/development/interpreters/bqn/cbqn/singeli.nix
+++ /dev/null
@@ -1,37 +0,0 @@
-{ lib
-, fetchFromGitHub
-, stdenvNoCC
-}:
-
-stdenvNoCC.mkDerivation {
-  pname = "singeli";
-  version = "unstable-2023-11-22";
-
-  src = fetchFromGitHub {
-    owner = "mlochbaum";
-    repo = "Singeli";
-    rev = "528faaf9e2a7f4f3434365bcd91d6c18c87c4f08";
-    hash = "sha256-/z1KHqflCqPGC9JU80jtgqdk2mkX06eWSziuf4TU4TM=";
-  };
-
-  dontConfigure = true;
-  # The CBQN derivation will build Singeli, here we just provide the source files.
-  dontBuild = true;
-
-  installPhase = ''
-    runHook preInstall
-
-    mkdir -p $out/dev
-    cp -r $src $out/dev
-
-    runHook postInstall
-  '';
-
-  meta = with lib; {
-    homepage = "https://github.com/mlochbaum/Singeli";
-    description = "A metaprogramming DSL for SIMD";
-    license = licenses.isc;
-    maintainers = with maintainers; [ AndersonTorres sternenseemann synthetica shnarazk detegr ];
-    platforms = platforms.all;
-  };
-}
diff --git a/pkgs/development/interpreters/bqn/cbqn/sources.nix b/pkgs/development/interpreters/bqn/cbqn/sources.nix
new file mode 100644
index 0000000000000..3b9ca78533e36
--- /dev/null
+++ b/pkgs/development/interpreters/bqn/cbqn/sources.nix
@@ -0,0 +1,60 @@
+# Sources required to build CBQN
+# Update them all at the same time, or else misbuilds will happen!
+# TODO: automate the update of this file
+
+{
+  fetchFromGitHub,
+}:
+
+{
+  cbqn = let
+    self = {
+      pname = "cbqn";
+      version = "0.7.0";
+
+      src = fetchFromGitHub {
+        owner = "dzaima";
+        repo = "CBQN";
+        rev = "v${self.version}";
+        hash = "sha256-TUK0HrJ1IyiVi9Y3S1IrK/d4/EZxdRdWyxsAwj79KEc=";
+      };
+    };
+  in
+    self;
+
+  cbqn-bytecode = {
+    pname = "cbqn-bytecode";
+    version = "0-unstable-2024-05-22";
+
+    src = fetchFromGitHub {
+      owner = "dzaima";
+      repo = "cbqnBytecode";
+      rev = "c5674783c11d7569e5a4d166600ffcde2409331d";
+      hash = "sha256-y7gqHzUxVUUVryutlq3Upuso8r3ZRSyF7ydMg1OVlwA=";
+    };
+  };
+
+  replxx = {
+    pname = "replxx";
+    version = "0-unstable-2023-10-31";
+
+    src = fetchFromGitHub {
+      owner = "dzaima";
+      repo = "replxx";
+      rev = "13f7b60f4f79c2f14f352a76d94860bad0fc7ce9";
+      hash = "sha256-xPuQ5YBDSqhZCwssbaN/FcTZlc3ampYl7nfl2bbsgBA=";
+    };
+  };
+
+  singeli = {
+    pname = "singeli";
+    version = "0-unstable-2024-02-26";
+
+    src = fetchFromGitHub {
+      owner = "mlochbaum";
+      repo = "Singeli";
+      rev = "ce6ef5d06d35777f0016bbfe0c6c1cf6a9c1b48e";
+      hash = "sha256-dDoWoq4LYMD2CKyPxXDAwoeH2E+f0FDyvngtWPEr67w=";
+    };
+  };
+}
diff --git a/pkgs/development/interpreters/bqn/mlochbaum-bqn/001-libbqn-path.patch b/pkgs/development/interpreters/bqn/mlochbaum-bqn/001-libbqn-path.patch
deleted file mode 100644
index b23c3de44af6d..0000000000000
--- a/pkgs/development/interpreters/bqn/mlochbaum-bqn/001-libbqn-path.patch
+++ /dev/null
@@ -1,12 +0,0 @@
-diff -Naur source-old/bqn.js source-new/bqn.js
---- source-old/bqn.js	1969-12-31 21:00:01.000000000 -0300
-+++ source-new/bqn.js	2021-10-03 01:28:00.268998916 -0300
-@@ -4,7 +4,7 @@
- let path = require('path');
- let fs = require('fs');
- 
--let bqn = require("./docs/bqn.js");
-+let bqn = require("@libbqn@");
- module.exports = bqn;
- let {fmt,fmtErr,sysvals,sysargs,makebqn,makerepl}=bqn;
- let {has,list,str,unstr,dynsys,req1str,makens}=bqn.util;
diff --git a/pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix b/pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix
deleted file mode 100644
index d217ec99ebe5a..0000000000000
--- a/pkgs/development/interpreters/bqn/mlochbaum-bqn/default.nix
+++ /dev/null
@@ -1,64 +0,0 @@
-{ lib
-, stdenvNoCC
-, fetchFromGitHub
-, makeWrapper
-, nodejs
-}:
-
-stdenvNoCC.mkDerivation rec {
-  pname = "bqn";
-  version = "unstable-2023-05-17";
-
-  src = fetchFromGitHub {
-    owner = "mlochbaum";
-    repo = "BQN";
-    rev = "070bd07dc10c291695215265218ec0ff856ce457";
-    hash = "sha256-GRIIzJwlJ+JTBHXZjoX/9vLFbAC7zyeuqVcrA/Jm/NA=";
-  };
-
-  nativeBuildInputs = [ makeWrapper ];
-
-  buildInputs = [ nodejs ];
-
-  patches = [
-    # Creates a @libbqn@ substitution variable, to be filled in the fixupPhase
-    ./001-libbqn-path.patch
-  ];
-
-  dontConfigure = true;
-
-  dontBuild = true;
-
-  installPhase = ''
-    runHook preInstall
-
-    mkdir -p $out/bin $out/share/${pname}
-    cp bqn.js $out/share/${pname}/bqn.js
-    cp docs/bqn.js $out/share/${pname}/libbqn.js
-
-    makeWrapper "${lib.getBin nodejs}/bin/node" "$out/bin/mbqn" \
-      --add-flags "$out/share/${pname}/bqn.js"
-
-    ln -s $out/bin/mbqn $out/bin/bqn
-
-    runHook postInstall
-  '';
-
-  fixupPhase = ''
-    runHook preFixup
-
-    substituteInPlace $out/share/${pname}/bqn.js \
-      --subst-var-by "libbqn" "$out/share/${pname}/libbqn.js"
-
-    runHook postFixup
-  '';
-
-  meta = with lib; {
-    homepage = "https://github.com/mlochbaum/BQN/";
-    description = "The original BQN implementation in Javascript";
-    license = licenses.isc;
-    maintainers = with maintainers; [ AndersonTorres ];
-    platforms = platforms.all;
-  };
-}
-# TODO: install docs and other stuff