templates: rust: init

This commit is contained in:
Bloxx12 2025-06-05 08:27:20 +02:00
commit 4834edd2d4
Signed by: faukah
SSH key fingerprint: SHA256:Uj2AXqvtdCA4hn5Hq0ZonhIAyUqI1q4w2sMG3Z1TH7E
7 changed files with 60 additions and 0 deletions

6
templates/default.nix Normal file
View file

@ -0,0 +1,6 @@
{
rust = {
path = ./rust;
description = "Rust project template";
};
}

1
templates/rust/.envrc Normal file
View file

@ -0,0 +1 @@
use flake

View file

@ -0,0 +1,5 @@
[package]
name = "sample-rust"
version = "0.0.1"
license = "GPL-3.0-only"
edition = "2024"

View file

@ -0,0 +1,8 @@
{rustPlatform}:
rustPlatform.buildRustPackage {
pname = "some-rust-package";
version = "0.0.1";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;
}

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

@ -0,0 +1,35 @@
{
description = "Rust project template";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
systems.url = "github:nix-systems/default-linux";
};
outputs = inputs: let
inherit (inputs.nixpkgs) lib;
inherit (lib.attrsets) genAttrs mapAttrs;
eachSystem = genAttrs (import inputs.systems);
pkgsFor = inputs.nixpkgs.legacyPackages;
in {
packages = eachSystem (system: {
default = inputs.self.packages.${system}.ralc;
ralc = pkgsFor.${system}.callPackage ./nix/package.nix {};
});
devShells =
mapAttrs (system: pkgs: {
default = pkgs.mkShell {
packages = with pkgs; [
cargo
rustc
rustfmt
bacon
rust-analyzer
rustPackages.clippy
];
};
})
pkgsFor;
};
}

View file

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