forked from nix-community/ethereum.nix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
191 lines (181 loc) · 5.37 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
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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
{
description = "ethereum.nix / A reproducible Nix package set for Ethereum clients and utilities";
nixConfig = {
extra-substituters = ["https://nix-community.cachix.org"];
extra-trusted-public-keys = ["nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="];
};
inputs = {
# packages
nixpkgs.url = "github:nixos/nixpkgs/23.11";
nixpkgs-unstable.url = "github:nixos/nixpkgs/nixpkgs-unstable";
foundry-nix = {
url = "github:shazow/foundry.nix/monthly";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
inputs.systems.follows = "systems";
inputs.treefmt-nix.follows = "treefmt-nix";
};
# flake-parts
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
# used by dependencies
flake-utils.url = "github:numtide/flake-utils";
flake-utils.inputs.systems.follows = "systems";
# utils
systems.url = "github:nix-systems/default";
devshell = {
url = "github:numtide/devshell";
inputs.flake-utils.follows = "flake-utils";
inputs.nixpkgs.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-compat.url = "github:nix-community/flake-compat";
devour-flake = {
url = "github:srid/devour-flake";
flake = false;
};
lib-extras = {
url = "github:aldoborrero/lib-extras/v0.2.2";
inputs.devshell.follows = "devshell";
inputs.flake-parts.follows = "flake-parts";
inputs.nixpkgs.follows = "nixpkgs";
inputs.treefmt-nix.follows = "treefmt-nix";
};
};
outputs = inputs @ {
flake-parts,
nixpkgs,
lib-extras,
systems,
...
}: let
lib = nixpkgs.lib.extend (l: _: {
extras = (lib-extras.lib l) // (import ./lib.nix l);
});
in
flake-parts.lib.mkFlake {
inherit inputs;
specialArgs = {inherit lib;};
}
{
imports = [
inputs.devshell.flakeModule
inputs.treefmt-nix.flakeModule
./mkdocs.nix
./modules
./pkgs
];
systems = import systems;
perSystem = {
config,
pkgs,
pkgsUnstable,
system,
self',
...
}: {
# pkgs
_module.args = {
pkgs = lib.extras.nix.mkNixpkgs {
inherit system;
inherit (inputs) nixpkgs;
};
pkgsUnstable = lib.extras.nix.mkNixpkgs {
inherit system;
nixpkgs = inputs.nixpkgs-unstable;
};
};
# devshell
devshells.default = {
name = "ethereum.nix";
packages = with pkgsUnstable; [
nix-update
];
commands = [
{
category = "Tools";
name = "fmt";
help = "Format the source tree";
command = "nix fmt";
}
{
category = "Tools";
name = "check";
help = "Checks the source tree";
command = "nix flake check";
}
];
};
# formatter
treefmt.config = {
projectRootFile = "flake.nix";
flakeFormatter = true;
flakeCheck = true;
programs = {
alejandra.enable = true;
deadnix.enable = true;
deno.enable = true;
mdformat.enable = true;
statix.enable = true;
};
settings.formatter = {
deno.excludes = [
"*.md"
"*.html"
];
mdformat.command = lib.mkDefault (pkgsUnstable.mdformat.withPlugins (p: [
p.mdformat-admon
p.mdformat-beautysh
p.mdformat-footnote
p.mdformat-frontmatter
p.mdformat-gfm
p.mdformat-mkdocs
p.mdformat-nix-alejandra
p.mdformat-simple-breaks
p.mdformat-toc
]));
mdformat.excludes = [
# mdformat doesn't behave well with some admonitions features
"apps.md"
"getting-started.md"
"index.md"
"restore-from-backup.md"
];
};
};
# checks
checks =
{
# TODO: Restore this check whenever buildbot supports more specific checks
# nix-build-all = pkgs.writeShellApplication {
# name = "nix-build-all";
# runtimeInputs = [
# pkgs.nix
# devour-flake
# ];
# text = ''
# # Make sure that flake.lock is sync
# nix flake lock --no-update-lock-file
#
# # Do a full nix build (all outputs)
# devour-flake . "$@"
# '';
# };
}
# merge in the package derivations to force a build of all packages during a `nix flake check`
// (with lib; mapAttrs' (n: nameValuePair "package-${n}") (filterAttrs (n: _: ! builtins.elem n ["docs"]) self'.packages))
# mix in tests
// config.testing.checks;
};
};
}