flake-file icon indicating copy to clipboard operation
flake-file copied to clipboard

docs: hooks examples not in sync with hooks declaration

Open landure opened this issue 7 months ago • 0 comments

Hi,

in https://flake-file.oeiuwq.com/guides/hooks/, examples hooks use exec option. It doesn't exists. It's now program. The examples should be:

{  lib, pkgs, ... }: {
  flake-file.write-hooks = [
    {
      index = 10;
      program = pkgs:    pkgs.writeShellApplication {
        name = "flake-update";
        text = "${lib.meta.getExe pkgs.nix} flake update";
       };
    }
  ];
}

And:

{ pkgs, ... }: {
  flake-file.check-hooks = [
    {
      index = 10;
      program = pkgs:    pkgs.writeShellApplication {
        name = "my-linter-check";
        text = "${lib.meta.getExe pkgs.my-linter} --check .";
       };
    }
  ];
}

For beginners sake, It would be nice to use real linter examples:

{ lib, pkgs, ... }: {
  flake-file.check-hooks = [
      {
        index = 10;
        program =
          pkgs:
          pkgs.writeShellApplication {
            name = "nil-diagnostics";
            text = ''
              shopt -s globstar
              
              flake_path="''${1}"
            
              ${lib.meta.getExe pkgs.nil} diagnostics --deny-warnings "''${flake_path}/"**/*.nix
            '';
          };
      }
      {
        index = 20;
        program = pkgs: pkgs.writeShellApplication {
          name = "statix-check";
          text = "${lib.meta.getExe pkgs.statix} check";
        };
      }
    ];
}

Thank you for your work.

landure avatar Apr 17 '26 06:04 landure