-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
135 lines (130 loc) · 3.26 KB
/
flake.nix
File metadata and controls
135 lines (130 loc) · 3.26 KB
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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
{
description = "Protobuf Compiler/Codegen Declaratively from Nix";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
treefmt-nix.url = "github:numtide/treefmt-nix";
};
outputs = inputs: let
eachSystem = f:
builtins.listToAttrs (
map
(system: {
name = system;
value = f system;
})
[
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
]
);
treefmtEval = eachSystem (
system: let
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [];
};
in
inputs.treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";
programs = {
alejandra.enable = true;
buf.enable = true;
prettier.enable = true;
prettier.includes = [
"**/*.md"
"**/*.mdx"
"**/*.ts"
"**/*.tsx"
"**/*.json"
];
yamlfmt.enable = true;
};
}
);
in {
# Flake formatter output for `nix fmt`
formatter = eachSystem (
system:
treefmtEval.${system}.config.build.wrapper
);
# Add checks
checks = eachSystem (system: let
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [];
};
in {
# formatting = treefmtEval.${system}.config.build.check inputs.self;
});
devShells = eachSystem (
system: let
pkgs = import inputs.nixpkgs {
inherit system;
overlays = [];
};
scripts = {
dx = {
exec = ''$EDITOR "$(git rev-parse --show-toplevel)"/flake.nix'';
description = "Edit flake.nix";
};
lint = {
exec = ''
REPO_ROOT="$(git rev-parse --show-toplevel)"
statix check "$REPO_ROOT"/flake.nix
deadnix "$REPO_ROOT"/flake.nix
'';
deps = with pkgs; [statix deadnix];
description = "Lint nix files";
};
};
scriptPackages =
pkgs.lib.mapAttrs
(
name: script:
pkgs.writeShellApplication {
inherit name;
text = script.exec;
runtimeInputs = script.deps or [];
}
)
scripts;
in {
default = pkgs.mkShell {
shellHook = ''
export REPO_ROOT=$(git rev-parse --show-toplevel)
'';
packages = with pkgs;
[
# Nix
alejandra
nixd
statix
nixdoc
# Add the formatter to the devShell
treefmtEval.${system}.config.build.wrapper
git-bug
# Python for package update scripts
python3
actionlint
shellcheck
act
]
++ builtins.attrValues scriptPackages;
};
}
);
lib = {
mkBufrnixPackage = {
pkgs,
self ? null,
config ? {},
...
}:
import "${inputs.self}/src/lib/mkBufrnix.nix" {
inherit pkgs self config;
};
};
};
}