gunk-dev/the-valley

flake.nix

sourceed5d985387a4main's published tip history
4.5 KiB
1{
2 description = "the-valley: the CUE domain schema for a valley host, and the NixOS module that installs one";
3
4 inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
5
6 outputs =
7 { self, nixpkgs }:
8 let
9 lib = nixpkgs.lib;
10 # Checks use import-from-derivation (the module's cue export), so they
11 # are only defined for the system that can actually build them here.
12 systems = [ "x86_64-linux" ];
13 # sigverify is also built and tested for aarch64-linux, because cosmo's
14 # Raspberry Pis verify their releases with it. Its checks need no
15 # import-from-derivation, so they are defined there too, and an
16 # aarch64 builder (or binfmt emulation) runs them. Nothing else here
17 # is offered on aarch64, because nothing else is tested there.
18 sigverifySystems = [ "aarch64-linux" ];
19
20 pkgsFor = system: nixpkgs.legacyPackages.${system};
21
22 # What this flake builds (nix/packages.nix) and what it tests
23 # (nix/checks.nix). A flake says which outputs exist and what they are
24 # built from; what a package is and what a check does live in files.
25 packagesFor =
26 system:
27 import ./nix/packages.nix {
28 inherit lib;
29 pkgs = pkgsFor system;
30 };
31 in
32 {
33 nixosModules.valley-host = ./nix/valley-host.nix;
34 nixosModules.default = self.nixosModules.valley-host;
35
36 # The knowledge lint, for any project that keeps a `.the-valley/` graph.
37 # This is the check's primary form: a consuming project takes this flake
38 # as an input and instantiates the derivation over its own source, so the
39 # check a policy names is supplied by the instance rather than written
40 # again by every project the policy covers (dcr-f41f718). A whole
41 # consuming flake is:
42 #
43 # {
44 # inputs.the-valley.url = "github:gunk-dev/the-valley";
45 # outputs =
46 # { self, the-valley }:
47 # {
48 # checks.x86_64-linux.knowledge-lint = the-valley.lib.knowledgeLint {
49 # system = "x86_64-linux";
50 # src = self;
51 # };
52 # };
53 # }
54 #
55 # There is no nixpkgs input in that flake on purpose: cue and python come
56 # from this flake's pinned nixpkgs, so every project in a group runs the
57 # same lint against the same toolchain. `root` names the graph directory
58 # for a project that keeps its graph somewhere other than `.the-valley/`.
59 lib.knowledgeLint =
60 {
61 system,
62 src,
63 root ? ".the-valley",
64 }:
65 import ./nix/knowledge-lint.nix {
66 inherit src root;
67 pkgs = pkgsFor system;
68 };
69
70 apps =
71 lib.genAttrs systems (
72 system:
73 let
74 packages = packagesFor system;
75 in
76 {
77 fmt = {
78 type = "app";
79 program = lib.getExe packages.prose-fmt;
80 };
81 attest = {
82 type = "app";
83 program = lib.getExe packages.attest;
84 };
85 integrator = {
86 type = "app";
87 program = lib.getExe packages.integrator;
88 };
89 identity = {
90 type = "app";
91 program = lib.getExe packages.identity;
92 };
93 sigverify = {
94 type = "app";
95 program = lib.getExe packages.sigverify;
96 };
97 }
98 )
99 // lib.genAttrs sigverifySystems (system: {
100 sigverify = {
101 type = "app";
102 program = lib.getExe (packagesFor system).sigverify;
103 };
104 });
105
106 packages =
107 lib.genAttrs systems (
108 system:
109 let
110 packages = packagesFor system;
111 in
112 {
113 inherit (packages)
114 valley
115 attest
116 integrator
117 identity
118 valleyhook
119 sigverify
120 ;
121 default = packages.valley;
122 }
123 )
124 // lib.genAttrs sigverifySystems (system: {
125 inherit (packagesFor system) sigverify;
126 });
127
128 checks =
129 lib.genAttrs systems (
130 system:
131 import ./nix/checks.nix {
132 inherit lib self system;
133 pkgs = pkgsFor system;
134 packages = packagesFor system;
135 }
136 )
137 // lib.genAttrs sigverifySystems (
138 system:
139 import ./nix/checks/sigverify.nix {
140 pkgs = pkgsFor system;
141 packages = packagesFor system;
142 }
143 );
144 };
145}