diff --git a/packages/rust/1.50.0/build.sh b/packages/rust/1.50.0/build.sh deleted file mode 100755 index c3e41b1..0000000 --- a/packages/rust/1.50.0/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -curl -OL "https://static.rust-lang.org/dist/rust-1.50.0-x86_64-unknown-linux-gnu.tar.gz" -tar xzvf rust-1.50.0-x86_64-unknown-linux-gnu.tar.gz -rm rust-1.50.0-x86_64-unknown-linux-gnu.tar.gz diff --git a/packages/rust/1.50.0/compile b/packages/rust/1.50.0/compile deleted file mode 100644 index 201318a..0000000 --- a/packages/rust/1.50.0/compile +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# https://stackoverflow.com/questions/38041331/rust-compiler-cant-find-crate-for-std -# Rust compiler needs to find the stdlib to link against -rustc -o binary -L ${RUST_INSTALL_LOC}/rustc/lib -L ${RUST_INSTALL_LOC}/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib "$@" -chmod +x binary diff --git a/packages/rust/1.50.0/environment b/packages/rust/1.50.0/environment deleted file mode 100644 index 2a704ee..0000000 --- a/packages/rust/1.50.0/environment +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -# Put 'export' statements here for environment variables -export PATH=$PWD/rust-1.50.0-x86_64-unknown-linux-gnu/rustc/bin/:$PATH -export RUST_INSTALL_LOC=$PWD/rust-1.50.0-x86_64-unknown-linux-gnu diff --git a/packages/rust/1.50.0/metadata.json b/packages/rust/1.50.0/metadata.json deleted file mode 100644 index 57cefa0..0000000 --- a/packages/rust/1.50.0/metadata.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "language": "rust", - "version": "1.50.0", - "aliases": ["rs"] -} diff --git a/packages/rust/1.50.0/run b/packages/rust/1.50.0/run deleted file mode 100644 index d377dd9..0000000 --- a/packages/rust/1.50.0/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -shift -./binary "$@" diff --git a/packages/rust/1.50.0/test.rs b/packages/rust/1.50.0/test.rs deleted file mode 100644 index 9561664..0000000 --- a/packages/rust/1.50.0/test.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("OK"); -} diff --git a/packages/rust/1.56.1/build.sh b/packages/rust/1.56.1/build.sh deleted file mode 100644 index 6be556f..0000000 --- a/packages/rust/1.56.1/build.sh +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -curl -OL "https://static.rust-lang.org/dist/rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz" -tar xzvf rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz -rm rust-1.56.1-x86_64-unknown-linux-gnu.tar.gz diff --git a/packages/rust/1.56.1/compile b/packages/rust/1.56.1/compile deleted file mode 100644 index 201318a..0000000 --- a/packages/rust/1.56.1/compile +++ /dev/null @@ -1,6 +0,0 @@ -#!/usr/bin/env bash - -# https://stackoverflow.com/questions/38041331/rust-compiler-cant-find-crate-for-std -# Rust compiler needs to find the stdlib to link against -rustc -o binary -L ${RUST_INSTALL_LOC}/rustc/lib -L ${RUST_INSTALL_LOC}/rust-std-x86_64-unknown-linux-gnu/lib/rustlib/x86_64-unknown-linux-gnu/lib "$@" -chmod +x binary diff --git a/packages/rust/1.56.1/environment b/packages/rust/1.56.1/environment deleted file mode 100644 index c28b1b7..0000000 --- a/packages/rust/1.56.1/environment +++ /dev/null @@ -1,5 +0,0 @@ -#!/usr/bin/env bash - -# Put 'export' statements here for environment variables -export PATH=$PWD/rust-1.56.1-x86_64-unknown-linux-gnu/rustc/bin/:$PATH -export RUST_INSTALL_LOC=$PWD/rust-1.56.1-x86_64-unknown-linux-gnu diff --git a/packages/rust/1.56.1/metadata.json b/packages/rust/1.56.1/metadata.json deleted file mode 100644 index 1f7319a..0000000 --- a/packages/rust/1.56.1/metadata.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "language": "rust", - "version": "1.56.1", - "aliases": [ - "rs" - ] -} diff --git a/packages/rust/1.56.1/run b/packages/rust/1.56.1/run deleted file mode 100644 index d377dd9..0000000 --- a/packages/rust/1.56.1/run +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env bash - -shift -./binary "$@" diff --git a/packages/rust/1.56.1/test.rs b/packages/rust/1.56.1/test.rs deleted file mode 100644 index 9561664..0000000 --- a/packages/rust/1.56.1/test.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - println!("OK"); -} diff --git a/runtimes/default.nix b/runtimes/default.nix index 47bd12f..5a8c6a2 100644 --- a/runtimes/default.nix +++ b/runtimes/default.nix @@ -52,4 +52,5 @@ args: { "yabasic" = import ./yabasic.nix args; "emacs" = import ./emacs.nix args; "gnat-ada" = import ./gnat-ada.nix args; + "rust" = import ./rust.nix args; } diff --git a/runtimes/rust.nix b/runtimes/rust.nix new file mode 100644 index 0000000..4e4b6a4 --- /dev/null +++ b/runtimes/rust.nix @@ -0,0 +1,47 @@ +{pkgs, piston, ...}: +let + gccPackage = pkgs.gcc; # gcc is required for the linker + pkg = pkgs.rustc; +in piston.mkRuntime { + language = "rust"; + version = pkg.version; + + aliases = [ + "rs" + ]; + + compile = '' + ${pkg}/bin/rustc -o binary -C linker=${gccPackage}/bin/gcc $1 + chmod +x binary + ''; + + run = '' + shift + ./binary "$@" + ''; + + tests = [ + (piston.mkTest { + files = { + "test.rs" = '' + pub mod helper; + use std::env; + + fn main() { + let args: Vec = env::args().collect(); + helper::print_something(args[1].to_string()); + } + ''; + "helper.rs" = '' + pub fn print_something(what: String) -> () { + println!("{}", what); + } + ''; + }; + args = ["OK"]; + stdin = ""; + packages = []; + main = "test.rs"; + }) + ]; +}