1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-11 07:10:39 +02:00

feat: add treefmt and switch to nixfmt-rfc-style

This commit is contained in:
oddlama 2024-11-26 13:30:28 +01:00
parent 5cea27f592
commit deca311c68
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
3 changed files with 111 additions and 90 deletions

21
flake.lock generated
View file

@ -2071,6 +2071,7 @@
"nixvim": "nixvim", "nixvim": "nixvim",
"pre-commit-hooks": "pre-commit-hooks_6", "pre-commit-hooks": "pre-commit-hooks_6",
"stylix": "stylix", "stylix": "stylix",
"treefmt-nix": "treefmt-nix_5",
"whisper-overlay": "whisper-overlay", "whisper-overlay": "whisper-overlay",
"wired-notify": "wired-notify" "wired-notify": "wired-notify"
} }
@ -2511,6 +2512,26 @@
"type": "github" "type": "github"
} }
}, },
"treefmt-nix_5": {
"inputs": {
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1732292307,
"narHash": "sha256-5WSng844vXt8uytT5djmqBCkopyle6ciFgteuA9bJpw=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "705df92694af7093dfbb27109ce16d828a79155f",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"treefmt_2": { "treefmt_2": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [

View file

@ -95,6 +95,11 @@
inputs.home-manager.follows = "home-manager"; inputs.home-manager.follows = "home-manager";
}; };
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
whisper-overlay = { whisper-overlay = {
url = "github:oddlama/whisper-overlay"; url = "github:oddlama/whisper-overlay";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs";
@ -106,8 +111,9 @@
}; };
}; };
outputs = inputs: outputs =
inputs.flake-parts.lib.mkFlake {inherit inputs;} { inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ imports = [
./nix/agenix-rekey.nix ./nix/agenix-rekey.nix
./nix/devshell.nix ./nix/devshell.nix

View file

@ -1,25 +1,27 @@
{inputs, ...}: { { inputs, ... }:
{
imports = [ imports = [
inputs.devshell.flakeModule inputs.devshell.flakeModule
inputs.pre-commit-hooks.flakeModule inputs.pre-commit-hooks.flakeModule
inputs.treefmt-nix.flakeModule
]; ];
perSystem = { perSystem =
{
config, config,
pkgs, pkgs,
... ...
}: { }:
pre-commit.settings.hooks = { {
alejandra.enable = true; pre-commit.settings.hooks.treefmt.enable = true;
treefmt = {
projectRootFile = "flake.nix";
programs = {
deadnix.enable = true; deadnix.enable = true;
statix.enable = true; statix.enable = true;
#gitleaks = { nixfmt.enable = true;
# enable = true; rustfmt.enable = true;
# name = "gitleaks"; };
# entry = "${pkgs.gitleaks}/bin/gitleaks protect --verbose --redact --staged";
# language = "system";
# pass_filenames = false;
#};
}; };
devshells.default = { devshells.default = {
@ -28,22 +30,14 @@
]; ];
commands = [ commands = [
{
package = config.treefmt.build.wrapper;
help = "Format all files";
}
{ {
package = pkgs.deploy; package = pkgs.deploy;
help = "Build and deploy this nix config to nodes"; help = "Build and deploy this nix config to nodes";
} }
{
package = pkgs.alejandra;
help = "Format nix code";
}
{
package = pkgs.statix;
help = "Lint nix code";
}
{
package = pkgs.deadnix;
help = "Find unused expressions in nix code";
}
{ {
package = pkgs.nix-tree; package = pkgs.nix-tree;
help = "Interactively browse dependency graphs of Nix derivations"; help = "Interactively browse dependency graphs of Nix derivations";