about summary refs log tree commit diff
path: root/pkgs/development/interpreters/bqn
diff options
context:
space:
mode:
authorNarazaki, Shuji <shujinarazaki@protonmail.com>2022-12-02 04:06:49 +0900
committerNarazaki, Shuji <shujinarazaki@protonmail.com>2022-12-21 14:17:29 +0900
commitefbce7d4aa5ec2d766f21767779ec4c606fde767 (patch)
tree0387ceb7aa279a1734f4abb173e64602d4dfb327 /pkgs/development/interpreters/bqn
parentcc620a6e594ba1527227f158ee964c8eb607308e (diff)
cbqn: add enableReplxx option
Diffstat (limited to 'pkgs/development/interpreters/bqn')
-rw-r--r--pkgs/development/interpreters/bqn/cbqn/default.nix26
1 files changed, 22 insertions, 4 deletions
diff --git a/pkgs/development/interpreters/bqn/cbqn/default.nix b/pkgs/development/interpreters/bqn/cbqn/default.nix
index 1766c45995a37..6e4c18c961eff 100644
--- a/pkgs/development/interpreters/bqn/cbqn/default.nix
+++ b/pkgs/development/interpreters/bqn/cbqn/default.nix
@@ -4,11 +4,13 @@
 , genBytecode ? false
 , bqn-path ? null
 , mbqn-source ? null
+, enableReplxx ? false
 , libffi
 , pkg-config
 }:
 
 let
+  # TODO: these submodules should be separated libraries
   cbqn-bytecode-files = fetchFromGitHub {
     name = "cbqn-bytecode-files";
     owner = "dzaima";
@@ -16,6 +18,13 @@ let
     rev = "3df8ae563a626ff7ae0683643092f0c3bc2481e5";
     hash = "sha256:0rh9qp1bdm9aa77l0kn9n4jdy08gl6l7898lncskxiq9id6xvyb8";
   };
+  replxx-submodule = fetchFromGitHub {
+    name = "replxx-submodule";
+    owner = "dzaima";
+    repo = "replxx";
+    rev = "ba94c293caad52486df8712e808783df9a8f4501";
+    hash = "sha256-pMLvURksj/5k5b6BTwWxjomoROMOE5+GRjyaoqu/iYE=";
+  };
 in
 assert genBytecode -> ((bqn-path != null) && (mbqn-source != null));
 
@@ -26,8 +35,8 @@ stdenv.mkDerivation rec {
   src = fetchFromGitHub {
     owner = "dzaima";
     repo = "CBQN";
-    rev = "dbc7c83f7085d05e87721bedf1ee38931f671a8e";
-    hash = "sha256:0nal1fs9y7nyx4d5q1qw868lxk7mivzw2y16wc3hw97pq4qf0dpb";
+    rev = "49c0d9a355698f54fff2c0caa177e2b341fabb45";
+    hash = "sha256-jm2ZzFxhr9o4nFR2rjYJz/4GH+WFnfU4QDovrOPI3jQ=";
   };
 
   nativeBuildInputs = [
@@ -47,7 +56,8 @@ stdenv.mkDerivation rec {
 
   makeFlags = [
     "CC=${stdenv.cc.targetPrefix}cc"
-  ];
+  ]
+  ++ lib.optional enableReplxx "REPLXX=1";
 
   preBuild = ''
     # Purity: avoids git downloading bytecode files
@@ -56,7 +66,15 @@ stdenv.mkDerivation rec {
     ${bqn-path} ./build/genRuntime ${mbqn-source} build/bytecodeLocal/
   '' else ''
     cp ${cbqn-bytecode-files}/src/gen/{compiles,explain,formatter,runtime0,runtime1,src} build/bytecodeLocal/gen/
-  '');
+  '')
+  + lib.optionalString enableReplxx ''
+    cp -r ${replxx-submodule} build/replxxLocal/
+  ''
+  # Need to adjust ld flags for darwin manually
+  # https://github.com/dzaima/CBQN/issues/26
+  + lib.optionalString stdenv.hostPlatform.isDarwin ''
+    makeFlagsArray+=(LD_LIBS="-ldl -lffi")
+  '';
 
   installPhase = ''
      runHook preInstall