-
-
Notifications
You must be signed in to change notification settings - Fork 158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
treewide: add developer shell and pre-commit hooks and simplify GitHub workflows #519
base: master
Are you sure you want to change the base?
Conversation
All |
I will address #519 (comment) together with any potential change requests. For reference:
|
Restrict the workflow permissions to the jobs:
docs:
runs-on: ubuntu-22.04
permissions:
contents: read
id-token: write
pages: write |
@danth, I don't think it would significantly impact your review, but should I rebase this PR on top of |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feel free to go ahead and rebase the PR and make any other changes as well as addressing the comments in this review :)
Personally I would prefer nixfmt
over Alejandra, since it's being developed into the official standard formatter. At a glance it seems pre-commit-hooks
supports it.
Good catch! Admittedly, I adapted this GitHub Action from my dotfiles setup without testing it. The only difference with my dotfiles setup is: -path: result/usr/share/doc
+path: result I assume the GitHub Action does not consider Should we apply your
I assumed the
The developer shell should include all necessary development packages. Since GHC is almost never used, I created a separate developer shell for it.
Despite its very early development, using the official formatter sound sreasonable due to Stylix's popularity. Currently, harmonizing nixfmt (with the required From 8c9597ea94795ee3061d6efb2d4d808ef9471ca5 Mon Sep 17 00:00:00 2001
From: NAHO <[email protected]>
Date: Tue, 10 Sep 2024 00:33:18 +0200
Subject: [PATCH] stylix: add nixfmt formatter
---
flake.lock | 23 ++++++++++++++++++++++-
flake.nix | 13 +++++++++++++
2 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/flake.lock b/flake.lock
index b05b9fd..ddfaa91 100644
--- a/flake.lock
+++ b/flake.lock
@@ -283,7 +283,8 @@
"gnome-shell": "gnome-shell",
"home-manager": "home-manager",
"nixpkgs": "nixpkgs",
- "systems": "systems"
+ "systems": "systems",
+ "treefmt-nix": "treefmt-nix"
}
},
"systems": {
@@ -300,6 +301,26 @@
"repo": "default",
"type": "github"
}
+ },
+ "treefmt-nix": {
+ "inputs": {
+ "nixpkgs": [
+ "nixpkgs"
+ ]
+ },
+ "locked": {
+ "lastModified": 1725271838,
+ "narHash": "sha256-VcqxWT0O/gMaeWTTjf1r4MOyG49NaNxW4GHTO3xuThE=",
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "rev": "9fb342d14b69aefdf46187f6bb80a4a0d97007cd",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "treefmt-nix",
+ "type": "github"
+ }
}
},
"root": "root",
diff --git a/flake.nix b/flake.nix
index d6c7192..e1dc976 100644
--- a/flake.nix
+++ b/flake.nix
@@ -71,6 +71,11 @@
# Interface flake systems.
systems.url = "github:nix-systems/default";
+
+ treefmt-nix = {
+ inputs.nixpkgs.follows = "nixpkgs";
+ url = "github:numtide/treefmt-nix";
+ };
};
outputs =
@@ -109,6 +114,14 @@
];
};
+ formatter = (
+ inputs.treefmt-nix.lib.evalModule pkgs {
+ programs.nixfmt.enable = true;
+ projectRootFile = "flake.nix";
+ }
+ )
+ .config.build.wrapper;
+
packages = let
universalPackages = {
docs = import ./docs { inherit pkgs inputs lib; };
-- For reference, Alejandra adds 69% less new lines than nixfmt:
|
Leverage direnv [1] to automatically enter the developer shell upon entering the project directory after running 'direnv allow'. [1]: https://direnv.net Link: danth#519
Add the deadnix and statix pre-commit hooks used in the Lint GitHub workflow. Link: danth#519
ad87e25
to
cb8c988
Compare
Changelogv1: cb8c988
v0: ad87e25 |
cb8c988
to
e7d6995
Compare
Changelogv2: e7d6995
v1: cb8c988
v0: ad87e25 |
@danth, could you approve this PR again by looking at its changelog and addressing the following unanswered question:
I will rebase this PR on top of Note Heavily consider reviewing the commits individually (https://patch-diff.githubusercontent.com/raw/danth/stylix/pull/519.patch), as over 90% of the diff stems from the final "treewide: add and apply nixfmt pre-commit hook" commit. |
e7d6995
to
ffd7436
Compare
Changelogv3: ffd7436
v2: e7d6995
v1: cb8c988
v0: ad87e25 |
Cc: @danth
|
Leverage direnv [1] to automatically enter the developer shell upon entering the project directory after running 'direnv allow'. [1]: https://direnv.net Link: danth#519
Add the deadnix and statix pre-commit hooks used in the Lint GitHub workflow. Link: danth#519
ffd7436
to
8880c87
Compare
Changelogv4: 8880c87
v3: ffd7436
v2: e7d6995
v1: cb8c988
v0: ad87e25 |
@trueNAHO @danth isn't it better to just configure formatters and linters using pre-commit hooks are useless in my opinion if the only thing they are used for is formatting and linting, they are easily bypassed.
And formatter = pkgs.nixfmt-rfc-style; and can't use anything other than that one formatter + doesn't get style checks on |
Yes, pre-commit hooks are an optional Git feature. Their compliance is, as you proposed, already checked with
The current inputs.stylix.inputs.git-hooks.follows = ""; Initially,
|
This patchset closes issue #236 ("treewide: add linters and formatters") after integrating pre-commit hooks into the developer shell and simplifying GitHub workflows using
nix flake check
.This patchset is stacked on top of the pending patchset #515 ("treewide: re-add flake-utils dependency and interface flake systems") and should only be merged after it.
Note
These commits should be merged individually, not squashed, to ensure a clear and easily reversible changelog. In case of change requests, review the commits separately.