From f5f1be1e526bec8d5f83c597319d9f4260c007ec Mon Sep 17 00:00:00 2001 From: voidarc Date: Wed, 1 Apr 2026 14:13:04 +0100 Subject: [PATCH] initial with rust --- flake.nix | 14 ++++++++++++++ rust-template | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 flake.nix create mode 100644 rust-template diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e00084b --- /dev/null +++ b/flake.nix @@ -0,0 +1,14 @@ +{ + description = "A very basic flake"; + + outputs = + { self }: + { + templates = { + rust = { + path = ./rust-template; + description = "A standard Rust development environment"; + }; + }; + }; +} diff --git a/rust-template b/rust-template new file mode 100644 index 0000000..69c9a43 --- /dev/null +++ b/rust-template @@ -0,0 +1,50 @@ +{ + description = "A simple Rust development environment"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + utils, + }: + utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + in + { + devShells.default = pkgs.mkShell { + + name = "rustshell"; + + buildInputs = with pkgs; [ + # Rust toolchain + rustc + cargo + rustfmt + clippy + rust-analyzer + + # Common dependencies for Rust crates + pkg-config + openssl + ]; + + # Environment variables + shellHook = '' + export RUST_BACKTRACE=1 + + # Trigger zsh if not already in it + if [[ -z "$ZSH_VERSION" ]]; then + exec zsh + fi + ''; + }; + } + ); +}