new: templates: basic rust example
This commit is contained in:
parent
831e14600f
commit
346ccb57d5
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,2 @@
|
||||
|
||||
templates/*/result*
|
||||
templates/*/flake.lock
|
||||
|
@ -18,5 +18,9 @@
|
||||
nixosModules = {
|
||||
bonfire = import ./nixosModules/bonfire.nix;
|
||||
};
|
||||
|
||||
templates = {
|
||||
rust = { path = ./templates/rust; description = "Basic Rust template"; };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
2
templates/rust/.gitignore
vendored
Normal file
2
templates/rust/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/target
|
||||
result*
|
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-example"
|
||||
version = "0.1.0"
|
6
templates/rust/Cargo.toml
Normal file
6
templates/rust/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "rust-example"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
[dependencies]
|
8
templates/rust/README.md
Normal file
8
templates/rust/README.md
Normal file
@ -0,0 +1,8 @@
|
||||
# Basic Rust Example
|
||||
|
||||
* Creating/updating `Cargo.lock`
|
||||
```shell
|
||||
touch Cargo.lock
|
||||
nix develop
|
||||
cargo check
|
||||
```
|
52
templates/rust/flake.nix
Normal file
52
templates/rust/flake.nix
Normal file
@ -0,0 +1,52 @@
|
||||
{
|
||||
description = "Basic rust template";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
||||
crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; };
|
||||
};
|
||||
|
||||
outputs = inputs @ { self, nixpkgs, crane, ... }:
|
||||
let
|
||||
forAllSystems = nixpkgs.lib.genAttrs [ "x86_64-linux" ];
|
||||
nixpkgsFor = forAllSystems (system: import nixpkgs { inherit system; });
|
||||
in {
|
||||
packages = forAllSystems (system: {
|
||||
my-crate = let
|
||||
pkgs = nixpkgsFor.${system};
|
||||
craneLib = crane.lib.${system};
|
||||
in craneLib.buildPackage {
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
strictDeps = true;
|
||||
|
||||
buildInputs = [];
|
||||
};
|
||||
|
||||
default = self.packages.${system}.my-crate;
|
||||
});
|
||||
|
||||
checks = forAllSystems (system: {
|
||||
inherit (self.packages.${system}.my-crate);
|
||||
|
||||
my-crate-fmt = let craneLib = crane.lib.${system}; in craneLib.cargoFmt {
|
||||
src = craneLib.cleanCargoSource (craneLib.path ./.);
|
||||
};
|
||||
});
|
||||
|
||||
apps = forAllSystems (system: {
|
||||
default = {
|
||||
type = "app";
|
||||
program = "${self.packages.${system}.my-crate}/bin/rust-example";
|
||||
};
|
||||
});
|
||||
|
||||
devShells = forAllSystems (system: {
|
||||
default = crane.lib.${system}.devShell {
|
||||
checks = self.checks.${system};
|
||||
|
||||
packages = [];
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
}
|
3
templates/rust/src/main.rs
Normal file
3
templates/rust/src/main.rs
Normal file
@ -0,0 +1,3 @@
|
||||
fn main() {
|
||||
println!("Hello, nix!");
|
||||
}
|
Loading…
Reference in New Issue
Block a user