Skip to content

docs: hooks examples not in sync with hooks declaration #102

@landure

Description

@landure

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions