summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 696781840ff978781ba759a29cc37d5562d32d0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
{
  description = "getchoo's neovim config";

  inputs = {
    nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/0.1.0.tar.gz";
    utils.url = "https://flakehub.com/f/numtide/flake-utils/0.1.88.tar.gz";

    nixvim = {
      url = "https://flakehub.com/f/nix-community/nixvim/0.1.*.tar.gz";
      inputs = {
        nixpkgs.follows = "nixpkgs";
        flake-utils.follows = "utils";
        pre-commit-hooks.follows = "";
      };
    };

    tree-sitter-just = {
      url = "github:IndianBoy42/tree-sitter-just";
      flake = false;
    };
  };

  outputs = {
    nixpkgs,
    utils,
    nixvim,
    tree-sitter-just,
    ...
  }:
    utils.lib.eachDefaultSystem (system: let
      pkgs = nixpkgs.legacyPackages.${system};
      inherit (pkgs) lib;
    in rec {
      checks = {
        check-actionlint =
          pkgs.runCommand "check-actionlint" {
            nativeBuildInputs = [pkgs.actionlint];
          } ''
            actionlint ${./.}/.github/workflows/*
            touch $out
          '';

        "check-${formatter.pname}" =
          pkgs.runCommand "check-${formatter.pname}" {
            nativeBuildInputs = [formatter];
          } ''
            ${lib.getExe formatter} --check ${./.}
            touch $out
          '';

        check-statix =
          pkgs.runCommand "check-statix" {
            nativeBuildInputs = [pkgs.statix];
          }
          ''
            statix check ${./.}
            touch $out
          '';

        check-nil =
          pkgs.runCommand "check-nil" {
            nativeBuildInputs = with pkgs; [fd git nil];
          }
          ''
            cd ${./.}
            fd . -e 'nix' | while read -r file; do
              nil diagnostics "$file"
            done

            touch $out
          '';
      };

      devShells = {
        default = pkgs.mkShell {
          packages = with pkgs; [
            actionlint
            formatter
            deadnix
            nil
            statix
          ];
        };
      };

      formatter = pkgs.alejandra;

      packages = {
        nvim = nixvim.legacyPackages.${system}.makeNixvimWithModule {
          module = ./config;
          extraSpecialArgs = {self = packages;};
        };

        tree-sitter-just = pkgs.tree-sitter.buildGrammar {
          language = "just";
          version = builtins.substring 0 8 tree-sitter-just.lastModifiedDate;
          src = tree-sitter-just;
        };

        default = packages.nvim;
      };
    });
}