This repository has been archived by the owner on Aug 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
192 lines (178 loc) · 5.68 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
192
{
description = "Nixobolus flake";
nixConfig = {
extra-substituters = [
"https://cache.nixos.org"
"https://nix-community.cachix.org"
];
extra-trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
devenv.url = "github:cachix/devenv";
ethereum-nix.url = "github:nix-community/ethereum.nix";
flake-parts.url = "github:hercules-ci/flake-parts";
nixpkgs-stable.url = "github:NixOS/nixpkgs/nixos-23.05";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
keep-core.url = "github:jhvst/nix-config?dir=packages/keep-core";
};
outputs = {
self,
ethereum-nix,
flake-parts,
nixpkgs,
nixpkgs-stable,
...
} @ inputs:
flake-parts.lib.mkFlake {inherit inputs;} rec {
systems = nixpkgs.lib.systems.flakeExposed;
imports = [
inputs.devenv.flakeModule
inputs.flake-parts.flakeModules.easyOverlay
];
perSystem = {
pkgs,
lib,
config,
system,
...
}: {
# Overlays
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [
self.overlays.default
];
config = {};
};
overlayAttrs = {
inherit
(config.packages)
blutgang
buidl
erigon
homestakeros
keep-core
lighthouse
nethermind
nimbus
prysm
reth
ssvnode
teku
;
};
# Nix code formatter, accessible through 'nix fmt'
formatter = nixpkgs.legacyPackages.${system}.alejandra;
# Development shell
# Accessible trough 'nix develop .# --impure' or 'direnv allow'
devenv.shells = {
default = {
packages = with pkgs; [
buidl
];
env = {
NIX_CONFIG = ''
accept-flake-config = true
extra-experimental-features = flakes nix-command
warn-dirty = false
'';
};
pre-commit.hooks = {
alejandra.enable = true;
shellcheck.enable = true;
};
# Workaround for https://github.com/cachix/devenv/issues/760
containers = pkgs.lib.mkForce {};
};
};
# Custom packages, accessible trough 'nix build', 'nix run', etc.
packages =
rec {
"buidl" = pkgs.callPackage ./packages/buidl {};
# Ethereum.nix
"blutgang" = inputs.ethereum-nix.packages.${system}.blutgang;
"erigon" = inputs.ethereum-nix.packages.${system}.erigon;
"lighthouse" = inputs.ethereum-nix.packages.${system}.lighthouse;
"nethermind" = inputs.ethereum-nix.packages.${system}.nethermind;
"nimbus" = inputs.ethereum-nix.packages.${system}.nimbus;
"prysm" = inputs.ethereum-nix.packages.${system}.prysm;
"reth" = inputs.ethereum-nix.packages.${system}.reth;
"ssvnode" = inputs.ethereum-nix.packages.${system}.ssvnode;
"teku" = inputs.ethereum-nix.packages.${system}.teku;
"keep-core" = inputs.keep-core.packages.${system}.keep-core;
}
# Entrypoint aliases, accessible trough 'nix build'
// (with flake.nixosConfigurations; {
"homestakeros" = homestakeros.config.system.build.kexecTree;
});
};
flake = let
inherit (self) outputs;
homestakeros = {
system = "x86_64-linux";
specialArgs = {inherit inputs outputs;};
modules =
[
self.nixosModules.kexecTree
self.nixosModules.homestakeros
{
system.stateVersion = "23.11";
}
]
++ nixpkgs.lib.optional (builtins.pathExists /tmp/data.nix) /tmp/data.nix;
};
# Function to format module options
parseOpts = options:
nixpkgs.lib.attrsets.mapAttrsRecursiveCond (v: ! nixpkgs.lib.options.isOption v)
(k: v: {
type = v.type.name;
default = v.default;
description =
if v ? description
then v.description
else null;
example =
if v ? example
then v.example
else null;
})
options;
# Function to get options from module(s)
getOpts = modules:
builtins.removeAttrs
(nixpkgs.lib.evalModules {
inherit modules;
specialArgs = {inherit nixpkgs;};
})
.options ["_module"];
in {
# HomestakerOS module for Ethereum-related components
# A accessible through 'nix eval --json .#exports'
nixosModules.homestakeros = {
imports = [
./modules/homestakeros
./modules/homestakeros/system.nix
];
};
# Module option exports for the frontend
# Accessible through 'nix eval --json .#exports'
exports = parseOpts (getOpts [
./modules/homestakeros/options.nix
]);
# NixOS configuration entrypoints for the frontend
nixosConfigurations = with nixpkgs.lib; {
"homestakeros" = nixosSystem homestakeros;
};
# Format modules
nixosModules.isoImage = {
imports = [./modules/copytoram-iso.nix];
};
nixosModules.kexecTree = {
imports = [./modules/netboot-kexec.nix];
};
};
};
}