cbqn: 2022-11-27 -> 2023-02-01

This commit is contained in:
skykanin 2023-03-16 20:34:31 +01:00 committed by Anderson Torres
parent 38637c5c8f
commit 4db65a7ec4
4 changed files with 136 additions and 33 deletions

View File

@ -0,0 +1,35 @@
{ lib
, fetchFromGitHub
, stdenvNoCC
}:
stdenvNoCC.mkDerivation {
pname = "cbqn-bytecode";
version = "unstable-2023-01-27";
src = fetchFromGitHub {
owner = "dzaima";
repo = "cbqnBytecode";
rev = "b2f47806ea770451d06d04e20177baeaec92e6dd";
hash = "sha256-dukpEB5qg6jF4AIHKK+atTvCKZTVtJ1M/nw7+SNp250=";
};
dontConfigure = true;
dontBuild = true;
installPhase = ''
runHook preInstall
install -D $src/gen/{compiles,explain,formatter,runtime0,runtime1,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 ];
platforms = platforms.all;
};
}

View File

@ -1,10 +1,13 @@
{ lib
{ callPackage
, lib
, stdenv
, stdenvNoCC
, fetchFromGitHub
, genBytecode ? false
, bqn-path ? null
, mbqn-source ? null
, enableReplxx ? false
, enableSingeli ? stdenv.hostPlatform.avx2Support
# No support for macOS' .dylib on the CBQN side
, enableLibcbqn ? stdenv.hostPlatform.isLinux
, libffi
@ -12,33 +15,22 @@
}:
let
# TODO: these submodules should be separated libraries
cbqn-bytecode-files = fetchFromGitHub {
name = "cbqn-bytecode-files";
owner = "dzaima";
repo = "CBQN";
rev = "3df8ae563a626ff7ae0683643092f0c3bc2481e5";
hash = "sha256:0rh9qp1bdm9aa77l0kn9n4jdy08gl6l7898lncskxiq9id6xvyb8";
};
replxx-submodule = fetchFromGitHub {
name = "replxx-submodule";
owner = "dzaima";
repo = "replxx";
rev = "ba94c293caad52486df8712e808783df9a8f4501";
hash = "sha256-pMLvURksj/5k5b6BTwWxjomoROMOE5+GRjyaoqu/iYE=";
};
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; };
in
assert genBytecode -> ((bqn-path != null) && (mbqn-source != null));
stdenv.mkDerivation rec {
pname = "cbqn" + lib.optionalString (!genBytecode) "-standalone";
version = "0.pre+date=2022-11-27";
version = "unstable-2023-02-01";
src = fetchFromGitHub {
owner = "dzaima";
repo = "CBQN";
rev = "49c0d9a355698f54fff2c0caa177e2b341fabb45";
hash = "sha256-jm2ZzFxhr9o4nFR2rjYJz/4GH+WFnfU4QDovrOPI3jQ=";
rev = "05c1270344908e98c9f2d06b3671c3646f8634c3";
hash = "sha256-wKeyYWMgTZPr+Ienz3xnsXeD67vwdK4sXbQlW+GpQho=";
};
nativeBuildInputs = [
@ -62,7 +54,7 @@ stdenv.mkDerivation rec {
buildFlags = [
# interpreter binary
"o3"
(lib.flatten (if enableSingeli then ["o3n-singeli" "f='-mavx2'"] else ["o3"]))
] ++ lib.optionals enableLibcbqn [
# embeddable interpreter as a shared lib
"shared-o3"
@ -74,11 +66,14 @@ stdenv.mkDerivation rec {
'' + (if genBytecode then ''
${bqn-path} ./build/genRuntime ${mbqn-source} build/bytecodeLocal/
'' else ''
cp ${cbqn-bytecode-files}/src/gen/{compiles,explain,formatter,runtime0,runtime1,src} build/bytecodeLocal/gen/
cp -r ${cbqn-bytecode-submodule}/dev/* build/bytecodeLocal/gen/
'')
+ lib.optionalString enableReplxx ''
cp -r ${replxx-submodule} build/replxxLocal/
'';
cp -r ${replxx-submodule}/dev/* build/replxxLocal/
''
+ lib.optionalString enableSingeli ''
cp -r ${singeli-submodule}/dev/* build/singeliLocal/
'';
outputs = [
"out"
@ -88,20 +83,20 @@ stdenv.mkDerivation rec {
];
installPhase = ''
runHook preInstall
runHook preInstall
mkdir -p $out/bin/
cp BQN -t $out/bin/
# note guard condition for case-insensitive filesystems
[ -e $out/bin/bqn ] || ln -s $out/bin/BQN $out/bin/bqn
[ -e $out/bin/cbqn ] || ln -s $out/bin/BQN $out/bin/cbqn
mkdir -p $out/bin/
cp BQN -t $out/bin/
# note guard condition for case-insensitive filesystems
[ -e $out/bin/bqn ] || ln -s $out/bin/BQN $out/bin/bqn
[ -e $out/bin/cbqn ] || ln -s $out/bin/BQN $out/bin/cbqn
''
+ lib.optionalString enableLibcbqn ''
install -Dm644 include/bqnffi.h -t "$dev/include"
install -Dm755 libcbqn${stdenv.hostPlatform.extensions.sharedLibrary} -t "$lib/lib"
install -Dm644 include/bqnffi.h -t "$dev/include"
install -Dm755 libcbqn${stdenv.hostPlatform.extensions.sharedLibrary} -t "$lib/lib"
''
+ ''
runHook postInstall
runHook postInstall
'';
meta = with lib; {
@ -112,5 +107,4 @@ stdenv.mkDerivation rec {
platforms = platforms.all;
};
}
# TODO: version cbqn-bytecode-files
# TODO: test suite

View File

@ -0,0 +1,37 @@
{ lib
, fetchFromGitHub
, stdenvNoCC
}:
stdenvNoCC.mkDerivation {
pname = "replxx";
version = "unstable-2023-01-21";
src = fetchFromGitHub {
owner = "dzaima";
repo = "replxx";
rev = "eb6bcecff4ca6051120c99e9dd64c3bd20fcc42f";
hash = "sha256-cb486FGF+4sUxgBbRfnbTTnZn2WQ3p93fSwDRCEtFJg=";
};
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 ];
platforms = platforms.all;
};
}

View File

@ -0,0 +1,37 @@
{ lib
, fetchFromGitHub
, stdenvNoCC
}:
stdenvNoCC.mkDerivation {
pname = "singeli";
version = "unstable-2023-01-23";
src = fetchFromGitHub {
owner = "mlochbaum";
repo = "Singeli";
rev = "0bc519ccbbe4051204d40bfc861a5bed7132e95f";
hash = "sha256-zo4yr9t3hp6BOX1ac3md6R/O+hl5MphZdCmI8nNP9Yc=";
};
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 ];
platforms = platforms.all;
};
}