summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkshay <[email protected]>2023-04-15 13:44:32 +0100
committerAkshay <[email protected]>2023-04-15 13:44:32 +0100
commit316537bb60099d8535d3d91b7dc39d57be2188a3 (patch)
treec3fc73bec852cfaee692c34f45b6ae3cbae79e8d
init rust-bin flake templateHEADmaster
-rw-r--r--.gitignore1
-rw-r--r--Cargo.lock7
-rw-r--r--Cargo.toml8
-rw-r--r--flake.lock24
-rw-r--r--flake.nix51
-rw-r--r--src/main.rs3
6 files changed, 94 insertions, 0 deletions
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..b425a03
--- /dev/null
+++ b/Cargo.lock
@@ -0,0 +1,7 @@
1# This file is automatically @generated by Cargo.
2# It is not intended for manual editing.
3version = 3
4
5[[package]]
6name = "rust-bin"
7version = "0.1.0"
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000..c97aa53
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,8 @@
1[package]
2name = "rust-bin"
3version = "0.1.0"
4edition = "2021"
5
6# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7
8[dependencies]
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..f231e8c
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,24 @@
1{
2 "nodes": {
3 "nixpkgs": {
4 "locked": {
5 "lastModified": 1677852945,
6 "narHash": "sha256-liiVJjkBTuBTAkRW3hrI8MbPD2ImYzwUpa7kvteiKhM=",
7 "path": "/nix/store/cgfz9cycn82cwhvpaskq80bfw0k711gq-source",
8 "rev": "f5ffd5787786dde3a8bf648c7a1b5f78c4e01abb",
9 "type": "path"
10 },
11 "original": {
12 "id": "nixpkgs",
13 "type": "indirect"
14 }
15 },
16 "root": {
17 "inputs": {
18 "nixpkgs": "nixpkgs"
19 }
20 }
21 },
22 "root": "root",
23 "version": 7
24}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..28b7a60
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,51 @@
1{
2 description = "build rust binaries";
3
4 outputs = { self, nixpkgs }:
5 let
6 supportedSystems = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ];
7 forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
8 nixpkgsFor = forAllSystems (system: import nixpkgs {
9 inherit system;
10 overlays = [ self.overlays.default ];
11 });
12 in
13 {
14
15 overlays.default = final: prev: {
16 rust-bin =
17 let
18 packageMeta = (final.lib.importTOML ./Cargo.toml).package;
19 in
20 final.rustPlatform.buildRustPackage {
21 pname = packageMeta.name;
22 inherit (packageMeta) version;
23 src = self;
24 cargoLock.lockFile = ./Cargo.lock;
25 };
26 };
27
28 packages = forAllSystems (system: {
29 inherit (nixpkgsFor."${system}") rust-bin;
30 });
31
32 defaultPackage = forAllSystems (system: self.packages."${system}".rust-bin);
33
34 devShell = forAllSystems (system:
35 let
36 pkgs = nixpkgsFor."${ system}";
37 in
38 pkgs.mkShell {
39 nativeBuildInputs = [
40 pkgs.rustc
41 pkgs.cargo
42 pkgs.rustfmt
43 pkgs.rust-analyzer
44 pkgs.cargo-watch
45 ];
46 RUST_BACKTRACE = 1;
47 }
48 );
49
50 };
51}
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 @@
1fn main() {
2 println!("Hello, world!");
3}