From c0343c15aeffb662c0ec975e1c6acbe0c4c1fbaa Mon Sep 17 00:00:00 2001 From: NotAShelf Date: Sun, 1 Dec 2024 11:31:39 +0300 Subject: [PATCH] initial commit --- .envrc | 0 .gitignore | 1 + Cargo.lock | 7 +++++++ Cargo.toml | 6 ++++++ default.nix | 8 ++++++++ flake.lock | 26 ++++++++++++++++++++++++++ flake.nix | 24 ++++++++++++++++++++++++ shell.nix | 20 ++++++++++++++++++++ src/main.rs | 3 +++ 9 files changed, 95 insertions(+) create mode 100644 .envrc create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 default.nix create mode 100644 flake.lock create mode 100644 flake.nix create mode 100644 shell.nix create mode 100644 src/main.rs diff --git a/.envrc b/.envrc new file mode 100644 index 0000000..e69de29 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..785168c --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "frzn-challenge" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..24ebc17 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,6 @@ +[package] +name = "frzn-challenge" +version = "0.1.0" +edition = "2021" + +[dependencies] diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..58798a6 --- /dev/null +++ b/default.nix @@ -0,0 +1,8 @@ +{rustPlatform}: +rustPlatform.buildRustPackage { + pname = "sample-rust"; + version = "0.0.1"; + + src = ./.; + cargoLock.lockFile = ./Cargo.lock; +} diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..f29d625 --- /dev/null +++ b/flake.lock @@ -0,0 +1,26 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1733039856, + "narHash": "sha256-CAvvt3N7MWFlEpspYtfth5jWzbHQUAUOufOVXgm03rw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "0a644d62935fd8c0e6d9244c2ee2e8f6c2b6158c", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..c707ab8 --- /dev/null +++ b/flake.nix @@ -0,0 +1,24 @@ +{ + description = "Rust Project Template"; + inputs.nixpkgs.url = "github:NixOS/nixpkgs"; + + outputs = { + self, + nixpkgs, + }: let + systems = ["x86_64-linux" "aarch64-linux"]; + forEachSystem = nixpkgs.lib.genAttrs systems; + + pkgsForEach = nixpkgs.legacyPackages; + in rec { + packages = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./default.nix {}; + }); + + devShells = forEachSystem (system: { + default = pkgsForEach.${system}.callPackage ./shell.nix {}; + }); + + hydraJobs = packages; + }; +} diff --git a/shell.nix b/shell.nix new file mode 100644 index 0000000..8150363 --- /dev/null +++ b/shell.nix @@ -0,0 +1,20 @@ +{ + callPackage, + rust-analyzer, + rustfmt, + clippy, + cargo, +}: let + mainPkg = callPackage ./default.nix {}; +in + mainPkg.overrideAttrs (oa: { + nativeBuildInputs = + [ + # Additional rust tooling + rust-analyzer + rustfmt + clippy + cargo + ] + ++ (oa.nativeBuildInputs or []); + }) diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..e7a11a9 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,3 @@ +fn main() { + println!("Hello, world!"); +}