Skip to content

feat(nix): Implement nix-build-check hook #16

@aRustyDev

Description

@aRustyDev

Description

Implement a pre-commit hook to test Nix builds for both legacy and flake-based projects.

Requirements

  • Support both default.nix and flake-based builds
  • Check for successful evaluation and build
  • Support building specific attributes via args
  • Provide option for dry-run builds
  • Clear error reporting for build failures

Implementation Details

  • Location: hooks/nix/nix-build-check.sh
  • Language: bash script
  • File patterns: *.nix, default.nix, shell.nix

Testing

  • Test with simple derivation
  • Test with complex multi-output derivation
  • Test with both flakes and legacy nix
  • Test with build failures
  • Test with evaluation errors

Configuration in .pre-commit-hooks.yaml

- id: nix-build-check
  name: Check Nix builds
  description: Tests that Nix expressions build successfully
  entry: hooks/nix/nix-build-check.sh
  language: script
  files: (default|shell)\.nix$
  pass_filenames: true

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