From 6156cbfe8b4a9bdd4f703a73900972b6de92e26a Mon Sep 17 00:00:00 2001 From: Marty Sluijtman Date: Thu, 3 Jul 2025 12:37:07 +0200 Subject: [PATCH] Rust template --- crude/.gitignore | 2 +- rust/.envrc | 1 + rust/.gitignore | 10 ++++++++++ rust/Cargo.toml | 6 ++++++ rust/flake.nix | 46 ++++++++++++++++++++++++++++++++++++++++++++++ rust/src/main.rs | 3 +++ 6 files changed, 67 insertions(+), 1 deletion(-) create mode 100644 rust/.envrc create mode 100644 rust/.gitignore create mode 100644 rust/Cargo.toml create mode 100644 rust/flake.nix create mode 100644 rust/src/main.rs diff --git a/crude/.gitignore b/crude/.gitignore index c0e0d42..f33a36c 100644 --- a/crude/.gitignore +++ b/crude/.gitignore @@ -1,3 +1,3 @@ result .direnv -.pdf +*.pdf diff --git a/rust/.envrc b/rust/.envrc new file mode 100644 index 0000000..3550a30 --- /dev/null +++ b/rust/.envrc @@ -0,0 +1 @@ +use flake diff --git a/rust/.gitignore b/rust/.gitignore new file mode 100644 index 0000000..b865012 --- /dev/null +++ b/rust/.gitignore @@ -0,0 +1,10 @@ +/target +result +/.direnv + + +# Added by cargo +# +# already existing elements were commented out + +#/target diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 0000000..bee2783 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "myapp" +version = "0.1.0" +edition = "2024" + +[dependencies] diff --git a/rust/flake.nix b/rust/flake.nix new file mode 100644 index 0000000..ebdc60e --- /dev/null +++ b/rust/flake.nix @@ -0,0 +1,46 @@ +{ + inputs = { + naersk.url = "github:nix-community/naersk/master"; + nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + utils, + naersk, + }: + utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + naersk-lib = pkgs.callPackage naersk { }; + in + { + defaultPackage = naersk-lib.buildPackage { + src = ./.; + # nativeBuildInputs = with pkgs; [ + # ]; + # LD_LIBRARY_PATH = pkgs.lib.makeLibraryPath nativeBuildInputs; + RUST_SRC_PATH = pkgs.rustPlatform.rustLibSrc; + }; + devShell = + with pkgs; + mkShell { + buildInputs = [ + cargo + rustc + rustfmt + pre-commit + rustPackages.clippy + openssl + pkg-config + ]; + RUST_SRC_PATH = rustPlatform.rustLibSrc; + RUST_BACKTRACE = 1; + }; + } + ); +} diff --git a/rust/src/main.rs b/rust/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/rust/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}