feat(rust): add rust to the templates

This commit is contained in:
Artur Manuel 2024-08-14 23:44:43 +01:00
commit 9083ff41ab
Failed to generate hash of commit
8 changed files with 139 additions and 0 deletions

View file

@ -15,6 +15,10 @@
path = ./templates/go;
description = "go flake template";
};
"rust" = {
path = ./templates/rust;
description = "rust flake template";
};
};
};
}

7
templates/rust/Cargo.lock generated Normal file
View file

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "rust-app"
version = "0.1.0"

View file

@ -0,0 +1,8 @@
[package]
name = "rust-app"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

61
templates/rust/flake.lock generated Normal file
View file

@ -0,0 +1,61 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1723673859,
"narHash": "sha256-FLYl6raDlRSUf6o3DkbCg/KkOUBGHcyNKZ0RlzoSLcA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "c55e2908deb848d0e94d8170cb4b0a1e9bc30c8c",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1718428119,
"narHash": "sha256-WdWDpNaq6u1IPtxtYHHWpl5BmabtpmLnMAx0RdJ/vo8=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "e6cea36f83499eb4e9cd184c8a8e823296b50ad5",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"rust": "rust"
}
},
"rust": {
"inputs": {
"nixpkgs": "nixpkgs_2"
},
"locked": {
"lastModified": 1723602049,
"narHash": "sha256-Z/noCSn9WPkv7O77dWKLcBxe4Ub4bWyNzsL5JhjaQfw=",
"owner": "oxalica",
"repo": "rust-overlay",
"rev": "ea0bf33a11a26a62c60123c49d96011da396602c",
"type": "github"
},
"original": {
"owner": "oxalica",
"repo": "rust-overlay",
"type": "github"
}
}
},
"root": "root",
"version": 7
}

41
templates/rust/flake.nix Normal file
View file

@ -0,0 +1,41 @@
{
description = "Rust Developer Environment";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
rust.url = "github:oxalica/rust-overlay";
};
outputs = { self, nixpkgs, rust }: let
systems = [
"x86_64-linux"
"aarch64-linux"
];
forAllSystems = nixpkgs.lib.genAttrs systems;
in {
packages = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust)
];
};
inherit system;
in {
rust-app = pkgs.callPackage ./nix/package.nix { };
default = self.packages.${system}.rust-app;
});
devShells = forAllSystems (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
(import rust)
];
};
inherit system;
in {
default = pkgs.callPackage ./nix/shell.nix {
inherit (self.packages.${system}) rust-app;
};
});
};
}

View file

@ -0,0 +1,8 @@
{ rustPlatform }: let
pname = "rust-app";
version = "0.1.0";
in rustPlatform.buildRustPackage {
inherit pname version;
src = ../.;
cargoLock.lockFile = ../Cargo.lock;
}

View file

@ -0,0 +1,7 @@
{ mkShell, rust-app, rust-bin }:
mkShell {
inputsFrom = [ rust-app ];
buildInputs = [
rust-bin.stable.latest.default
];
}

View file

@ -0,0 +1,3 @@
fn main() {
println!("Hello, world!");
}