Repository navigation
Expand file tree
/
Copy pathflake.nix
More file actions
816 lines (801 loc) · 32.4 KB
/
Copy pathflake.nix
File metadata and controls
816 lines (801 loc) · 32.4 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
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
{
description = "Nixfied v2 workspace";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
# Independently pinned Rust toolchain source. Runtime/CLI compiler upgrades
# stay separate from nixpkgs updates: host-Rust-free and reproducible.
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{
self,
nixpkgs,
rust-overlay,
}:
let
systems = [
"aarch64-darwin"
"aarch64-linux"
"x86_64-linux"
];
forAllSystems =
f:
nixpkgs.lib.genAttrs systems (
system:
f {
inherit system;
pkgs = import nixpkgs {
inherit system;
overlays = [ rust-overlay.overlays.default ];
};
}
);
mkNixfiedPackage =
{
pkgs,
package,
buildType ? "release",
}:
import ./nix/packages/runtime.nix {
inherit pkgs package buildType;
};
libraryDeclarations =
{ pkgs, system }:
let
compileManifest =
module:
import ./nix/compiler/default.nix {
inherit (nixpkgs) lib;
inherit pkgs system module;
};
# The release runtime an adopter's apps run against. Lazy: only forced
# when `projectApps` is used, so `compileManifest`-only callers don't build it.
releaseRuntime = mkNixfiedPackage {
inherit pkgs;
package = "nixfied-runtime";
};
composeLib = import ./nix/lib/compose.nix { inherit (nixpkgs) lib; };
resolveConfig =
module:
(import ./nix/compiler/resolve.nix {
inherit (nixpkgs) lib;
inherit pkgs system module;
}).config;
in
[
{
kind = "function";
scope = "library";
name = "compileManifest";
description = "Compile a native Nixfied module into a manifest package.";
input = "A native module function, attribute set, or module path.";
result = "Derivation containing manifest.json and disposable views/docs.md.";
usage = "nixfied.lib.${system}.compileManifest ./nixfied.nix";
references = [
{
kind = "topic";
id = "manifest";
}
];
binding = compileManifest;
}
{
kind = "function";
scope = "library";
name = "seq";
description = "Construct sequential composite steps from distinct task names.";
input = "List of distinct declared task identifiers, in execution order.";
result = "Native steps attribute set; each step depends on its predecessor.";
usage = ''nixfiedLib.seq [ "lint" "test" ]'';
references = [
{
kind = "topic";
id = "derivation";
}
];
binding = composeLib.seq;
}
{
kind = "function";
scope = "library";
name = "projectApps";
description = "Expose discovery, documentation, controls and explicitly exported project tasks.";
input = "A Nix module path, function, or attribute set.";
result = "Native flake app attribute set with descriptions.";
usage = "apps.${system} = nixfied.lib.${system}.projectApps ./nixfied.nix;";
references = [
{
kind = "topic";
id = "discovery";
}
{
kind = "option";
path = [
"nixfied"
"surface"
"verbs"
];
}
];
binding =
module:
import ./nix/project-apps.nix {
inherit pkgs releaseRuntime system;
inherit (nixpkgs) lib;
docs = docsFor { inherit pkgs system; };
publicationTargets = (authoringFor { inherit pkgs system; }).targets;
manifest = compileManifest module;
config = resolveConfig module;
};
}
];
authoringFor = args: import ./nix/meta/authoring.nix ({ inherit (nixpkgs) lib; } // args);
publicationFor =
args@{ pkgs, system }:
let
authoring = authoringFor args;
in
import ./nix/meta/publications.nix { inherit (nixpkgs) lib; } {
targets = authoring.targets;
declarations =
authoring.declarations
++ libraryDeclarations args
++ packageDeclarations args
++ appDeclarations args
++ checkDeclarations args
++ shellDeclarations args
++ import ./nix/project-publications.nix { };
};
publications = forAllSystems publicationFor;
mkNixfiedLib = { system, ... }: publications.${system}.project "function" "library";
docsFor =
args:
import ./nix/docs/reference.nix (
{
inherit (nixpkgs) lib;
options = (authoringFor args).options;
publications = publications.${args.system}.entries;
source = {
path = toString self.outPath;
revision = self.rev or null;
dirtyRevision = self.dirtyRev or null;
narHash = self.narHash or null;
};
}
// args
);
publishPackage = scope: name: description: artifact: binding: {
kind = "package";
inherit
scope
name
description
artifact
binding
;
usage =
if scope == "devShell" then
"nix develop"
else if scope == "check" then
"nix build .#checks.<system>.${name}"
else
"nix build .#${name}";
};
mkNixfiedTestChild =
pkgs:
mkNixfiedPackage {
inherit pkgs;
package = "nixfied-test-child";
};
packageDeclarations =
{ pkgs, system }:
let
nixfiedLib = mkNixfiedLib { inherit pkgs system; };
# Public release products. The installer uses only the CLI; generated
# project apps use the release runtime through `projectApps` above.
nixfiedCli = mkNixfiedPackage {
inherit pkgs;
package = "nixfied-cli";
};
nixfiedRuntime = mkNixfiedPackage {
inherit pkgs;
package = "nixfied-runtime";
};
# The debug build the framework's own CI path uses (flake checks and the
# gate), so every `.#ci` compile shares one fast profile instead of also
# building release optimization.
nixfiedRuntimeDebug = mkNixfiedPackage {
inherit pkgs;
package = "nixfied-runtime";
buildType = "debug";
};
nixfiedTestChild = mkNixfiedTestChild pkgs;
taskOutputManifest = nixfiedLib.compileManifest (
{ ... }:
{
nixfied.project.projectId = "task-output";
nixfied.project.name = "Task Output";
nixfied.codebases.main.logicalRoot = ".";
nixfied.closures.test-child = {
package = nixfiedTestChild;
executable = "bin/nixfied-test-child";
effects = [ "process" ];
};
nixfied.secrets.task-output-secret = {
source = {
kind = "env-var";
envVar = "NIXFIED_TASK_OUTPUT_SECRET";
};
};
nixfied.tasks.output = {
invocation = {
tools = [ "test-child" ];
run = [
"nixfied-test-child"
"output"
"hex"
"00010200ff0a"
"646961676e6f73746963"
];
};
};
nixfied.tasks.accepted = {
invocation = {
tools = [ "test-child" ];
run = [
"nixfied-test-child"
"output"
"hex-exit"
"6163636570746564"
"6e6f6e7a65726f"
"7"
];
};
exitPolicy.successCodes = [
0
7
];
};
nixfied.tasks.redacted = {
invocation = {
tools = [ "test-child" ];
run = [
"nixfied-test-child"
"output"
"env"
"TOKEN"
];
env.TOKEN = "\${secret:task-output-secret}";
};
};
nixfied.tasks.timeout = {
invocation = {
tools = [ "test-child" ];
run = [
"nixfied-test-child"
"output"
"hex-block"
"74696d656f75742d6f7574707574"
"74696d656f75742d6572726f72"
"\${stateDir}/task-output-timeout-marker"
];
timeoutMs = 150;
};
};
nixfied.tasks.cancel = {
invocation = {
tools = [ "test-child" ];
run = [
"nixfied-test-child"
"output"
"hex-block"
"63616e63656c2d6f7574707574"
"63616e63656c2d6572726f72"
"\${stateDir}/task-output-cancel-marker"
];
};
};
nixfied.tasks.composite-block = {
invocation = {
tools = [ "test-child" ];
run = [
"nixfied-test-child"
"output"
"hex-block"
"636f6d706f736974652d6f7574707574"
"636f6d706f736974652d6572726f72"
"\${stateDir}/task-output-composite-marker"
];
};
};
nixfied.tasks.pipeline = {
kind = "composite";
steps.only.task = "composite-block";
};
}
);
minimalManifest = nixfiedLib.compileManifest ./examples/minimal/nixfied.nix;
sessionEndpointManifest = nixfiedLib.compileManifest (
{ pkgs, ... }:
{
imports = [ ./examples/minimal/nixfied.nix ];
nixfied.state.persistence = "persistent";
nixfied.tasks.endpoint-prepare = {
invocation = {
tools = [
pkgs.bash
pkgs.coreutils
];
run = [
"bash"
"-c"
''
set -euo pipefail
touch "''${stateDir}/endpoint-prepare-sentinel"
''
];
};
};
nixfied.services.synthetic.lifecycle.prepare.task = "endpoint-prepare";
nixfied.tasks.keep-up = {
invocation = {
tools = [ pkgs.bash pkgs.coreutils ];
run = [
"bash"
"-c"
''
set -euo pipefail
touch "''${stateDir}/session-active"
exec sleep 3600
''
];
};
requires = [ "synthetic" ];
};
}
);
purgeMinimalManifest = nixfiedLib.compileManifest (
{ ... }:
{
imports = [ ./examples/minimal/nixfied.nix ];
nixfied.state.persistence = "persistent";
}
);
postgresManifest = nixfiedLib.compileManifest ./examples/postgres/nixfied.nix;
# The cargo lifecycle test runs immediately before the gate in `.#ci`.
# Keep its window distinct from the gate and outside ephemeral ranges:
# polling connect can otherwise self-connect using the destination as
# its ephemeral source port, falsely indicating a live server.
postgresTestManifest = nixfiedLib.compileManifest (
{ lib, ... }:
{
imports = [ ./examples/postgres/nixfied.nix ];
nixfied.placement.ports.base = lib.mkForce 25580;
nixfied.state.persistence = lib.mkForce "persistent";
nixfied.closures.test-child = {
package = nixfiedTestChild;
executable = "bin/nixfied-test-child";
effects = [ "process" ];
};
nixfied.tasks.backend-churn-owner = {
requires = [ "postgres" ];
invocation = {
tools = [ "test-child" ];
run = [
"nixfied-test-child"
"block"
];
};
};
}
);
compositeManifest = nixfiedLib.compileManifest ./examples/composite/nixfied.nix;
downstreamManifest = nixfiedLib.compileManifest ./examples/downstream/nixfied.nix;
# The example shard and the later slot-concurrency shard use distinct
# deterministic windows. A stopped Postgres can leave a non-listening
# TIME_WAIT claim that the required raw-bind preflight must refuse as
# unverifiable rather than silently treating as available.
# Keep both slot windows below the usual Linux ephemeral range too,
# so the preceding socket tests do not allocate these as client ports.
downstreamSlotsManifest = nixfiedLib.compileManifest (
{ lib, ... }:
{
imports = [ ./examples/downstream/nixfied.nix ];
nixfied.placement.ports.base = lib.mkForce 31880;
}
);
rethManifest = nixfiedLib.compileManifest ./examples/reth/nixfied.nix;
toolchainManifest = nixfiedLib.compileManifest ./examples/toolchain/nixfied.nix;
# Gate-only variants of the example manifests, for the state lifecycle
# shard: a configuration change with the same state identity and a new
# manifest hash, and a postgres whose smoke query sleeps long enough
# to interrupt mid-run.
# The lifecycle shard retains data across sessions, so it uses
# persistent retention; run-scoped data ends with its session.
minimalPersistentManifest = nixfiedLib.compileManifest (
{ ... }:
{
imports = [ ./examples/minimal/nixfied.nix ];
nixfied.state.persistence = "persistent";
}
);
minimalManifestB = nixfiedLib.compileManifest (
{ lib, ... }:
{
imports = [ ./examples/minimal/nixfied.nix ];
nixfied.project.name = lib.mkForce "Minimal B";
nixfied.state.persistence = "persistent";
}
);
# A deterministically failing composite (its leaf dials a closed
# port), for the gate's failure-identity negative check.
negativeFailManifest = nixfiedLib.compileManifest (
{ ... }:
{
imports = [ ./examples/minimal/nixfied.nix ];
nixfied.tasks.always-fails = {
operationId = "task.always-fails.run";
invocation = {
tools = [ "synthetic-helper" ];
run = [
"nixfied-synthetic-helper"
"task"
"--host"
"127.0.0.1"
"--port"
"1"
];
};
};
nixfied.tasks.failing = {
kind = "composite";
steps.boom.task = "always-fails";
};
}
);
nixfiedInstall = import ./nix/install/install.nix {
inherit pkgs;
cli = nixfiedCli;
};
nixfiedUpgrade = import ./nix/install/upgrade.nix { inherit pkgs; };
# Nix-layer tests: reject_composite suite + adoption loop.
nixfiedGateNix = import ./nix/gate-nix.nix {
inherit pkgs;
debugRuntime = nixfiedRuntimeDebug;
};
# Runtime-layer tests expressed as a first-class nixfied manifest.
# The compileManifest override injects the runtime closure and all manifest
# paths as compile-time env vars.
gateRuntimeManifest = nixfiedLib.compileManifest (
{ ... }:
{
imports = [ ./nix/gate-runtime/nixfied.nix ];
nixfied.closures.rt = {
package = nixfiedRuntimeDebug;
executable = "bin/nixfied-runtime";
effects = [
"process"
"file-write"
];
};
nixfied.tasks.example-minimal.invocation.env.MINIMAL_MANIFEST = toString minimalManifest;
nixfied.tasks.example-postgres.invocation.env.POSTGRES_MANIFEST = toString postgresManifest;
nixfied.tasks.example-composite.invocation.env.COMPOSITE_MANIFEST = toString compositeManifest;
nixfied.tasks.example-downstream.invocation.env.DOWNSTREAM_MANIFEST = toString downstreamManifest;
nixfied.tasks.example-reth.invocation.env.RETH_MANIFEST = toString rethManifest;
nixfied.tasks.example-toolchain.invocation.env.TOOLCHAIN_MANIFEST = toString toolchainManifest;
nixfied.tasks.task-output.invocation.env.TASK_OUTPUT_MANIFEST = toString taskOutputManifest;
nixfied.tasks.task-output.invocation.env.NIXFIED_TASK_OUTPUT_SECRET = "task-output-gate-secret";
nixfied.tasks.negative-no-selection.invocation.env.MINIMAL_MANIFEST = toString minimalManifest;
nixfied.tasks.negative-undeclared-task.invocation.env.MINIMAL_MANIFEST = toString minimalManifest;
nixfied.tasks.negative-failure-identity.invocation.env.NEGATIVE_FAIL_MANIFEST =
toString negativeFailManifest;
nixfied.tasks.lifecycle-first-run.invocation.env.MINIMAL_MANIFEST =
toString minimalPersistentManifest;
nixfied.tasks.lifecycle-second-run.invocation.env.MINIMAL_MANIFEST =
toString minimalPersistentManifest;
nixfied.tasks.lifecycle-change-preserves-data.invocation.env.MINIMAL_B_MANIFEST =
toString minimalManifestB;
nixfied.tasks.lifecycle-tamper-refusal.invocation.env.MINIMAL_B_MANIFEST =
toString minimalManifestB;
nixfied.tasks.lifecycle-session-ownership.invocation.env.SESSION_ENDPOINT_MANIFEST =
toString sessionEndpointManifest;
nixfied.tasks.lifecycle-purge.invocation.env.PURGE_MINIMAL_MANIFEST = toString purgeMinimalManifest;
nixfied.tasks.endpoint-cross-root.invocation.env.SESSION_ENDPOINT_MANIFEST =
toString sessionEndpointManifest;
nixfied.tasks.slot-0.invocation.env.DOWNSTREAM_MANIFEST = toString downstreamSlotsManifest;
nixfied.tasks.slot-1.invocation.env.DOWNSTREAM_MANIFEST = toString downstreamSlotsManifest;
nixfied.tasks.slots-assert.invocation.env.DOWNSTREAM_MANIFEST = toString downstreamSlotsManifest;
}
);
nixfiedGateRuntime = pkgs.writeShellApplication {
name = "nixfied-gate-runtime";
runtimeInputs = [ nixfiedRuntimeDebug ];
# Every gate task inherits this umask through the runtime.
text = ''
umask 077
nixfied-runtime run \
--manifest "${gateRuntimeManifest}/manifest.json" \
--task all \
--timeout-ms 300000
'';
};
# `nix run .#gate`: the framework gate — runtime-layer tests via the
# gate-runtime nixfied manifest, then nix-layer tests via gate-nix.
nixfiedGate = import ./nix/gate.nix {
inherit pkgs;
gateNix = nixfiedGateNix;
gateRuntime = nixfiedGateRuntime;
};
# `.#check` / `.#test` / `.#ci`: the framework's own source/test/CI gate.
devApps = import ./nix/dev.nix {
inherit pkgs postgresTestManifest;
gate = nixfiedGate;
debugRuntime = nixfiedRuntimeDebug;
testChild = nixfiedTestChild;
};
in
[
(publishPackage "root" "default" "Default minimal example manifest"
"manifest.json and disposable views/docs.md, with realised closure dependencies."
minimalManifest
)
(publishPackage "root" "toolchain-manifest" "Heterogeneous toolchain example manifest"
"manifest.json and disposable views/docs.md, with realised closure dependencies."
toolchainManifest
)
(publishPackage "root" "gate-runtime-manifest" "Runtime integration gate manifest"
"manifest.json and disposable views/docs.md, with realised closure dependencies."
gateRuntimeManifest
)
(publishPackage "root" "nixfied-cli" "Release scaffold installer CLI"
"Executable under bin/ with its native runtime dependencies."
nixfiedCli
)
(publishPackage "root" "nixfied-runtime" "Release generic process runtime"
"Executable under bin/ with its native runtime dependencies."
nixfiedRuntime
)
(publishPackage "root" "install" "Scaffold installation program"
"Executable under bin/ with its native runtime dependencies."
nixfiedInstall
)
(publishPackage "root" "upgrade" "Input upgrade and documentation-report program"
"Executable under bin/ with its native runtime dependencies."
nixfiedUpgrade
)
(publishPackage "root" "gate" "Framework integration gate program"
"Executable under bin/ with its native runtime dependencies."
nixfiedGate
)
(publishPackage "root" "check" "Hermetic source and manifest-admission check program"
"Executable under bin/ with its native runtime dependencies."
devApps.check
)
(publishPackage "root" "test" "Fixture-backed Cargo test program"
"Executable under bin/ with its native runtime dependencies."
devApps.test
)
(publishPackage "root" "ci" "Whole-repository local CI program"
"Executable under bin/ with its native runtime dependencies."
devApps.ci
)
(publishPackage "root" "minimal-manifest" "Minimal service example manifest"
"manifest.json and disposable views/docs.md, with realised closure dependencies."
minimalManifest
)
(publishPackage "root" "postgres-manifest" "PostgreSQL example manifest"
"manifest.json and disposable views/docs.md, with realised closure dependencies."
postgresManifest
)
(publishPackage "root" "composite-manifest" "Composite task example manifest"
"manifest.json and disposable views/docs.md, with realised closure dependencies."
compositeManifest
)
(publishPackage "root" "downstream-manifest" "Downstream workflow example manifest"
"manifest.json and disposable views/docs.md, with realised closure dependencies."
downstreamManifest
)
(publishPackage "root" "reth-manifest" "Reth multi-endpoint example manifest"
"manifest.json and disposable views/docs.md, with realised closure dependencies."
rethManifest
)
(publishPackage "root" "docs" "Revision-bound authoring and API reference"
"bin/nixfied-docs and share/nixfied/reference/API.md."
(docsFor {
inherit pkgs system;
})
)
];
appDeclarations =
{ pkgs, system }:
let
app =
name: description: effects: reference: binding:
{
kind = "app";
scope = "root";
inherit
name
description
effects
binding
;
usage = "nix run .#${name} -- --help";
}
// reference;
program = name: {
type = "app";
program = "${self.packages.${system}.${name}}/bin/nixfied-${name}";
};
in
[
(app "help" "List Nixfied-generated commands"
"Prints the generated app catalog without caller-flake inspection."
{ topic = "discovery"; }
(
import ./nix/help-app.nix {
inherit pkgs;
apps = builtins.listToAttrs (
map
(entry: {
name = entry.name;
value.meta.description = entry.description;
})
(appDeclarations {
inherit pkgs system;
})
);
}
)
)
(app "docs" "Read the authoring and API reference from this Nixfied source"
"Reads packaged reference content without manifest admission, runtime state or network access."
{ topic = "discovery"; }
(program "docs")
)
(app "install" "Install Nixfied scaffold files into a downstream project"
"Creates scaffold files with native ownership and overwrite checks."
{ command = "install"; }
(program "install")
)
(app "upgrade" "Repin the Nixfied flake input without touching project-owned declarations"
"Plan inspects locked sources without manifest evaluation; checked apply evaluates the candidate manifest; force skips evaluation while retaining guarded pin/lock writes."
{ command = "upgrade"; }
(program "upgrade")
)
(app "gate" "Run the framework gate (examples + slots/negative/adoption) against the working tree"
"Builds and executes runtime and downstream adoption integration fixtures."
{ topic = "development"; }
(program "gate")
)
(app "check" "Hermetic source gate (rustfmt/clippy/check) + manifest admission"
"Runs flake checks and admits a realised example manifest."
{ topic = "development"; }
(program "check")
)
(app "test" "Run the white-box cargo test floor with the pinned toolchain"
"Executes fixture-backed Cargo tests, including native processes and sockets."
{ topic = "development"; }
(program "test")
)
(app "ci" "Fail-fast whole-repo gate: check then test then the gate"
"Runs the complete local check, test and integration sequence."
{ topic = "development"; }
(program "ci")
)
(app "regenerate" "Regenerate Nixfied's checked-in Rust declarations"
"Builds declarations with the pinned formatter and writes generated Rust in the Nixfied checkout."
{
topic = "development";
usage = "nix run .#regenerate";
}
{
type = "app";
program = "${import ./nix/meta/regenerate.nix { inherit pkgs; }}/bin/nixfied-regenerate";
}
)
];
checkDeclarations =
{ pkgs, system }:
let
optionsDoc = import ./nix/docs/options.nix {
inherit pkgs system;
inherit (nixpkgs) lib;
};
in
[
(publishPackage "check" "minimal-manifest" "Build the minimal example manifest" "Realised manifest package."
self.packages.${system}.minimal-manifest
)
(publishPackage "check" "derive-facts-vectors" "Check independent Nix derivation golden vectors"
"Successful evaluation of the derivation-spec vectors."
(
import ./nix/checks/derive-facts-vectors.nix {
inherit pkgs;
inherit (nixpkgs) lib;
}
)
)
(publishPackage "check" "nixfied-runtime" "Compile the debug runtime reproducibly"
"Debug runtime executable."
(mkNixfiedPackage {
inherit pkgs;
package = "nixfied-runtime";
buildType = "debug";
})
)
(publishPackage "check" "rust-workspace"
"Check native metadata, reference freshness, rustfmt and Clippy"
"Successful hermetic source and type checks."
(
assert import ./nix/checks/option-metadata.nix {
inherit pkgs system;
inherit (nixpkgs) lib;
};
assert import ./nix/checks/publications.nix {
inherit (nixpkgs) lib;
};
assert import ./nix/checks/structure.nix { inherit (nixpkgs) lib; };
assert import ./nix/checks/syntax.nix { inherit (nixpkgs) lib; };
assert import ./nix/checks/invocation-templates.nix { inherit pkgs system; inherit (nixpkgs) lib; };
assert import ./nix/checks/endpoint-readiness.nix { inherit pkgs system; inherit (nixpkgs) lib; };
assert import ./nix/checks/coverage.nix { inherit (nixpkgs) lib; };
assert publications.${system}.audit "function" "library" self.lib.${system};
assert publications.${system}.audit "package" "root" self.packages.${system};
assert publications.${system}.audit "app" "root" self.apps.${system};
assert publications.${system}.audit "package" "check" self.checks.${system};
assert publications.${system}.audit "package" "devShell" self.devShells.${system};
import ./nix/packages/rust-workspace-check.nix {
inherit pkgs optionsDoc;
referenceCheck = import ./nix/checks/reference.nix {
inherit pkgs system;
inherit (nixpkgs) lib;
docs = docsFor { inherit pkgs system; };
};
}
)
)
];
shellDeclarations =
{ pkgs, ... }:
let
nixfiedTestChild = mkNixfiedTestChild pkgs;
in
[
# The pinned toolchain (cargo/rustc/clippy/rustfmt) so the cargo floor
# runs identically on every host and in CI, independent of host Rust.
(publishPackage "devShell" "default" "Pinned Rust and Nix development environment"
"Development shell with the private test-child fixture."
(
pkgs.mkShell ({
packages = [
(import ./nix/toolchain.nix { inherit pkgs; }).dev
pkgs.sqlite
pkgs.nix
pkgs.git
] ++ pkgs.lib.optional pkgs.stdenv.hostPlatform.isDarwin pkgs.rust-bindgen-unwrapped;
NIXFIED_TEST_CHILD = "${nixfiedTestChild}/bin/nixfied-test-child";
NIXFIED_TEST_SLEEP = "${pkgs.coreutils}/bin/sleep";
NIXFIED_TEST_FIXTURES = toString (import ./nix/checks/runtime-fixtures.nix {
inherit pkgs;
testChild = nixfiedTestChild;
});
} // pkgs.lib.optionalAttrs pkgs.stdenv.hostPlatform.isDarwin {
SDKROOT = "${pkgs.apple-sdk.sdkroot}";
})
)
)
];
in
{
lib = forAllSystems mkNixfiedLib;
packages = forAllSystems ({ system, ... }: publications.${system}.project "package" "root");
apps = forAllSystems ({ system, ... }: publications.${system}.project "app" "root");
checks = forAllSystems ({ system, ... }: publications.${system}.project "package" "check");
devShells = forAllSystems ({ system, ... }: publications.${system}.project "package" "devShell");
};
}