feat: add rust template
This commit is contained in:
parent
8d5300682c
commit
c37a55d570
5 changed files with 82 additions and 0 deletions
|
@ -204,8 +204,13 @@
|
|||
|
||||
templates = {
|
||||
python = {
|
||||
description = "Simple poetry shell.nix";
|
||||
path = ./templates/python;
|
||||
};
|
||||
rust = {
|
||||
description = "Crane + Fenix flake with mold for faster local builds.";
|
||||
path = ./templates/rust;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
2
templates/rust/.cargo/config.toml
Normal file
2
templates/rust/.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[target.x86_64-unknown-linux-gnu]
|
||||
linker = "clang"
|
1
templates/rust/.envrc
Normal file
1
templates/rust/.envrc
Normal file
|
@ -0,0 +1 @@
|
|||
use flake
|
24
templates/rust/.gitignore
vendored
Normal file
24
templates/rust/.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
# Created by https://www.toptal.com/developers/gitignore/api/rust,direnv
|
||||
# Edit at https://www.toptal.com/developers/gitignore?templates=rust,direnv
|
||||
|
||||
### direnv ###
|
||||
.direnv
|
||||
.envrc
|
||||
|
||||
### Rust ###
|
||||
# Generated by Cargo
|
||||
# will have compiled files and executables
|
||||
debug/
|
||||
target/
|
||||
|
||||
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
|
||||
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
|
||||
# Cargo.lock
|
||||
|
||||
# These are backup files generated by rustfmt
|
||||
**/*.rs.bk
|
||||
|
||||
# MSVC Windows builds of rustc generate these, which store debugging information
|
||||
*.pdb
|
||||
|
||||
# End of https://www.toptal.com/developers/gitignore/api/rust,direnv
|
50
templates/rust/flake.nix
Normal file
50
templates/rust/flake.nix
Normal file
|
@ -0,0 +1,50 @@
|
|||
{
|
||||
inputs = {
|
||||
crane = {
|
||||
url = "github:ipetkov/crane";
|
||||
inputs = {
|
||||
flake-utils.follows = "flake-utils";
|
||||
nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
fenix = {
|
||||
url = "github:nix-community/fenix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||
};
|
||||
|
||||
outputs = { self, crane, fenix, flake-utils, nixpkgs }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = (import nixpkgs) {
|
||||
inherit system;
|
||||
};
|
||||
toolchain = fenix.packages.${system}.stable;
|
||||
craneLib = crane.lib.${system}.overrideToolchain toolchain.toolchain;
|
||||
in
|
||||
{
|
||||
packages.default =
|
||||
let
|
||||
inherit (pkgs.lib) fileset;
|
||||
in
|
||||
craneLib.buildPackage {
|
||||
src = fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = fileset.intersection
|
||||
(fileset.difference ./.
|
||||
(fileset.unions [ ./.cargo ./flake.nix ./flake.lock ./.envrc ]))
|
||||
(fileset.gitTracked ./.);
|
||||
};
|
||||
};
|
||||
|
||||
devShell = pkgs.mkShell.override
|
||||
{
|
||||
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.clangStdenv;
|
||||
}
|
||||
{
|
||||
nativeBuildInputs = with toolchain; [ rustc cargo rust-analyzer clippy ];
|
||||
};
|
||||
});
|
||||
}
|
Loading…
Reference in a new issue