feat: Add a bunch of precommit hooks

This commit is contained in:
Jalil David Salamé Messina 2024-01-15 23:59:15 +01:00
parent 0f72495da5
commit 9e822c9782
Signed by: jalil
GPG key ID: F016B9E770737A0B
4 changed files with 142 additions and 2 deletions

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake

1
.gitignore vendored
View file

@ -1,2 +1,3 @@
result result
.direnv/ .direnv/
.pre-commit-config.yaml

View file

@ -172,6 +172,22 @@
} }
}, },
"flake-compat_2": { "flake-compat_2": {
"flake": false,
"locked": {
"lastModified": 1696426674,
"narHash": "sha256-kvjfFW7WAETZlt09AgDn1MrtKzP7t90Vf7vypd3OL1U=",
"owner": "edolstra",
"repo": "flake-compat",
"rev": "0f9255e01c2351cc7d116c072cb317785dd33b33",
"type": "github"
},
"original": {
"owner": "edolstra",
"repo": "flake-compat",
"type": "github"
}
},
"flake-compat_3": {
"flake": false, "flake": false,
"locked": { "locked": {
"lastModified": 1673956053, "lastModified": 1673956053,
@ -283,6 +299,24 @@
"type": "github" "type": "github"
} }
}, },
"flake-utils_3": {
"inputs": {
"systems": "systems_3"
},
"locked": {
"lastModified": 1701680307,
"narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "4022d587cbbfd70fe950c1e2083a02621806a725",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"fromYaml": { "fromYaml": {
"flake": false, "flake": false,
"locked": { "locked": {
@ -299,6 +333,27 @@
"type": "github" "type": "github"
} }
}, },
"gitignore": {
"inputs": {
"nixpkgs": [
"pre-commit-hooks",
"nixpkgs"
]
},
"locked": {
"lastModified": 1703887061,
"narHash": "sha256-gGPa9qWNc6eCXT/+Z5/zMkyYOuRZqeFZBDbopNZQkuY=",
"owner": "hercules-ci",
"repo": "gitignore.nix",
"rev": "43e1aa1308018f37118e34d3a9cb4f5e75dc11d5",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"repo": "gitignore.nix",
"type": "github"
}
},
"haumea": { "haumea": {
"inputs": { "inputs": {
"nixpkgs": "nixpkgs" "nixpkgs": "nixpkgs"
@ -602,6 +657,22 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs-stable": {
"locked": {
"lastModified": 1704874635,
"narHash": "sha256-YWuCrtsty5vVZvu+7BchAxmcYzTMfolSPP5io8+WYCg=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "3dc440faeee9e889fe2d1b4d25ad0f430d449356",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-23.11",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1705133751, "lastModified": 1705133751,
@ -711,6 +782,30 @@
"type": "github" "type": "github"
} }
}, },
"pre-commit-hooks": {
"inputs": {
"flake-compat": "flake-compat_2",
"flake-utils": "flake-utils_3",
"gitignore": "gitignore",
"nixpkgs": [
"nixpkgs"
],
"nixpkgs-stable": "nixpkgs-stable"
},
"locked": {
"lastModified": 1705229514,
"narHash": "sha256-itILy0zimR/iyUGq5Dgg0fiW8plRDyxF153LWGsg3Cw=",
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"rev": "ffa9a5b90b0acfaa03b1533b83eaf5dead819a05",
"type": "github"
},
"original": {
"owner": "cachix",
"repo": "pre-commit-hooks.nix",
"type": "github"
}
},
"root": { "root": {
"inputs": { "inputs": {
"flake-schemas": "flake-schemas", "flake-schemas": "flake-schemas",
@ -718,6 +813,7 @@
"home-manager": "home-manager", "home-manager": "home-manager",
"nixos-hardware": "nixos-hardware", "nixos-hardware": "nixos-hardware",
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"pre-commit-hooks": "pre-commit-hooks",
"stylix": "stylix" "stylix": "stylix"
} }
}, },
@ -731,7 +827,7 @@
"base16-kitty": "base16-kitty", "base16-kitty": "base16-kitty",
"base16-tmux": "base16-tmux", "base16-tmux": "base16-tmux",
"base16-vim": "base16-vim", "base16-vim": "base16-vim",
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_3",
"home-manager": [ "home-manager": [
"home-manager" "home-manager"
], ],
@ -781,6 +877,21 @@
"repo": "default", "repo": "default",
"type": "github" "type": "github"
} }
},
"systems_3": {
"locked": {
"lastModified": 1681028828,
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
"owner": "nix-systems",
"repo": "default",
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
"type": "github"
},
"original": {
"owner": "nix-systems",
"repo": "default",
"type": "github"
}
} }
}, },
"root": "root", "root": "root",

View file

@ -23,8 +23,21 @@
inputs.nixos-hardware.url = "https://flakehub.com/f/NixOS/nixos-hardware/0.1.*.tar.gz"; inputs.nixos-hardware.url = "https://flakehub.com/f/NixOS/nixos-hardware/0.1.*.tar.gz";
inputs.pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
inputs.pre-commit-hooks.inputs.nixpkgs.follows = "nixpkgs";
# Flake outputs that other flakes can use # Flake outputs that other flakes can use
outputs = { self, flake-schemas, nixpkgs, stylix, home-manager, home-config, nixos-hardware, ... }: outputs =
{ self
, flake-schemas
, nixpkgs
, stylix
, home-manager
, home-config
, nixos-hardware
, pre-commit-hooks
, ...
}:
let let
inherit (nixpkgs) lib; inherit (nixpkgs) lib;
# Helpers for producing system-specific outputs # Helpers for producing system-specific outputs
@ -43,6 +56,13 @@
# Schemas tell Nix about the structure of your flake's outputs # Schemas tell Nix about the structure of your flake's outputs
schemas = flake-schemas.schemas; schemas = flake-schemas.schemas;
checks = forEachSupportedSystem ({ pkgs, system }: {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = builtins.path { path = ./.; name = "configuration.nix"; };
hooks.nixpkgs-fmt.enable = true;
};
});
packages = doc; packages = doc;
# Nix files formatter (run `nix fmt`) # Nix files formatter (run `nix fmt`)
@ -120,5 +140,12 @@
default = nixosModule; default = nixosModule;
inherit nixosModule; inherit nixosModule;
} // machineModules; } // machineModules;
devShells = forEachSupportedSystem ({ pkgs, system }:
{
default = pkgs.mkShell {
inherit (self.checks.${system}.pre-commit-check) shellHook;
};
});
}; };
} }