feat: add back my rust template
This commit is contained in:
parent
7f9d44b107
commit
8556d25bda
3 changed files with 100 additions and 0 deletions
|
|
@ -63,6 +63,13 @@
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
flake = {
|
||||||
|
templates.rust = {
|
||||||
|
description = "Crane + Fenix flake with mold for faster local builds.";
|
||||||
|
path = ./templates/rust;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
# Define your clan
|
# Define your clan
|
||||||
# See: https://docs.clan.lol/reference/nix-api/buildclan/
|
# See: https://docs.clan.lol/reference/nix-api/buildclan/
|
||||||
clan = {
|
clan = {
|
||||||
|
|
|
||||||
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
|
||||||
69
templates/rust/flake.nix
Normal file
69
templates/rust/flake.nix
Normal file
|
|
@ -0,0 +1,69 @@
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
crane.url = "github:ipetkov/crane";
|
||||||
|
crane.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
fenix.url = "github:nix-community/fenix";
|
||||||
|
fenix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
|
flake-utils.url = "github:numtide/flake-utils";
|
||||||
|
nixpkgs.url = "nixpkgs/nixos-unstable";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = {
|
||||||
|
crane,
|
||||||
|
flake-utils,
|
||||||
|
nixpkgs,
|
||||||
|
...
|
||||||
|
} @ inputs:
|
||||||
|
flake-utils.lib.eachDefaultSystem (
|
||||||
|
system: let
|
||||||
|
inherit (pkgs) lib;
|
||||||
|
pkgs = import nixpkgs {inherit system;};
|
||||||
|
fenix = inputs.fenix.packages.${system};
|
||||||
|
craneLib = crane.lib.${system}.overrideToolchain toolchain.toolchain;
|
||||||
|
mkSrc = extraPaths:
|
||||||
|
with lib.fileset; let
|
||||||
|
root = ./.;
|
||||||
|
rustFiles = fromSource (craneLib.cleanCargoSource root);
|
||||||
|
fileset = union rustFiles (unions extraPaths);
|
||||||
|
in
|
||||||
|
toSource {inherit root fileset;};
|
||||||
|
|
||||||
|
## Customize here ##
|
||||||
|
toolchain = fenix.complete; # or fenix.stable;
|
||||||
|
stdenv = pkgs.stdenvAdapters.useMoldLinker pkgs.stdenv;
|
||||||
|
in {
|
||||||
|
packages.default = craneLib.buildPackage {
|
||||||
|
inherit stdenv;
|
||||||
|
src = mkSrc [];
|
||||||
|
strictDeps = true;
|
||||||
|
buildInputs =
|
||||||
|
[
|
||||||
|
# Add additional build inputs here
|
||||||
|
]
|
||||||
|
++ lib.optionals pkgs.stdenv.isDarwin [
|
||||||
|
# Additional darwin specific inputs can be set here
|
||||||
|
pkgs.libiconv
|
||||||
|
];
|
||||||
|
# Additional environment variables can be set directly
|
||||||
|
# MY_CUSTOM_VAR = "some value";
|
||||||
|
};
|
||||||
|
|
||||||
|
devShells.default =
|
||||||
|
pkgs.mkShell.override {inherit stdenv;}
|
||||||
|
{
|
||||||
|
nativeBuildInputs = with pkgs;
|
||||||
|
[
|
||||||
|
# Add additional build inputs here
|
||||||
|
]
|
||||||
|
++ (with toolchain; [
|
||||||
|
cargo
|
||||||
|
clippy
|
||||||
|
rustfmt
|
||||||
|
rustc
|
||||||
|
fenix.rust-analyzer
|
||||||
|
]);
|
||||||
|
RUST_SRC_PATH = "${toolchain.rust-src}/lib/rustlib/src/rust/library";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue