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";
|
2021-10-07 14:46:35 +00:00
|
|
|
rev = "4d23479cdbd5ac6eb512c376ade58077b814b2b7";
|
|
|
|
hash = "sha256-MTvg4lOB26bqvJTqV71p4Y4qDjTYaOE40Jk4Sle/hsY=";
|
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";
|
2021-10-07 14:46:35 +00:00
|
|
|
version = "0.pre+unstable=2021-10-05";
|
2021-10-01 09:20:50 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "dzaima";
|
|
|
|
repo = "CBQN";
|
2021-10-07 14:46:35 +00:00
|
|
|
rev = "e23dab20daff9c0dacc2561c616174af72029a3e";
|
|
|
|
hash = "sha256-amVKKD9hD5A+LbqglXHLKEsYqFSSztdXs1FCoNJyCJ4=";
|
2021-10-01 09:20:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
dontConfigure = true;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
sed -i '/SHELL =.*/ d' makefile
|
|
|
|
'';
|
|
|
|
|
2021-10-06 13:57:05 +00:00
|
|
|
preBuild = ''
|
2021-10-07 14:46:35 +00:00
|
|
|
# otherwise cbqn defaults to clang
|
|
|
|
makeFlagsArray+=("CC=$CC")
|
|
|
|
|
2021-10-06 13:57:05 +00:00
|
|
|
# inform make we are providing the runtime ourselves
|
|
|
|
touch src/gen/customRuntime
|
|
|
|
'' + (if genBytecode then ''
|
|
|
|
${bqn-path} genRuntime ${mbqn-source}
|
|
|
|
'' else ''
|
|
|
|
cp ${cbqn-bytecode-files}/src/gen/{compiler,formatter,runtime0,runtime1,src} src/gen/
|
|
|
|
'');
|
2021-10-01 09:20:50 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/bin/
|
|
|
|
cp BQN -t $out/bin/
|
|
|
|
ln -s $out/bin/BQN $out/bin/bqn
|
|
|
|
ln -s $out/bin/BQN $out/bin/cbqn
|
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
homepage = "https://github.com/dzaima/CBQN/";
|
|
|
|
description = "BQN implementation in C";
|
|
|
|
license = licenses.gpl3Plus;
|
2021-10-04 12:37:57 +00:00
|
|
|
maintainers = with maintainers; [ AndersonTorres sternenseemann synthetica ];
|
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
|