From 2a163e5d30d3ff9eb904fede074270f210d80b85 Mon Sep 17 00:00:00 2001 From: Ryan Rodriguez Date: Sat, 9 Nov 2024 22:13:55 -0800 Subject: [PATCH 1/2] add a flake file for development environment --- flake.lock | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 35 +++++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..3093ae4a0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,60 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1726560853, + "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1730785428, + "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-unstable", + "type": "indirect" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..420080b03 --- /dev/null +++ b/flake.nix @@ -0,0 +1,35 @@ +{ + description = "Rust development environment with Cargo dependencies"; + + # Specify the inputs, such as nixpkgs + inputs = { + nixpkgs.url = "nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + # Define the outputs + outputs = { self, nixpkgs, flake-utils }: flake-utils.lib.eachDefaultSystem (system: let + pkgs = import nixpkgs { inherit system; }; + in { + # Define a devShell for development + devShell = pkgs.mkShell { + # Add Rust and Cargo to the environment + buildInputs = [ + pkgs.rustup + ]; + + # Optionally, set environment variables + CARGO_HOME = "./.cargo"; + RUST_BACKTRACE = "1"; # Enable backtrace for debugging + + # Optional shellHook to fetch dependencies when entering the shell + shellHook = '' + echo "Entering Rust development environment..." + rustup default nightly + cargo install rerun-cli + cargo fetch # Pre-fetch dependencies defined in Cargo.toml + ''; + }; + }); +} + From b4e0bdaf65c9e9488b96919a3882a5ec2faf30e5 Mon Sep 17 00:00:00 2001 From: Ryan Rodriguez Date: Sat, 9 Nov 2024 22:14:08 -0800 Subject: [PATCH 2/2] ignore .cargo --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 04b7fe06f..768a8c7cb 100644 --- a/.gitignore +++ b/.gitignore @@ -21,3 +21,4 @@ Cargo.lock *.DS_Store .idea/workspace.xml .idea/vcs.xml +.cargo