From 2bc715589512de0852f9ba9f609ffc40f5bb3182 Mon Sep 17 00:00:00 2001 From: Dan Vargas Date: Fri, 11 Feb 2022 11:14:14 -0700 Subject: [PATCH] add piston nix pkg for ghc-haskell --- packages/haskell/9.0.1/build.sh | 19 -------------- packages/haskell/9.0.1/compile | 6 ----- packages/haskell/9.0.1/environment | 1 - packages/haskell/9.0.1/metadata.json | 5 ---- packages/haskell/9.0.1/run | 4 --- packages/haskell/9.0.1/test.hs | 1 - runtimes/default.nix | 1 + runtimes/ghc-haskell.nix | 37 ++++++++++++++++++++++++++++ 8 files changed, 38 insertions(+), 36 deletions(-) delete mode 100755 packages/haskell/9.0.1/build.sh delete mode 100644 packages/haskell/9.0.1/compile delete mode 100644 packages/haskell/9.0.1/environment delete mode 100644 packages/haskell/9.0.1/metadata.json delete mode 100644 packages/haskell/9.0.1/run delete mode 100644 packages/haskell/9.0.1/test.hs create mode 100644 runtimes/ghc-haskell.nix diff --git a/packages/haskell/9.0.1/build.sh b/packages/haskell/9.0.1/build.sh deleted file mode 100755 index 50d63c2..0000000 --- a/packages/haskell/9.0.1/build.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -PREFIX=$(realpath $(dirname $0)) - -mkdir -p build - -cd build - -# Platform specific because a true source compile would require GHC to be installed already on the latest -curl -L "https://downloads.haskell.org/~ghc/9.0.1/ghc-9.0.1-x86_64-deb10-linux.tar.xz" -o ghc.tar.xz -tar xf ghc.tar.xz --strip-components=1 -rm ghc.tar.xz - -./configure --prefix="$PREFIX" -make install -j$(nproc) - -cd ../ - -rm -rf build diff --git a/packages/haskell/9.0.1/compile b/packages/haskell/9.0.1/compile deleted file mode 100644 index 18e268b..0000000 --- a/packages/haskell/9.0.1/compile +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# Compile haskell file(s) -rename 's/$/\.hs/' "$@" # Add .hs extension -ghc -dynamic -v0 -o out *.hs -chmod +x out diff --git a/packages/haskell/9.0.1/environment b/packages/haskell/9.0.1/environment deleted file mode 100644 index bd0ff98..0000000 --- a/packages/haskell/9.0.1/environment +++ /dev/null @@ -1 +0,0 @@ -export PATH=$PWD/bin:$PATH \ No newline at end of file diff --git a/packages/haskell/9.0.1/metadata.json b/packages/haskell/9.0.1/metadata.json deleted file mode 100644 index d58d528..0000000 --- a/packages/haskell/9.0.1/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "haskell", - "version": "9.0.1", - "aliases": ["haskell", "hs"] -} diff --git a/packages/haskell/9.0.1/run b/packages/haskell/9.0.1/run deleted file mode 100644 index 6955ba9..0000000 --- a/packages/haskell/9.0.1/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -shift # Filename is only used to compile -./out "$@" diff --git a/packages/haskell/9.0.1/test.hs b/packages/haskell/9.0.1/test.hs deleted file mode 100644 index a8dd75a..0000000 --- a/packages/haskell/9.0.1/test.hs +++ /dev/null @@ -1 +0,0 @@ -main = putStrLn "OK" \ No newline at end of file diff --git a/runtimes/default.nix b/runtimes/default.nix index c09b8f5..b6f99ae 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -42,4 +42,5 @@ args: { "jelly" = import ./jelly.nix args; "openjdk-java" = import ./openjdk-java.nix args; "iverilog" = import ./iverilog.nix args; + "ghc-haskell" = import ./ghc-haskell.nix args; } diff --git a/runtimes/ghc-haskell.nix b/runtimes/ghc-haskell.nix new file mode 100644 index 0000000..81180f6 --- /dev/null +++ b/runtimes/ghc-haskell.nix @@ -0,0 +1,37 @@ +{pkgs, piston, ...}: +let + pkg = pkgs.haskell.compiler.ghcHEAD; +in piston.mkRuntime { + language = "haskell"; + version = pkg.version; + runtime = "ghc"; + + aliases = [ + "hs" + ]; + + compile = '' + rename 's/$/\.hs/' "$@" # Add .hs extension + ${pkg}/bin/ghc -dynamic -v0 -o out *.hs + chmod +x out + ''; + + run = '' + shift # Filename is only used to compile + ./out "$@" + ''; + + tests = [ + (piston.mkTest { + files = { + "test.hs" = '' + main = putStrLn "OK" + ''; + }; + args = []; + stdin = ""; + packages = []; + main = "test.hs"; + }) + ]; +} \ No newline at end of file