Skip to content

feat(nix): Implement nix-flake-check hook #15

@aRustyDev

Description

@aRustyDev

Description

Implement a pre-commit hook to validate Nix flakes using nix flake check.

Requirements

  • Check for nix command availability with flakes enabled
  • Run nix flake check on flake.nix files
  • Support both local and remote flakes
  • Provide clear error messages for validation failures
  • Handle cases where experimental features might not be enabled

Implementation Details

  • Location: hooks/nix/nix-flake-check.sh
  • Language: bash script
  • File pattern: flake.nix

Testing

  • Test with valid flake.nix
  • Test with invalid flake.nix
  • Test with missing inputs
  • Test with evaluation errors

Configuration in .pre-commit-hooks.yaml

- id: nix-flake-check
  name: Check Nix flakes
  description: Validates Nix flakes using 'nix flake check'
  entry: hooks/nix/nix-flake-check.sh
  language: script
  files: flake\.nix$

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions