feat: add rust template
parent
8d5300682c
commit
c37a55d570
|
@ -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;
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
[target.x86_64-unknown-linux-gnu]
|
||||
linker = "clang"
|
|
@ -0,0 +1 @@
|
|||
use flake
|
|
@ -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
|
|
@ -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 New Issue