# Copyright 2023 wanderer <a_mirre at utb dot cz>
# SPDX-License-Identifier: GPL-3.0-or-later

---
fail_fast: false
repos:
  - repo: https://github.com/pre-commit/pre-commit-hooks
    rev: v4.2.0
    hooks:
      - id: check-merge-conflict
  - repo: meta
    hooks:
      - id: check-hooks-apply
  - repo: local
    hooks:
      - id: statix
        name: statix
        entry: statix check .
        always_run: false
        pass_filenames: false
        files: '\.*.nix$'
        language: system
      - id: nix-fmt
        name: nix fmt
        entry: nix fmt -- --check .
        always_run: false
        pass_filenames: false
        files: '\.*.nix$'
        language: system
      - id: flake-check
        name: nix flake check
        entry: nix flake check --keep-going
        always_run: false
        pass_filenames: false
        files: "flake.(nix|lock)$"
        language: system
      - id: addlicense
        name: addlicence -check
        entry: >
          go run github.com/google/addlicense@v1.0.0 -check -v
        pass_filenames: true
        types_or: ["go", "yaml"]
        exclude: "^.drone.*"
        language: system
  - repo: https://github.com/dnephin/pre-commit-golang
    rev: v0.5.0
    hooks:
      - id: go-mod-tidy
      - id: go-unit-tests
      - id: golangci-lint
      - id: go-build
  - repo: local
    hooks:
      - id: nix-build
        name: nix build
        entry: nix build .#math-optim
        pass_filenames: false
        # trigger this hook on changes to any of nix (also flake.lock) files
        # and go's mod or sum files
        files: '\.*.(nix|lock|mod|sum)$'
        language: system
