aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2023-12-03 13:14:59 -0800
committerFranck Cuny <franck@fcuny.net>2023-12-03 13:14:59 -0800
commit45f8e2d134e3dd716c5a47d15ab55266cb354ec9 (patch)
treebfb29152a651e6693bce077620b2760e3de38cda /flake.nix
parentchore: update flake (#12) (diff)
downloadfcuny.net-45f8e2d134e3dd716c5a47d15ab55266cb354ec9.tar.gz
add `treefmt` and `pre-commit-hooks`
I can now run `nix fmt` or `nix flake check` to check the syntax for various files in this repository. Fixed a deprecation warning for `hugo`: ``` > WARN The author key in site configuration is deprecated. Use params.author.email instead. > WARN The author key in site configuration is deprecated. Use params.author.name instead. ```
Diffstat (limited to 'flake.nix')
-rw-r--r--flake.nix38
1 files changed, 26 insertions, 12 deletions
diff --git a/flake.nix b/flake.nix
index 878be9f..5ee6f10 100644
--- a/flake.nix
+++ b/flake.nix
@@ -4,16 +4,20 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/master";
flake-utils.url = "github:numtide/flake-utils";
+ pre-commit-hooks.url = "github:cachix/pre-commit-hooks.nix";
+ treefmt-nix.url = "github:numtide/treefmt-nix";
};
- outputs = { self, nixpkgs, flake-utils }:
+ outputs = { self, nixpkgs, flake-utils, pre-commit-hooks, treefmt-nix, }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
- in
- {
+ treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
+ in {
+ formatter = treefmtEval.config.build.wrapper;
+
packages = {
- site = with pkgs;
+ default = with pkgs;
stdenv.mkDerivation {
pname = "fcuny.net";
version = self.lastModifiedDate;
@@ -32,20 +36,30 @@
'';
};
- apps = {
- deploy = {
- type = "app";
- program = "${self.packages."${system}".deploy}/bin/deploy";
+ checks = {
+ pre-commit-check = pre-commit-hooks.lib.${system}.run {
+ src = ./.;
+ hooks = {
+ hugo = {
+ enable = true;
+ entry = "${pkgs.hugo}/bin/hugo --panicOnWarning";
+ pass_filenames = false;
+ };
+ };
};
+ formatting = treefmtEval.config.build.check self;
+ };
+
+ apps = {
default = {
type = "app";
program = "${self.packages."${system}".hugo}/bin/hugo";
};
};
- defaultPackage = self.packages."${system}".container;
-
- devShell =
- pkgs.mkShell { buildInputs = with pkgs; [ hugo git ]; };
+ devShells.default = pkgs.mkShell {
+ inherit (self.checks.${system}.pre-commit-check) shellHook;
+ buildInputs = with pkgs; [ hugo git treefmt ];
+ };
});
}