From efbce7d4aa5ec2d766f21767779ec4c606fde767 Mon Sep 17 00:00:00 2001 From: "Narazaki, Shuji" Date: Fri, 2 Dec 2022 04:06:49 +0900 Subject: [PATCH] cbqn: add enableReplxx option --- .../interpreters/bqn/cbqn/default.nix | 26 ++++++++++++++++--- pkgs/top-level/all-packages.nix | 17 ++++++++++++ 2 files changed, 39 insertions(+), 4 deletions(-) diff --git a/pkgs/development/interpreters/bqn/cbqn/default.nix b/pkgs/development/interpreters/bqn/cbqn/default.nix index 1766c45995a3..6e4c18c961ef 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 diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index a8e4e17ac52e..67e43424d86b 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -15762,7 +15762,9 @@ with pkgs; mbqn = callPackage ../development/interpreters/bqn/mlochbaum-bqn { }; cbqn = cbqn-bootstrap.phase2; + cbqn-replxx = cbqn-bootstrap.phase2-replxx; cbqn-standalone = cbqn-bootstrap.phase0; + cbqn-standalone-replxx = cbqn-bootstrap.phase0-replxx; # Below, the classic self-bootstrapping process cbqn-bootstrap = lib.dontRecurseIntoAttrs { @@ -15787,6 +15789,14 @@ with pkgs; mbqn-source = null; }; + phase0-replxx = callPackage ../development/interpreters/bqn/cbqn { + inherit (cbqn-bootstrap) stdenv; + genBytecode = false; + bqn-path = null; + mbqn-source = null; + enableReplxx = true; + }; + phase1 = callPackage ../development/interpreters/bqn/cbqn { inherit (cbqn-bootstrap) mbqn-source stdenv; genBytecode = true; @@ -15798,6 +15808,13 @@ with pkgs; genBytecode = true; bqn-path = "${buildPackages.cbqn-bootstrap.phase1}/bin/cbqn"; }; + + phase2-replxx = callPackage ../development/interpreters/bqn/cbqn { + inherit (cbqn-bootstrap) mbqn-source stdenv; + genBytecode = true; + bqn-path = "${buildPackages.cbqn-bootstrap.phase1}/bin/cbqn"; + enableReplxx = true; + }; }; dbqn = callPackage ../development/interpreters/bqn/dzaima-bqn {