templates: add rust-cargo
ci/woodpecker/push/check Pipeline was successful Details

This commit is contained in:
Bruno BELANYI 2023-05-10 13:04:06 +00:00
parent 6812d777cf
commit 26d6fcae4a
9 changed files with 176 additions and 0 deletions

View File

@ -7,4 +7,8 @@
path = ./c++-meson;
description = "A C++ project using Meson";
};
"rust-cargo" = {
path = ./rust-cargo;
description = "A Rust project using Cargo";
};
}

View File

@ -0,0 +1,5 @@
if ! has nix_direnv_version || ! nix_direnv_version 3.0.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.0/direnvrc" "sha256-21TMnI2xWX7HkSTjFFri2UaohXVj854mgvWapWrxRXg="
fi
use flake

6
templates/rust-cargo/.gitignore vendored Normal file
View File

@ -0,0 +1,6 @@
# Rust build directory
/target
# Nix generated files
/.pre-commit-config.yaml
/result

View File

@ -0,0 +1,31 @@
labels:
backend: local
steps:
- name: pre-commit check
image: bash
commands:
- nix develop --command pre-commit run --all
- name: nix flake check
image: bash
commands:
- nix flake check
- name: notifiy
image: bash
environment:
ADDRESS:
from_secret: matrix_homeserver
ROOM:
from_secret: matrix_roomid
USER:
from_secret: matrix_username
PASS:
from_secret: matrix_password
commands:
- nix run github:ambroisie/matrix-notifier
when:
status:
- failure
- success

7
templates/rust-cargo/Cargo.lock generated Normal file
View File

@ -0,0 +1,7 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 3
[[package]]
name = "project"
version = "0.0.0"

View File

@ -0,0 +1,8 @@
[package]
name = "project"
version = "0.0.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]

View File

@ -0,0 +1,112 @@
{
description = "A Rust project";
inputs = {
futils = {
type = "github";
owner = "numtide";
repo = "flake-utils";
ref = "main";
};
nixpkgs = {
type = "github";
owner = "NixOS";
repo = "nixpkgs";
ref = "nixos-unstable";
};
pre-commit-hooks = {
type = "github";
owner = "cachix";
repo = "pre-commit-hooks.nix";
ref = "master";
inputs = {
flake-utils.follows = "futils";
nixpkgs.follows = "nixpkgs";
};
};
};
outputs = { self, futils, nixpkgs, pre-commit-hooks }:
{
overlays = {
default = final: _prev: {
project = with final; rustPlatform.buildRustPackage {
pname = "project";
version = (final.lib.importTOML ./Cargo.toml).package.version;
src = self;
cargoLock = {
lockFile = "${self}/Cargo.lock";
};
meta = with lib; {
description = "A Rust project";
homepage = "https://git.belanyi.fr/ambroisie/project";
license = licenses.mit;
maintainers = with maintainers; [ ambroisie ];
};
};
};
};
} // futils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
};
pre-commit = pre-commit-hooks.lib.${system}.run {
src = self;
hooks = {
clippy = {
enable = true;
settings = {
denyWarnings = true;
};
};
nixpkgs-fmt = {
enable = true;
};
rustfmt = {
enable = true;
};
};
};
in
{
checks = {
inherit (self.packages.${system}) project;
};
devShells = {
default = pkgs.mkShell {
inputsFrom = with self.packages.${system}; [
project
];
packages = with pkgs; [
clippy
rust-analyzer
rustfmt
];
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
inherit (pre-commit) shellHook;
};
};
packages = futils.lib.flattenTree {
default = pkgs.project;
inherit (pkgs) project;
};
});
}

View File

View File

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