depot/third_party/nixpkgs/pkgs/development/interpreters/bqn/cbqn/default.nix
Default email 818c48e259 Project import generated by Copybara.
GitOrigin-RevId: 14aef06d9b3ad1d07626bdbb16083b83f92dc6c1
2021-10-04 09:37:57 -03:00

75 lines
1.7 KiB
Nix

{ 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 = "94bb312d20919f942eabed3dca33c514de3c3227";
hash = "sha256-aFw5/F7/sYkYmxAnGeK8EwkoVrbEcjuJAD9YT+iW9Rw=";
};
in
assert genBytecode -> ((bqn-path != null) && (mbqn-source != null));
stdenv.mkDerivation rec {
pname = "cbqn" + lib.optionalString (!genBytecode) "-standalone";
version = "0.0.0+unstable=2021-10-01";
src = fetchFromGitHub {
owner = "dzaima";
repo = "CBQN";
rev = "3725bd58c758a749653080319766a33169551536";
hash = "sha256-xWp64inFZRqGGTrH6Hqbj7aA0vYPyd+FdetowTMTjPs=";
};
dontConfigure = true;
patches = [
# self-explaining
./001-remove-vendoring.diff
];
postPatch = ''
sed -i '/SHELL =.*/ d' makefile
'';
preBuild =
if genBytecode
then ''
${bqn-path} genRuntime ${mbqn-source}
''
else ''
cp ${cbqn-bytecode-files}/src/gen/{compiler,formatter,runtime0,runtime1,src} src/gen/
'';
makeFlags = [
"CC=${stdenv.cc.targetPrefix}cc"
];
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;
priority = if genBytecode then 0 else 10;
};
}
# TODO: factor and version cbqn-bytecode-files
# TODO: test suite