add piston nix pkg for brainfuck

This commit is contained in:
Dan Vargas 2022-03-18 10:11:16 -06:00
parent 16e4f08dfa
commit 96ffdb63dd
7 changed files with 56 additions and 36 deletions

View File

@ -1,22 +0,0 @@
#!/usr/bin/env bash
# Put instructions to build your package in here
PREFIX=$(realpath $(dirname $0))
git clone https://github.com/fabianishere/brainfuck.git
cd brainfuck
git checkout 06f84462e0a96487670a4b8024e3ec531e0377ee
mkdir -p build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=$PREFIX/ -DENABLE_EDITLINE=OFF
make -j$(nproc)
make install -j$(nproc)
cd ../../
rm -rf brainfuck

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
# Put 'export' statements here for environment variables
export PATH=$PWD/bin:$PATH

View File

@ -1,5 +0,0 @@
{
"language": "brainfuck",
"version": "2.7.3",
"aliases": ["bf"]
}

View File

@ -1,4 +0,0 @@
#!/usr/bin/env bash
# Put instructions to run the runtime
fold -w1 | brainfuck $1

View File

@ -1 +0,0 @@
-[--->+<]>------.----.

55
runtimes/brainfuck.nix Normal file
View File

@ -0,0 +1,55 @@
{pkgs, piston, ...}:
let
# All other BF packages are either marked as broken in nix-pkgs
# or have missing functionality. Yabi isn't perfect either.
pkg = pkgs.haskellPackages.yabi;
in piston.mkRuntime {
language = "brainfuck";
version = pkg.version;
aliases = [
"bf"
"yabi"
];
run = ''
# Yabi produces messages when parsing the BF file that are sent to stderr
# Yabi will also break when trying to take more input at EOF
${pkg}/bin/yabi "$1" 2> /dev/null
'';
tests = [
# stdout test
(piston.mkTest {
files = {
"test.bf" = ''-[--->+<]>------.----.'';
};
args = [];
stdin = "";
packages = [];
main = "test.bf";
})
# stdin test
(piston.mkTest {
files = {
"test.bf" = '',.,.'';
};
args = [];
stdin = "OK";
packages = [];
main = "test.bf";
})
# bf doesn't take args test
(piston.mkTest {
files = {
"test.bf" = ''-[--->+<]>------.----.'';
};
args = ["OK"];
stdin = "";
packages = [];
main = "test.bf";
})
];
}

View File

@ -58,4 +58,5 @@ args: {
"dotnet-sdk-fsharp-interactive" = import ./dotnet-sdk-fsharp-interactive.nix args; "dotnet-sdk-fsharp-interactive" = import ./dotnet-sdk-fsharp-interactive.nix args;
"dotnet-sdk-visual-basic" = import ./dotnet-sdk-visual-basic.nix args; "dotnet-sdk-visual-basic" = import ./dotnet-sdk-visual-basic.nix args;
"fpc-pascal" = import ./fpc-pascal.nix args; "fpc-pascal" = import ./fpc-pascal.nix args;
"brainfuck" = import ./brainfuck.nix args;
} }