Skip to content

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

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions