-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
261 lines (242 loc) · 10.3 KB
/
Copy pathflake.nix
File metadata and controls
261 lines (242 loc) · 10.3 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
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
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
{
description = "SourceOS Linux realization root";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
nixos-apple-silicon = {
url = "github:tpwrules/nixos-apple-silicon";
inputs.nixpkgs.follows = "nixpkgs";
};
sops-nix = {
url = "github:Mic92/sops-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
lampstand-src = {
url = "github:SocioProphet/lampstand";
flake = false;
};
sourceos-syncd-src = {
url = "github:SourceOS-Linux/sourceos-syncd";
flake = false;
};
sourceos-boot-src = {
url = "github:SourceOS-Linux/sourceos-boot";
flake = false;
};
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = { self, nixpkgs, nixos-apple-silicon, sops-nix, lampstand-src, sourceos-syncd-src, sourceos-boot-src, nixos-generators }:
let
lib = nixpkgs.lib;
systems = [ "x86_64-linux" "aarch64-linux" ];
forAllSystems = f: lib.genAttrs systems (system: f system);
in {
formatter = forAllSystems (system: nixpkgs.legacyPackages.${system}.nixpkgs-fmt);
packages = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in rec {
meshd = pkgs.callPackage ./packages/mesh/meshd.nix { };
meshd-linkd = pkgs.callPackage ./packages/mesh/meshd-linkd.nix { };
meshd-exitd = pkgs.callPackage ./packages/mesh/meshd-exitd.nix { };
lampstand = pkgs.callPackage ./packages/search/lampstand.nix {
inherit lampstand-src;
};
sourceos-syncd = pkgs.callPackage ./packages/sourceos-syncd/default.nix {
inherit sourceos-syncd-src;
};
sourceos-boot = pkgs.callPackage ./packages/sourceos-boot/default.nix {
inherit sourceos-boot-src;
};
default = meshd;
} // lib.optionalAttrs (system == "x86_64-linux") (
let
syncdPkgImg = pkgs.callPackage ./packages/sourceos-syncd/default.nix { inherit sourceos-syncd-src; };
bootPkgImg = pkgs.callPackage ./packages/sourceos-boot/default.nix { inherit sourceos-boot-src; };
in {
sourceos-image-qcow2-canary = nixos-generators.nixosGenerate {
system = "x86_64-linux";
specialArgs = { self = self; syncdPkg = syncdPkgImg; bootPkg = bootPkgImg; };
modules = [
sops-nix.nixosModules.sops
self.nixosModules.sourceos-syncd
./images/canary-x86_64.nix
];
format = "qcow";
};
sourceos-image-qcow2-stable = nixos-generators.nixosGenerate {
system = "x86_64-linux";
specialArgs = { self = self; syncdPkg = syncdPkgImg; bootPkg = bootPkgImg; };
modules = [
sops-nix.nixosModules.sops
self.nixosModules.sourceos-syncd
./images/release-x86_64.nix
];
format = "qcow";
};
}
));
devShells = forAllSystems (system:
let
pkgs = nixpkgs.legacyPackages.${system};
workstationV0Names = [
"git" "jq" "nixpkgs-fmt"
"fzf" "atuin" "bat" "zoxide" "yazi" "eza" "gum" "direnv" "tldr" "fd" "ripgrep"
"sd"
"lazygit" "gh" "diff-so-fancy" "tig" "svu"
"tmux" "sesh" "mprocs" "procs" "lazydocker" "k9s" "btop"
"jnv" "gojq" "fx" "jless" "jqp"
"dua" "dust" "kondo"
"glow" "hyperfine" "entr" "curlie"
"rclone" "rsync" "minio-client"
];
haveAttr = n: builtins.hasAttr n pkgs;
missing = lib.filter (n: !(haveAttr n)) workstationV0Names;
presentPkgs = lib.filter (p: p != null) (map (n: if haveAttr n then pkgs.${n} else null) workstationV0Names);
missingStr = lib.concatStringsSep " " missing;
in {
default = pkgs.mkShell {
packages = with pkgs; [ git jq nixpkgs-fmt ];
shellHook = ''
echo "SourceOS Linux development shell"
echo "See docs/repository-layout.md, docs/agentplane-integration.md, and docs/mesh/README.md"
'';
};
workstation-v0 = pkgs.mkShell {
packages = presentPkgs ++ [ self.packages.${system}.lampstand ];
shellHook = ''
echo "SourceOS Workstation v0 dev shell"
echo "See docs/workstation/README.md"
if [ -n "${missingStr}" ]; then
echo "NOTE: missing nixpkgs attrs (not added): ${missingStr}"
fi
'';
};
});
nixosModules = {
sourceos-syncd = import ./modules/nixos/sourceos-syncd/default.nix;
};
nixosConfigurations = {
builder-aarch64 =
let
pkgs-aarch64 = nixpkgs.legacyPackages.aarch64-linux;
syncdPkg = pkgs-aarch64.callPackage ./packages/sourceos-syncd/default.nix {
inherit sourceos-syncd-src;
};
bootPkg = pkgs-aarch64.callPackage ./packages/sourceos-boot/default.nix {
inherit sourceos-boot-src;
};
in lib.nixosSystem {
system = "aarch64-linux";
specialArgs = { inherit self syncdPkg bootPkg; };
modules = [
nixos-apple-silicon.nixosModules.apple-silicon-support
sops-nix.nixosModules.sops
self.nixosModules.sourceos-syncd
./hosts/builder-aarch64/default.nix
];
};
canary-x86_64 =
let
pkgs-x86_64 = nixpkgs.legacyPackages.x86_64-linux;
syncdPkg = pkgs-x86_64.callPackage ./packages/sourceos-syncd/default.nix {
inherit sourceos-syncd-src;
};
bootPkg = pkgs-x86_64.callPackage ./packages/sourceos-boot/default.nix {
inherit sourceos-boot-src;
};
in lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit self syncdPkg bootPkg; };
modules = [
sops-nix.nixosModules.sops
self.nixosModules.sourceos-syncd
./hosts/canary-x86_64/default.nix
];
};
stable-x86_64 =
let
pkgs-x86_64 = nixpkgs.legacyPackages.x86_64-linux;
syncdPkg = pkgs-x86_64.callPackage ./packages/sourceos-syncd/default.nix {
inherit sourceos-syncd-src;
};
bootPkg = pkgs-x86_64.callPackage ./packages/sourceos-boot/default.nix {
inherit sourceos-boot-src;
};
in lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit self syncdPkg bootPkg; };
modules = [
sops-nix.nixosModules.sops
self.nixosModules.sourceos-syncd
./hosts/stable-x86_64/default.nix
];
};
exit-x86_64 =
let
pkgs-x86_64 = nixpkgs.legacyPackages.x86_64-linux;
syncdPkg = pkgs-x86_64.callPackage ./packages/sourceos-syncd/default.nix {
inherit sourceos-syncd-src;
};
bootPkg = pkgs-x86_64.callPackage ./packages/sourceos-boot/default.nix {
inherit sourceos-boot-src;
};
in lib.nixosSystem {
system = "x86_64-linux";
specialArgs = { inherit self syncdPkg bootPkg; };
modules = [
sops-nix.nixosModules.sops
self.nixosModules.sourceos-syncd
./hosts/exit-x86_64/default.nix
];
};
};
checks = forAllSystems (system:
let pkgs = nixpkgs.legacyPackages.${system};
in lib.optionalAttrs (system == "x86_64-linux" || system == "aarch64-linux") {
builder-aarch64-smoke =
if system == "aarch64-linux"
then import ./tests/builder-aarch64-contract.nix { inherit pkgs; }
else pkgs.runCommand "builder-aarch64-smoke-skip" {} ''
mkdir -p $out
'';
canary-x86_64-smoke =
if system == "x86_64-linux"
then import ./tests/canary-x86_64-contract.nix { inherit pkgs; }
else pkgs.runCommand "canary-x86_64-smoke-skip" {} ''
mkdir -p $out
'';
stable-x86_64-smoke =
if system == "x86_64-linux"
then import ./tests/stable-x86_64-contract.nix { inherit pkgs; }
else pkgs.runCommand "stable-x86_64-smoke-skip" {} ''
mkdir -p $out
'';
exit-x86_64-smoke =
if system == "x86_64-linux"
then import ./tests/exit-x86_64-contract.nix { inherit pkgs; }
else pkgs.runCommand "exit-x86_64-smoke-skip" {} ''
mkdir -p $out
'';
mesh-module-contract = import ./tests/mesh-module-contract.nix { inherit pkgs; };
mesh-runtime-contract = import ./tests/mesh-runtime-contract.nix { inherit pkgs; };
mesh-package-contract = import ./tests/mesh-package-contract.nix { inherit pkgs; };
mesh-host-runtime-contract = import ./tests/mesh-host-runtime-contract.nix { inherit pkgs; };
sourceos-shell-module-contract = import ./tests/sourceos-shell-module-contract.nix { inherit pkgs; };
sourceos-shell-pdf-stack-contract = import ./tests/sourceos-shell-pdf-stack-contract.nix { inherit pkgs; };
meshd-package = self.packages.${system}.meshd;
meshd-linkd-package = self.packages.${system}.meshd-linkd;
meshd-exitd-package = self.packages.${system}.meshd-exitd;
lampstand-package = self.packages.${system}.lampstand;
sourceos-syncd-package = self.packages.${system}.sourceos-syncd;
sourceos-boot-package = self.packages.${system}.sourceos-boot;
sourceos-syncd-package-contract = import ./tests/sourceos-syncd-package-contract.nix { inherit pkgs; };
sourceos-boot-package-contract = import ./tests/sourceos-boot-package-contract.nix { inherit pkgs; };
});
sourceos = {
channels = [ "dev" "candidate" "stable" ];
notes = "This flake is the Linux realization root. Control-plane semantics live in SocioProphet/agentplane and shared channel/capability schemas live in SocioProphet/socioprophet-agent-standards.";
};
};
}