Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions .config/filegen-manifest.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions .gitattributes

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .pre-commit-config.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
url = "github:BirdeeHub/nix-wrapper-modules";
inputs.nixpkgs.follows = "nixpkgs";
};

treefmt = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs =
Expand Down
1 change: 1 addition & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ importingFlake: {
imports = [
inputs.devshell.flakeModule
inputs.github-actions-nix.flakeModules.default
inputs.treefmt.flakeModule
flakeModules.prek-pre-commit

(importApply ./general args)
Expand Down
1 change: 1 addition & 0 deletions nix/general/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ importingFlake: {
imports = [
./action-versions.nix
(importApply ./devshell.nix args)
./formatting.nix
(importApply ./pre-commit-hooks.nix args)

./workflows/check-pre-commit-hooks.nix
Expand Down
51 changes: 30 additions & 21 deletions nix/general/devshell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,40 @@
...
}:
importingFlake: {
config.perSystem = { config, ... }: {
devshells.standards = {
name = lib.mkDefault "engineering-standards";
config.perSystem =
{ config, pkgs, ... }:
{
devshells.standards = {
name = lib.mkDefault "engineering-standards";

# Include all packages from pre-commit in the shell
# - This allows easy access to the individual checks, if developers are interested in running them
# - `prek install` doesn't install the wrapped binary, so when executing the hooks, all runtimePkgs
# would be missing if they were not in the shell
packages = builtins.map (package: package.data) config.prek-pre-commit.package.runtimePkgs;
# - This allows easy access to the individual checks, if developers are interested in running them
# - `prek install` doesn't install the wrapped binary, so when executing the hooks, all runtimePkgs
# would be missing if they were not in the shell
packages = builtins.map (package: package.data) config.prek-pre-commit.package.runtimePkgs;

commands = [
{
name = "prek";
help = "Run pre-commit hooks on currently staged changes";
category = "[[lints and checks]]";
package = config.prek-pre-commit.package.wrapper;
}
{
name = "nix fmt";
help = "Auto-format all files in the project.";
category = "[[lints and checks]]";
package = pkgs.nix;
}

{
name = "prek -s main -o HEAD";
help = "Run pre-commit hooks on all commits in the current branch";
category = "[[lints and checks]]";
package = config.prek-pre-commit.package.wrapper;
}
];
{
name = "prek";
help = "Run pre-commit hooks on currently staged changes";
category = "[[lints and checks]]";
package = config.prek-pre-commit.package.wrapper;
}

{
name = "prek -s main -o HEAD";
help = "Run pre-commit hooks on all commits in the current branch";
category = "[[lints and checks]]";
package = config.prek-pre-commit.package.wrapper;
}
];
};
};
};
}
34 changes: 34 additions & 0 deletions nix/general/formatting.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
perSystem =
{ config, ... }:
{
treefmt = {
# `prek` is in charge of running these kinds of checks, we don't
# want to run formatters with `nix flake check`.
flakeCheck = false;

settings = {
allowMissingFormatter = false;
walk = "git";

excludes = config.filegen.generatedFiles;
};

programs = {
prettier.enable = true;
sqlfluff.enable = true;
shfmt.enable = true;
};

settings.formatter.prettier.excludes = [ "*.md" ];
};

filegen.settings.files = [
{
type = "copy";
target = "treefmt.toml";
source = config.treefmt.build.configFile;
}
];
};
}
Loading
Loading