-
Notifications
You must be signed in to change notification settings - Fork 2
/
flake.nix
201 lines (170 loc) · 5.39 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
193
194
195
196
197
198
199
200
201
{
nixConfig = {
extra-substituters = [
"https://colmena.cachix.org"
"https://cuda-maintainers.cachix.org"
];
extra-trusted-public-keys = [
"colmena.cachix.org-1:7BzpDnjjH8ki2CT3f6GdOk7QAzPOl+1t3LvTLXqYcSg="
"cuda-maintainers.cachix.org-1:0dq3bujKpuEPMCX6U4WylrUDZ9JyUG0VpVZa7CNfq5E="
];
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
colmena.url = "github:zhaofengli/colmena";
colmena.inputs.nixpkgs.follows = "nixpkgs";
nix-github-actions.url = "github:nix-community/nix-github-actions";
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
nixpkgs-wayland.url = "github:nix-community/nixpkgs-wayland";
nixpkgs-wayland.inputs.nixpkgs.follows = "nixpkgs";
nixos-hardware.url = "github:NixOS/nixos-hardware";
# nixos-hardware.inputs.nixpkgs.follows = "nixpkgs";
home-manager.url = "github:nix-community/home-manager";
home-manager.inputs.nixpkgs.follows = "nixpkgs";
ethereum.url = "github:nix-community/ethereum.nix";
#ethereum.inputs.nixpkgs.follows = "nixpkgs";
nix-bitcoin.url = "github:fort-nix/nix-bitcoin/release";
nix-bitcoin.inputs.nixpkgs.follows = "nixpkgs";
darwin.url = "github:lnl7/nix-darwin/master";
darwin.inputs.nixpkgs.follows = "nixpkgs";
foundry.url = "github:shazow/foundry.nix";
foundry.inputs.nixpkgs.follows = "nixpkgs";
vscode-server.url = "github:nix-community/nixos-vscode-server";
vscode-server.inputs.nixpkgs.follows = "nixpkgs";
apple-silicon.url = "github:tpwrules/nixos-apple-silicon";
apple-silicon.inputs.nixpkgs.follows = "nixpkgs";
};
outputs =
{ self
, nixpkgs
, colmena
, darwin
, nixos-hardware
, home-manager
, ...
} @ inputs:
let
pkgs = import nixpkgs { system = "x86_64-linux"; };
deploy = import lib/deploy.nix;
inherit (inputs.nixpkgs.lib) composeManyExtensions;
inherit (builtins) attrNames readDir;
localOverlays = map
(f: import (./overlays + "/${f}"))
(attrNames (readDir ./overlays));
hardware =
nixos-hardware.nixosModules //
import lib/hardware.nix "${nixpkgs}/nixos/modules";
hm =
home-manager.nixosModules.home-manager;
vscode-server =
vscode-server.nixosModules.home;
nixpkgs_patched_src = pkgs.applyPatches {
name = "nixpkgs-patched-${nixpkgs.shortRev}";
src = nixpkgs;
patches = [ ];
};
patchedPkgs = forAllSystems (system:
let
pkgs = import nixpkgs_patched_src {
inherit system;
config.allowUnfree = true;
};
in
pkgs // { inherit (nixpkgs) lib; }
);
forAllSystems = f: builtins.listToAttrs (map
(name: { inherit name; value = f name; })
[
"x86_64-linux"
"aarch64-darwin"
]);
consts = import ./consts.nix { inherit (inputs.nixpkgs) lib; };
in
{
lib = { inherit forAllSystems hardware deploy; };
colmena = {
meta = {
description = "My personal machines";
nixpkgs = patchedPkgs.x86_64-linux;
specialArgs = {
inherit inputs;
inherit consts;
};
};
} // builtins.mapAttrs
(name: value: {
nixpkgs.system = value.config.nixpkgs.system;
imports = value._module.args.modules;
})
(self.nixosConfigurations);
darwinConfigurations."air" = darwin.lib.darwinSystem {
system = "aarch64-darwin";
specialArgs = { inherit inputs; };
modules = [
./machines/darwin-aarch64/darwin-configuration.nix
inputs.home-manager.darwinModules.home-manager
({ config, pkgs, ... }: {
nixpkgs.overlays = [
darwin.overlays.default
];
})
];
};
nixosModules =
{
inherit hm;
} //
nixpkgs.lib.mapAttrs'
(name: type: {
name = nixpkgs.lib.removeSuffix ".nix" name;
value = import (./modules + "/${name}");
})
(builtins.readDir ./modules);
nixosModule = {
imports = builtins.attrValues self.nixosModules;
nixpkgs.overlays = [
(composeManyExtensions localOverlays)
# (_: mypkgs)
];
};
devShells = forAllSystems (system: {
default =
let
pkgs = nixpkgs.legacyPackages.${system};
in
pkgs.mkShell {
packages = with pkgs; [
nixVersions.nix_2_24
colmena.packages.${system}.colmena
];
shellHook = ''
echo "Development shell loaded with colmena"
'';
};
});
nixosConfigurations = import
./machines
colmena
(patchedPkgs.x86_64-linux)
hardware
self.nixosModule
inputs
consts;
packages = (patchedPkgs.x86_64-linux);
githubActions =
let
mkGithubMatrix = nixConf: {
matrix = {
include = builtins.map
(x: {
attr = "nixosConfigurations.${x}.config.system.build.toplevel";
os = [ "ubuntu-22.04" ];
})
(builtins.attrNames nixConf);
};
};
in
mkGithubMatrix
self.nixosConfigurations;
};
}