feat(rust): add rust to the templates
This commit is contained in:
parent
cd612f03ad
commit
9083ff41ab
8 changed files with 139 additions and 0 deletions
|
@ -15,6 +15,10 @@
|
||||||
path = ./templates/go;
|
path = ./templates/go;
|
||||||
description = "go flake template";
|
description = "go flake template";
|
||||||
};
|
};
|
||||||
|
"rust" = {
|
||||||
|
path = ./templates/rust;
|
||||||
|
description = "rust flake template";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
7
templates/rust/Cargo.lock
generated
Normal file
7
templates/rust/Cargo.lock
generated
Normal 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"
|
8
templates/rust/Cargo.toml
Normal file
8
templates/rust/Cargo.toml
Normal 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
61
templates/rust/flake.lock
generated
Normal 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
41
templates/rust/flake.nix
Normal 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;
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
8
templates/rust/nix/package.nix
Normal file
8
templates/rust/nix/package.nix
Normal 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;
|
||||||
|
}
|
7
templates/rust/nix/shell.nix
Normal file
7
templates/rust/nix/shell.nix
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{ mkShell, rust-app, rust-bin }:
|
||||||
|
mkShell {
|
||||||
|
inputsFrom = [ rust-app ];
|
||||||
|
buildInputs = [
|
||||||
|
rust-bin.stable.latest.default
|
||||||
|
];
|
||||||
|
}
|
3
templates/rust/src/main.rs
Normal file
3
templates/rust/src/main.rs
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
fn main() {
|
||||||
|
println!("Hello, world!");
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue