Compare commits

...

4 commits

Author SHA1 Message Date
Bruno BELANYI 1bdcc7603a fixup! WIP: templates: add rust
All checks were successful
ci/woodpecker/push/check Pipeline was successful
2023-05-10 13:20:18 +00:00
Bruno BELANYI 9caee54f2b WIP: templates: add rust
Some checks failed
ci/woodpecker/push/check Pipeline failed
TODO: find out if I can use the `cargoLock` FOD to run `clippy`.
2023-05-10 13:19:13 +00:00
Bruno BELANYI 694c0224d3 templates: run 'pre-commit' outside of 'checks'
This allows adding pre-commit checks that can't be run in the sandbox,
such as `clippy` in Rust etc...

Not strictly necessary for the few checks that are enabled in the
current templates, but I like to have very similar setups across the
board.
2023-05-10 13:19:13 +00:00
Bruno BELANYI 9540b1424f templates: simplify direnv files
I don't need to bootstrap `nix-direnv` for those projects.

Also remove the unused `watch_file flake/*.nix` directives, as they do
not exist in the templates.
2023-05-10 13:07:37 +00:00
13 changed files with 175 additions and 18 deletions

View file

@ -1,10 +1,3 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi
use flake
watch_file ./flake/checks.nix
watch_file ./flake/dev-shells.nix
eval "$shellHooks"

View file

@ -2,6 +2,11 @@ labels:
type: exec
pipeline:
- name: pre-commit checks
image: bash
commands:
- nix shell . -c pre-commit run --all
- name: nix flake check
image: bash
commands:

View file

@ -86,8 +86,6 @@
{
checks = {
inherit (self.packages.${system}) project;
inherit pre-commit;
};
devShells = {

View file

@ -1,10 +1,3 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.2.1; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.2.1/direnvrc" "sha256-zelF0vLbEl5uaqrfIzbgNzJWGmLzCmYAkInj/LNxvKs="
fi
use flake
watch_file ./flake/checks.nix
watch_file ./flake/dev-shells.nix
eval "$shellHooks"

View file

@ -2,6 +2,11 @@ labels:
type: exec
pipeline:
- name: pre-commit checks
image: bash
commands:
- nix shell . -c pre-commit run --all
- name: nix flake check
image: bash
commands:

View file

@ -86,8 +86,6 @@
{
checks = {
inherit (self.packages.${system}) project;
inherit pre-commit;
};
devShells = {

3
templates/rust/.envrc Normal file
View file

@ -0,0 +1,3 @@
use flake
eval "$shellHooks"

6
templates/rust/.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:
type: exec
pipeline:
- name: pre-commit checks
image: bash
commands:
- nix shell . -c pre-commit run --all
- name: nix flake check
image: bash
commands:
- nix flake check
- name: notifiy
image: bash
secrets:
- source: matrix_homeserver
target: address
- source: matrix_roomid
target: room
- source: matrix_username
target: user
- source: matrix_password
target: pass
commands:
- nix run '.#matrix-notifier'
when:
status:
- failure
- success

7
templates/rust/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]

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

@ -0,0 +1,107 @@
{
description = "A C++ 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://gitea.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;
};
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; [
rust-analyzer
];
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

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