This repository has been archived by the owner on Dec 7, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
88 lines (76 loc) · 2.42 KB
/
flake.nix
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
{
description = "Get information about Niv dependencies";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable-small";
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = { self, nixpkgs, flake-utils, pre-commit-hooks }:
flake-utils.lib.eachDefaultSystem (system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs.lib) mkForce;
in
{
checks = {
pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;
hooks = {
nix-linter = {
enable = true;
entry = mkForce "${pkgs.nix-linter}/bin/nix-linter";
excludes = [ "nix/sources.nix" ];
};
nixpkgs-fmt = {
enable = true;
entry = mkForce "${pkgs.nixpkgs-fmt}/bin/nixpkgs-fmt --check";
};
prettier = {
enable = true;
entry = mkForce "${pkgs.nodejs}/bin/npm run format-check";
types_or = [ "json" "toml" "yaml" "ts" ];
excludes = [
"package-lock.json"
];
};
eslint = {
enable = true;
entry = mkForce "${pkgs.nodejs}/bin/npm run lint";
};
shellcheck = {
enable = true;
entry = mkForce "${pkgs.shellcheck}/bin/shellcheck";
files = "\\.sh$";
types_or = mkForce [ ];
};
shfmt = {
enable = true;
entry = mkForce "${pkgs.shfmt}/bin/shfmt -i 2 -sr -d -s -l";
files = "\\.sh$";
};
};
};
};
devShell = pkgs.mkShell {
name = "niv-dep-info-action";
buildInputs = with pkgs; [
git
nix-linter
nixpkgs-fmt
nodejs
shellcheck
shfmt
];
# npm forces output that can't possibly be useful to stdout so redirect
# stdout to stderr
shellHook = ''
${self.checks.${system}.pre-commit-check.shellHook}
npm install --no-fund 1>&2
'';
};
});
}