@highstate/library 0.7.10 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/index.ts CHANGED
@@ -12,3 +12,5 @@ export * as restic from "./restic"
12
12
  export * as mullvad from "./mullvad"
13
13
  export * as dns from "./dns"
14
14
  export * as timeweb from "./timeweb"
15
+ export * as nixos from "./nixos"
16
+ export * as sops from "./sops"
package/src/k3s.ts CHANGED
@@ -1,16 +1,24 @@
1
1
  import { defineUnit } from "@highstate/contract"
2
+ import { Type } from "@sinclair/typebox"
2
3
  import { serverEntity } from "./common"
3
4
  import { clusterEntity, sharedClusterArgs } from "./k8s"
5
+ import { providerEntity } from "./dns"
4
6
 
5
7
  export const cluster = defineUnit({
6
8
  type: "k3s.cluster",
7
9
 
8
10
  args: {
9
11
  ...sharedClusterArgs,
12
+ config: Type.Optional(Type.Record(Type.String(), Type.Any())),
10
13
  },
11
14
 
12
15
  inputs: {
13
16
  server: serverEntity,
17
+ dnsProviders: {
18
+ entity: providerEntity,
19
+ required: false,
20
+ multiple: true,
21
+ },
14
22
  },
15
23
 
16
24
  outputs: {
package/src/k8s.ts CHANGED
@@ -6,6 +6,9 @@ export const clusterInfoSchema = Type.Object({
6
6
  name: Type.String(),
7
7
  cni: Type.Optional(Type.String()),
8
8
  externalIps: Type.Array(Type.String()),
9
+ fqdn: Type.Optional(Type.String()),
10
+ kubeApiServerIp: Type.Optional(Type.String()),
11
+ kubeApiServerPort: Type.Optional(Type.Number()),
9
12
  })
10
13
 
11
14
  export const serviceTypeSchema = Type.StringEnum(["NodePort", "LoadBalancer", "ClusterIP"])
@@ -168,15 +171,16 @@ export const tlsIssuerEntity = defineEntity({
168
171
  })
169
172
 
170
173
  export const accessPointEntity = defineEntity({
171
- type: "common.access-point",
174
+ type: "k8s.access-point",
175
+
172
176
  schema: Type.Object({
173
177
  gateway: gatewayEntity.schema,
174
178
  tlsIssuer: tlsIssuerEntity.schema,
175
- dnsProvider: providerEntity.schema,
179
+ dnsProviders: Type.Array(providerEntity.schema),
176
180
  }),
177
181
 
178
182
  meta: {
179
- color: "#FFC107",
183
+ color: "#F57F17",
180
184
  },
181
185
  })
182
186
 
@@ -186,7 +190,10 @@ export const accessPoint = defineUnit({
186
190
  inputs: {
187
191
  gateway: gatewayEntity,
188
192
  tlsIssuer: tlsIssuerEntity,
189
- dnsProvider: providerEntity,
193
+ dnsProviders: {
194
+ entity: providerEntity,
195
+ multiple: true,
196
+ },
190
197
  },
191
198
 
192
199
  outputs: {
@@ -231,9 +238,23 @@ export const certManager = defineUnit({
231
238
  export const dns01TlsIssuer = defineUnit({
232
239
  type: "k8s.dns01-issuer",
233
240
 
241
+ args: {
242
+ /**
243
+ * The top-level domains to filter the DNS01 challenge for.
244
+ *
245
+ * If not provided, will use all domains passed to the DNS providers.
246
+ *
247
+ * @schema
248
+ */
249
+ domains: Type.Optional(Type.Array(Type.String())),
250
+ },
251
+
234
252
  inputs: {
235
253
  k8sCluster: clusterEntity,
236
- dnsProvider: providerEntity,
254
+ dnsProviders: {
255
+ entity: providerEntity,
256
+ multiple: true,
257
+ },
237
258
  },
238
259
 
239
260
  outputs: {
@@ -333,6 +354,30 @@ export const interfaceEntity = defineEntity({
333
354
  },
334
355
  })
335
356
 
357
+ export const gatewayApi = defineUnit({
358
+ type: "k8s.gateway-api",
359
+
360
+ inputs: {
361
+ k8sCluster: clusterEntity,
362
+ },
363
+
364
+ outputs: {
365
+ k8sCluster: clusterEntity,
366
+ },
367
+
368
+ meta: {
369
+ displayName: "Gateway API",
370
+ description: "Installs the Gateway API CRDs to the cluster.",
371
+ primaryIcon: "mdi:kubernetes",
372
+ primaryIconColor: "#4CAF50",
373
+ },
374
+
375
+ source: {
376
+ package: "@highstate/k8s",
377
+ path: "units/gateway-api",
378
+ },
379
+ })
380
+
336
381
  export type ClusterInfo = Static<typeof clusterInfoSchema>
337
382
  export type Cluster = Static<typeof clusterEntity.schema>
338
383
 
package/src/nixos.ts CHANGED
@@ -0,0 +1,167 @@
1
+ import { defineEntity, defineUnit, Type } from "@highstate/contract"
2
+ import { fileEntity, serverEntity } from "./common"
3
+
4
+ export const inlineModuleEntity = defineEntity({
5
+ type: "nixos.inline-module",
6
+
7
+ schema: Type.Object({
8
+ code: Type.String(),
9
+ }),
10
+
11
+ meta: {
12
+ displayName: "NixOS Inline Module",
13
+ description: "The NixOS module reference.",
14
+ color: "#5277c3",
15
+ },
16
+ })
17
+
18
+ export const inlineModule = defineUnit({
19
+ type: "nixos.inline-module",
20
+
21
+ args: {
22
+ code: Type.String({ language: "nix" }),
23
+ },
24
+
25
+ inputs: {
26
+ files: {
27
+ entity: fileEntity,
28
+ required: false,
29
+ multiple: true,
30
+ },
31
+ },
32
+
33
+ outputs: {
34
+ module: inlineModuleEntity,
35
+ },
36
+
37
+ meta: {
38
+ displayName: "NixOS Inline Module",
39
+ description: "Creates a NixOS module from inline code.",
40
+ primaryIcon: "simple-icons:nixos",
41
+ primaryIconColor: "#7ebae4",
42
+ secondaryIcon: "mdi:file-code",
43
+ },
44
+
45
+ source: {
46
+ package: "@highstate/nixos",
47
+ path: "inline-module",
48
+ },
49
+ })
50
+
51
+ export const flakeEntity = defineEntity({
52
+ type: "nixos.flake",
53
+
54
+ schema: Type.Object({
55
+ url: Type.String(),
56
+ }),
57
+
58
+ meta: {
59
+ displayName: "NixOS Flake",
60
+ description: "The NixOS flake reference.",
61
+ color: "#5277c3",
62
+ },
63
+ })
64
+
65
+ export const remoteFlake = defineUnit({
66
+ type: "nixos.remote-flake",
67
+
68
+ args: {
69
+ url: Type.String(),
70
+ },
71
+
72
+ outputs: {
73
+ flake: flakeEntity,
74
+ },
75
+
76
+ meta: {
77
+ displayName: "NixOS Remote Flake",
78
+ description: "References a remote NixOS flake.",
79
+ primaryIcon: "simple-icons:nixos",
80
+ primaryIconColor: "#7ebae4",
81
+ secondaryIcon: "simple-icons:git",
82
+ secondaryIconColor: "#f1502f",
83
+ },
84
+
85
+ source: {
86
+ package: "@highstate/nixos",
87
+ path: "flake",
88
+ },
89
+ })
90
+
91
+ export const inlineFlake = defineUnit({
92
+ type: "nixos.inline-flake",
93
+
94
+ args: {
95
+ code: Type.String({ language: "nix" }),
96
+ },
97
+
98
+ inputs: {
99
+ flakes: {
100
+ entity: flakeEntity,
101
+ required: false,
102
+ multiple: true,
103
+ },
104
+ modules: {
105
+ entity: inlineModuleEntity,
106
+ required: false,
107
+ multiple: true,
108
+ },
109
+ files: {
110
+ entity: fileEntity,
111
+ required: false,
112
+ multiple: true,
113
+ },
114
+ },
115
+
116
+ outputs: {
117
+ flake: flakeEntity,
118
+ },
119
+
120
+ meta: {
121
+ displayName: "NixOS Inline Flake",
122
+ description: "Creates a NixOS flake from inline code.",
123
+ primaryIcon: "simple-icons:nixos",
124
+ primaryIconColor: "#7ebae4",
125
+ secondaryIcon: "mdi:file-code",
126
+ },
127
+
128
+ source: {
129
+ package: "@highstate/nixos",
130
+ path: "inline-flake",
131
+ },
132
+ })
133
+
134
+ export const system = defineUnit({
135
+ type: "nixos.system",
136
+
137
+ args: {
138
+ system: Type.Optional(Type.String()),
139
+ },
140
+
141
+ inputs: {
142
+ flake: flakeEntity,
143
+ server: serverEntity,
144
+ modules: {
145
+ entity: inlineModuleEntity,
146
+ required: false,
147
+ multiple: true,
148
+ },
149
+ },
150
+
151
+ outputs: {
152
+ server: serverEntity,
153
+ },
154
+
155
+ meta: {
156
+ displayName: "NixOS System",
157
+ description: "Creates a NixOS system on top of any server.",
158
+ primaryIcon: "simple-icons:nixos",
159
+ primaryIconColor: "#7ebae4",
160
+ secondaryIcon: "codicon:vm",
161
+ },
162
+
163
+ source: {
164
+ package: "@highstate/nixos",
165
+ path: "system",
166
+ },
167
+ })
package/src/sops.ts ADDED
@@ -0,0 +1,33 @@
1
+ import { defineUnit, Type } from "@highstate/contract"
2
+ import { fileEntity, serverEntity } from "./common"
3
+
4
+ export const secrets = defineUnit({
5
+ type: "sops.secrets",
6
+
7
+ args: {
8
+ secrets: Type.Record(Type.String(), Type.Any()),
9
+ },
10
+
11
+ inputs: {
12
+ servers: {
13
+ entity: serverEntity,
14
+ required: false,
15
+ multiple: true,
16
+ },
17
+ },
18
+
19
+ outputs: {
20
+ file: fileEntity,
21
+ },
22
+
23
+ meta: {
24
+ displayName: "SOPS Secrets",
25
+ description: "Encrypts secrets using SOPS for the specified servers.",
26
+ primaryIcon: "mdi:file-lock",
27
+ },
28
+
29
+ source: {
30
+ package: "@highstate/sops",
31
+ path: "secrets",
32
+ },
33
+ })
package/src/wireguard.ts CHANGED
@@ -357,11 +357,21 @@ export const identity = defineUnit({
357
357
  * The FQDN of the WireGuard identity.
358
358
  * Will be used as endpoint for the peer.
359
359
  *
360
- * If `dnsProvider` is provided and `externalIp` is available, the FQDN will be registered automatically.
360
+ * If `dnsProvider` is provided, external IP is available and `registerFqdn` is set to `true`, and FQDN is provided explicitly (not obtained from the k8s cluster),
361
+ * the FQDN will be registered with the DNS provider.
361
362
  *
362
363
  * @schema
363
364
  */
364
365
  fqdn: Type.Optional(Type.String()),
366
+
367
+ /**
368
+ * Whether to register the FQDN of the identity with the DNS provider.
369
+ *
370
+ * By default, `true`.
371
+ *
372
+ * @schema
373
+ */
374
+ registerFqdn: Type.Default(Type.Boolean(), true),
365
375
  },
366
376
 
367
377
  secrets: {
@@ -410,6 +420,16 @@ export const identity = defineUnit({
410
420
  required: false,
411
421
  },
412
422
 
423
+ /**
424
+ * The Kubernetes cluster associated with the identity.
425
+ *
426
+ * If provided, will be used to obtain the external IP or FQDN of the identity.
427
+ */
428
+ k8sCluster: {
429
+ entity: clusterEntity,
430
+ required: false,
431
+ },
432
+
413
433
  dnsProvider: {
414
434
  entity: providerEntity,
415
435
  required: false,