Skip to content

Commit

Permalink
build: change fmt and add lints
Browse files Browse the repository at this point in the history
  • Loading branch information
KFearsoff committed Oct 16, 2024
1 parent ceb8371 commit 3d3a22d
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 55 deletions.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,10 @@ tailforward-cfg = { path = "tailforward-cfg" }
serde = "1.0"
toml = "0.8"
camino = { version = "1" }

[lints.clippy]
pedantic = { level = "warn", priority = -1 }
nursery = { level = "warn", priority = -1 }
unwrap_used = "deny"
expect_used = "deny"
missing_const_for_fn = "deny" # `const fn` can be considered as pure function; pure functions are easier to reason about, so we want to mark things as `const fn` when we can
13 changes: 8 additions & 5 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{dream2nix, ...}: {
{ dream2nix, ... }:
{
imports = [
# dream2nix modules go here
dream2nix.modules.dream2nix.rust-cargo-lock
Expand All @@ -9,10 +10,12 @@
src = ./.;
};

deps = {nixpkgs, ...}: {
# dependencies go here
inherit (nixpkgs) stdenv;
};
deps =
{ nixpkgs, ... }:
{
# dependencies go here
inherit (nixpkgs) stdenv;
};

name = "tailforward";
version = "0.7.1";
Expand Down
102 changes: 52 additions & 50 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,62 +16,64 @@
};
};

outputs = inputs @ {
nixpkgs,
pre-commit-hooks,
dream2nix,
...
}: let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in {
checks.x86_64-linux = {
pre-commit-check = pre-commit-hooks.lib.x86_64-linux.run {
src = ./.;
hooks = {
# Nix
alejandra.enable = true;
deadnix.enable = true;
statix.enable = true;
outputs =
inputs@{
nixpkgs,
pre-commit-hooks,
dream2nix,
...
}:
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in
{
checks.x86_64-linux = {
pre-commit-check = pre-commit-hooks.lib.x86_64-linux.run {
src = ./.;
hooks = {
# Nix
nixfmt-rfc-style.enable = true;
deadnix.enable = true;
statix.enable = true;

# Rust
cargo-check.enable = true;
clippy = {
enable = true;
raw.verbose = true;
raw.args = ["-D" "clippy::pedantic" "-D" "clippy::nursery" "-D" "clippy::unwrap_used" "-D" "clippy::expect_used"];
# Rust
cargo-check.enable = true;
clippy = {
enable = true;
raw.verbose = true;
};
rustfmt.enable = true;
};
rustfmt.enable = true;
};
};
};

devShells.x86_64-linux.default = pkgs.mkShell {
packages = with pkgs; [
cargo
rustc
rustfmt
clippy
rust-analyzer
cargo-deny
cargo-edit
cargo-nextest
];
devShells.x86_64-linux.default = pkgs.mkShell {
packages = with pkgs; [
cargo
rustc
rustfmt
clippy
rust-analyzer
cargo-deny
cargo-edit
cargo-nextest
];

inherit (inputs.self.checks.x86_64-linux.pre-commit-check) shellHook;
};
inherit (inputs.self.checks.x86_64-linux.pre-commit-check) shellHook;
};

packages.x86_64-linux.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = dream2nix.inputs.nixpkgs.legacyPackages.x86_64-linux;
modules = [
./default.nix
{
paths = {
projectRoot = ./.;
projectRootFile = "flake.nix";
package = ./.;
};
}
];
packages.x86_64-linux.default = dream2nix.lib.evalModules {
packageSets.nixpkgs = dream2nix.inputs.nixpkgs.legacyPackages.x86_64-linux;
modules = [
./default.nix
{
paths = {
projectRoot = ./.;
projectRootFile = "flake.nix";
package = ./.;
};
}
];
};
};
};
}

0 comments on commit 3d3a22d

Please sign in to comment.