chore(nix): add style tooling
This commit is contained in:
48
flake.nix
48
flake.nix
@@ -62,6 +62,12 @@
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
# Repository formatter and Nix lint wiring.
|
||||
treefmt-nix = {
|
||||
url = "github:numtide/treefmt-nix";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
|
||||
# CachyOS kernel and binary cache.
|
||||
# This must not follow this flake's nixpkgs because Chaotic builds against its own pinned package set.
|
||||
# Its cache serves the kernel only when the overlay stays on the cache-friendly path.
|
||||
@@ -69,8 +75,48 @@
|
||||
};
|
||||
|
||||
outputs =
|
||||
{ self, nixpkgs, ... }@inputs:
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
treefmt-nix,
|
||||
...
|
||||
}@inputs:
|
||||
let
|
||||
supportedSystems = [ "x86_64-linux" ];
|
||||
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
|
||||
pkgsFor = system: nixpkgs.legacyPackages.${system};
|
||||
treefmtEvalFor = system: treefmt-nix.lib.evalModule (pkgsFor system) ./treefmt.nix;
|
||||
in
|
||||
{
|
||||
formatter = forAllSystems (system: (treefmtEvalFor system).config.build.wrapper);
|
||||
|
||||
apps = forAllSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = pkgsFor system;
|
||||
treefmtEval = treefmtEvalFor system;
|
||||
nixStyleCheck = pkgs.writeShellApplication {
|
||||
name = "nix-style-check";
|
||||
runtimeInputs = [
|
||||
treefmtEval.config.build.wrapper
|
||||
pkgs.statix
|
||||
pkgs.deadnix
|
||||
];
|
||||
text = ''
|
||||
treefmt --fail-on-change
|
||||
statix check .
|
||||
deadnix --fail --no-lambda-pattern-names --no-underscore .
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
nix-style-check = {
|
||||
type = "app";
|
||||
program = "${nixStyleCheck}/bin/nix-style-check";
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
nixosConfigurations = (import ./src/dotfiles {
|
||||
inherit inputs self;
|
||||
lib = nixpkgs.lib;
|
||||
|
||||
Reference in New Issue
Block a user