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

72 lines
1.8 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 = "b000b951aa8f3590b196b4c09056604c0b32a168";
hash = "sha256-znW0xOXogP4TfifUmk3cs4aN/9mMSpSD2WJppmeI1Fg=";
};
in
assert genBytecode -> ((bqn-path != null) && (mbqn-source != null));
stdenv.mkDerivation rec {
pname = "cbqn" + lib.optionalString (!genBytecode) "-standalone";
version = "0.pre+date=2021-12-13";
src = fetchFromGitHub {
owner = "dzaima";
repo = "CBQN";
rev = "e7662b0f6a44add0749fba2a6d7309a5c1eb2601";
hash = "sha256-2nfkTZBIGHX5cok6Ea3KSewakZy8Ey8nSO2Fe4xGgvg=";
};
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/
# 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
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