From 96ffdb63ddc8f8a1dd34f6d559a236ba6630082d Mon Sep 17 00:00:00 2001 From: Dan Vargas Date: Fri, 18 Mar 2022 10:11:16 -0600 Subject: [PATCH] add piston nix pkg for brainfuck --- packages/brainfuck/2.7.3/build.sh | 22 ----------- packages/brainfuck/2.7.3/environment | 4 -- packages/brainfuck/2.7.3/metadata.json | 5 --- packages/brainfuck/2.7.3/run | 4 -- packages/brainfuck/2.7.3/test.bf | 1 - runtimes/brainfuck.nix | 55 ++++++++++++++++++++++++++ runtimes/default.nix | 1 + 7 files changed, 56 insertions(+), 36 deletions(-) delete mode 100644 packages/brainfuck/2.7.3/build.sh delete mode 100644 packages/brainfuck/2.7.3/environment delete mode 100644 packages/brainfuck/2.7.3/metadata.json delete mode 100644 packages/brainfuck/2.7.3/run delete mode 100644 packages/brainfuck/2.7.3/test.bf create mode 100644 runtimes/brainfuck.nix diff --git a/packages/brainfuck/2.7.3/build.sh b/packages/brainfuck/2.7.3/build.sh deleted file mode 100644 index 50c1868..0000000 --- a/packages/brainfuck/2.7.3/build.sh +++ /dev/null @@ -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 diff --git a/packages/brainfuck/2.7.3/environment b/packages/brainfuck/2.7.3/environment deleted file mode 100644 index 780b668..0000000 --- a/packages/brainfuck/2.7.3/environment +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# Put 'export' statements here for environment variables -export PATH=$PWD/bin:$PATH diff --git a/packages/brainfuck/2.7.3/metadata.json b/packages/brainfuck/2.7.3/metadata.json deleted file mode 100644 index a9f3083..0000000 --- a/packages/brainfuck/2.7.3/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "brainfuck", - "version": "2.7.3", - "aliases": ["bf"] -} diff --git a/packages/brainfuck/2.7.3/run b/packages/brainfuck/2.7.3/run deleted file mode 100644 index 7c4e7dd..0000000 --- a/packages/brainfuck/2.7.3/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -# Put instructions to run the runtime -fold -w1 | brainfuck $1 diff --git a/packages/brainfuck/2.7.3/test.bf b/packages/brainfuck/2.7.3/test.bf deleted file mode 100644 index d0c07ec..0000000 --- a/packages/brainfuck/2.7.3/test.bf +++ /dev/null @@ -1 +0,0 @@ --[--->+<]>------.----. \ No newline at end of file diff --git a/runtimes/brainfuck.nix b/runtimes/brainfuck.nix new file mode 100644 index 0000000..3acf84b --- /dev/null +++ b/runtimes/brainfuck.nix @@ -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"; + }) + ]; +} \ No newline at end of file diff --git a/runtimes/default.nix b/runtimes/default.nix index b2cf206..2f230c9 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -58,4 +58,5 @@ args: { "dotnet-sdk-fsharp-interactive" = import ./dotnet-sdk-fsharp-interactive.nix args; "dotnet-sdk-visual-basic" = import ./dotnet-sdk-visual-basic.nix args; "fpc-pascal" = import ./fpc-pascal.nix args; + "brainfuck" = import ./brainfuck.nix args; }