Add rust template in flake

This commit is contained in:
traxys 2022-10-31 16:35:31 +01:00
parent ae572deb85
commit 9b38722451
5 changed files with 54 additions and 0 deletions

View file

@ -40,6 +40,12 @@
nixpkgs,
...
} @ inputs: {
templates = {
rust = {
path = ./templates/rust;
description = "My rust template using rust-overlay and direnv";
};
};
nixosConfigurations = {
ZeNixLaptop = nixpkgs.lib.nixosSystem rec {
system = "x86_64-linux";

4
templates/rust/.envrc Normal file
View file

@ -0,0 +1,4 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.1.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.1.1/direnvrc" "sha256-b6qJ4r34rbE23yWjMqbmu3ia2z4b2wIlZUksBke/ol0="
fi
use flake

1
templates/rust/.gitignore vendored Normal file
View file

@ -0,0 +1 @@
/target

View file

@ -0,0 +1,7 @@
[package]
name = "todo_change_name"
version = "0.1.0"
authors = ["traxys <quentin@familleboyer.net>"]
edition = "2021"
[dependencies]

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

@ -0,0 +1,36 @@
{
description = "A basic flake with a shell";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.naersk.url = "github:nix-community/naersk";
inputs.rust-overlay.url = "github:oxalica/rust-overlay";
outputs = {
self,
nixpkgs,
flake-utils,
naersk,
rust-overlay,
}:
flake-utils.lib.eachDefaultSystem (system: let
pkgs = import nixpkgs {
inherit system;
overlays = [(import rust-overlay)];
};
rust = pkgs.rust-bin.stable.latest.default;
naersk' = pkgs.callPackage naersk {
cargo = rust;
rustc = rust;
};
in {
devShell = pkgs.mkShell {
nativeBuildInputs = [rust];
RUST_PATH = "${rust}";
shellHook = ''
alias rstddoc="firefox ${rust}/share/doc/rust/html/std/index.html"
'';
};
defaultPackage = nearsk'.buildPackage ./.;
});
}