commit 3d7f813ffb130b9cf856a3a0604010452416c5fb Author: rotterdam Date: Wed Mar 29 16:01:15 2023 -0300 Initial commit diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..b914ef1 --- /dev/null +++ b/flake.nix @@ -0,0 +1,11 @@ +{ + description = "My collection of flake templates"; + + outputs = { self }: { + templates = { + rust = { + path = ./rust; + description = "Rust template, using oxalica/rust-overlay"; + }; + }; + }; diff --git a/rust/.envrc b/rust/.envrc new file mode 100644 index 0000000..e31c306 --- /dev/null +++ b/rust/.envrc @@ -0,0 +1,4 @@ +if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then + source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs=" +fi +use flake diff --git a/rust/Cargo.toml b/rust/Cargo.toml new file mode 100644 index 0000000..1ec6963 --- /dev/null +++ b/rust/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "rust" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/rust/flake.nix b/rust/flake.nix new file mode 100644 index 0000000..56cd0b1 --- /dev/null +++ b/rust/flake.nix @@ -0,0 +1,30 @@ +{ + description = "Flake template for a rust project"; + + inputs = { + # nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + rust-overlay.url = "github:oxalica/rust-overlay"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, rust-overlay, flake-utils, ... }: + flake-utils.lib.eachDefaultSystem (system: + let + overlays = [ (import rust-overlay) ]; + pkgs = import nixpkgs { + inherit system overlays; + }; + in + with pkgs; + { + devShells.default = mkShell { + buildInputs = [ + rust-bin.stable.latest.default + ]; + packages = [ + rust-analyzer + ]; + }; + } + ); +} 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!"); +}