My personal project and infrastructure archive
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
nomicon/pkgs/development/interpreters/bqn/cbqn/default.nix

71 lines
1.7 KiB

{ lib
, stdenv
, fetchFromGitHub
, genBytecode ? false
, bqn-path ? null
, mbqn-source ? null
}:
let
cbqn-bytecode-files = fetchFromGitHub {
name = "cbqn-bytecode-files";
owner = "dzaima";
repo = "CBQN";
rev = "db686e89d4d2e9bfac3dddf306dff890135b2de1";
hash = "sha256-RJ751jCsAGjqQx3V5S5Uc611n+/TBs6G2o0q26x98NM=";
};
in
assert genBytecode -> ((bqn-path != null) && (mbqn-source != null));
stdenv.mkDerivation rec {
pname = "cbqn" + lib.optionalString (!genBytecode) "-standalone";
version = "0.pre+date=2021-11-06";
src = fetchFromGitHub {
owner = "dzaima";
repo = "CBQN";
rev = "cd866e1e45ce0f22bfacd25565ab912c06cb040f";
hash = "sha256-XuowrGDgrttRL/SY5si0nqHMKEidSNrQuquxNdBCW8o=";
};
dontConfigure = true;
postPatch = ''
sed -i '/SHELL =.*/ d' makefile
'';
makeFlags = [
"CC=${stdenv.cc.targetPrefix}cc"
];
preBuild = ''
# Purity: avoids git downloading bytecode files
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/
'');
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;
maintainers = with maintainers; [ AndersonTorres sternenseemann synthetica ];
platforms = platforms.all;
};
}
# TODO: version cbqn-bytecode-files
# TODO: test suite