gunk-dev/the-valley

flake.nix

source111eb193e549main's published tip history
5.0 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-linux, because nothing else is tested there.
18 sigverifySystems = [ "aarch64-linux" ];
19 # The valley CLI is also offered for aarch64-darwin, so it can be
20 # installed on a Mac. It is evaluated here but not built or tested
21 # here, because no Darwin machine runs this flake's checks. The
22 # valley-darwin-eval check evaluates it from x86_64-linux without
23 # building anything for Darwin. Nothing else is offered on Darwin.
24 cliSystems = [ "aarch64-darwin" ];
25
26 pkgsFor = system: nixpkgs.legacyPackages.${system};
27
28 # What this flake builds (nix/packages.nix) and what it tests
29 # (nix/checks.nix). A flake says which outputs exist and what they are
30 # built from; what a package is and what a check does live in files.
31 packagesFor =
32 system:
33 import ./nix/packages.nix {
34 inherit lib;
35 pkgs = pkgsFor system;
36 };
37 in
38 {
39 nixosModules.valley-host = ./nix/valley-host.nix;
40 nixosModules.default = self.nixosModules.valley-host;
41
42 # The knowledge lint, for any project that keeps a `.the-valley/` graph.
43 # This is the check's primary form: a consuming project takes this flake
44 # as an input and instantiates the derivation over its own source, so the
45 # check a policy names is supplied by the instance rather than written
46 # again by every project the policy covers (dcr-f41f718). A whole
47 # consuming flake is:
48 #
49 # {
50 # inputs.the-valley.url = "github:gunk-dev/the-valley";
51 # outputs =
52 # { self, the-valley }:
53 # {
54 # checks.x86_64-linux.knowledge-lint = the-valley.lib.knowledgeLint {
55 # system = "x86_64-linux";
56 # src = self;
57 # };
58 # };
59 # }
60 #
61 # There is no nixpkgs input in that flake on purpose: cue and python come
62 # from this flake's pinned nixpkgs, so every project in a group runs the
63 # same lint against the same toolchain. `root` names the graph directory
64 # for a project that keeps its graph somewhere other than `.the-valley/`.
65 lib.knowledgeLint =
66 {
67 system,
68 src,
69 root ? ".the-valley",
70 }:
71 import ./nix/knowledge-lint.nix {
72 inherit src root;
73 pkgs = pkgsFor system;
74 };
75
76 apps =
77 lib.genAttrs systems (
78 system:
79 let
80 packages = packagesFor system;
81 in
82 {
83 fmt = {
84 type = "app";
85 program = lib.getExe packages.prose-fmt;
86 };
87 attest = {
88 type = "app";
89 program = lib.getExe packages.attest;
90 };
91 integrator = {
92 type = "app";
93 program = lib.getExe packages.integrator;
94 };
95 identity = {
96 type = "app";
97 program = lib.getExe packages.identity;
98 };
99 sigverify = {
100 type = "app";
101 program = lib.getExe packages.sigverify;
102 };
103 }
104 )
105 // lib.genAttrs sigverifySystems (system: {
106 sigverify = {
107 type = "app";
108 program = lib.getExe (packagesFor system).sigverify;
109 };
110 });
111
112 packages =
113 lib.genAttrs systems (
114 system:
115 let
116 packages = packagesFor system;
117 in
118 {
119 inherit (packages)
120 valley
121 attest
122 integrator
123 identity
124 valleyhook
125 sigverify
126 ;
127 default = packages.valley;
128 }
129 )
130 // lib.genAttrs sigverifySystems (system: {
131 inherit (packagesFor system) sigverify;
132 })
133 // lib.genAttrs cliSystems (system: {
134 inherit (packagesFor system) valley;
135 });
136
137 checks =
138 lib.genAttrs systems (
139 system:
140 import ./nix/checks.nix {
141 inherit lib self system;
142 pkgs = pkgsFor system;
143 packages = packagesFor system;
144 }
145 )
146 // lib.genAttrs sigverifySystems (
147 system:
148 import ./nix/checks/sigverify.nix {
149 pkgs = pkgsFor system;
150 packages = packagesFor system;
151 }
152 );
153 };
154}