2021-10-01 09:20:50 +00:00
|
|
|
{ lib
|
|
|
|
, stdenv
|
|
|
|
, fetchFromGitHub
|
2021-10-04 12:37:57 +00:00
|
|
|
, genBytecode ? false
|
2021-10-01 09:20:50 +00:00
|
|
|
, bqn-path ? null
|
2021-10-04 12:37:57 +00:00
|
|
|
, mbqn-source ? null
|
2021-10-01 09:20:50 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
2021-10-04 12:37:57 +00:00
|
|
|
cbqn-bytecode-files = fetchFromGitHub {
|
|
|
|
name = "cbqn-bytecode-files";
|
|
|
|
owner = "dzaima";
|
|
|
|
repo = "CBQN";
|
2022-05-18 14:49:53 +00:00
|
|
|
rev = "c39653c898531a2cdbf4cc5c764df6e37b1894a4";
|
|
|
|
hash = "sha256-JCEmkwh5Rv5+NQoxvefSrYnayU892/Wam+gjMgcQmO0=";
|
2021-10-01 09:20:50 +00:00
|
|
|
};
|
|
|
|
in
|
2021-10-04 12:37:57 +00:00
|
|
|
assert genBytecode -> ((bqn-path != null) && (mbqn-source != null));
|
2021-10-07 14:46:35 +00:00
|
|
|
|
2021-10-01 09:20:50 +00:00
|
|
|
stdenv.mkDerivation rec {
|
2021-10-04 12:37:57 +00:00
|
|
|
pname = "cbqn" + lib.optionalString (!genBytecode) "-standalone";
|
2022-05-18 14:49:53 +00:00
|
|
|
version = "0.pre+date=2022-05-06";
|
2021-10-01 09:20:50 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "dzaima";
|
|
|
|
repo = "CBQN";
|
2022-05-18 14:49:53 +00:00
|
|
|
rev = "3496a939b670f8c9ca2a04927378d6b7e9abd68e";
|
|
|
|
hash = "sha256-P+PoY4XF9oEw7VIpmybvPp+jxWHEo2zt1Lamayf1mHg=";
|
2021-10-01 09:20:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
sed -i '/SHELL =.*/ d' makefile
|
|
|
|
'';
|
|
|
|
|
2021-10-11 16:52:03 +00:00
|
|
|
makeFlags = [
|
|
|
|
"CC=${stdenv.cc.targetPrefix}cc"
|
|
|
|
];
|
2021-10-07 14:46:35 +00:00
|
|
|
|
2021-10-11 16:52:03 +00:00
|
|
|
preBuild = ''
|
|
|
|
# Purity: avoids git downloading bytecode files
|
2021-10-06 13:57:05 +00:00
|
|
|
touch src/gen/customRuntime
|
|
|
|
'' + (if genBytecode then ''
|
|
|
|
${bqn-path} genRuntime ${mbqn-source}
|
|
|
|
'' else ''
|
2022-05-18 14:49:53 +00:00
|
|
|
cp ${cbqn-bytecode-files}/src/gen/{compiles,formatter,runtime0,runtime1,src} src/gen/
|
2021-10-06 13:57:05 +00:00
|
|
|
'');
|
2021-10-01 09:20:50 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/bin/
|
|
|
|
cp BQN -t $out/bin/
|
2021-12-06 16:07:01 +00:00
|
|
|
# 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
|
2021-10-01 09:20:50 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/dzaima/CBQN/";
|
|
|
|
description = "BQN implementation in C";
|
|
|
|
license = licenses.gpl3Plus;
|
2022-05-18 14:49:53 +00:00
|
|
|
maintainers = with maintainers; [ AndersonTorres sternenseemann synthetica shnarazk ];
|
2021-10-01 09:20:50 +00:00
|
|
|
platforms = platforms.all;
|
|
|
|
};
|
|
|
|
}
|
2021-10-07 14:46:35 +00:00
|
|
|
# TODO: version cbqn-bytecode-files
|
2021-10-04 12:37:57 +00:00
|
|
|
# TODO: test suite
|