| 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 | # Packages are plain builds with no import-from-derivation, which lets |
| 14 | # them be offered for every Linux system a consumer runs. A Raspberry |
| 15 | # Pi, for one, takes sigverify from here. |
| 16 | packageSystems = systems ++ [ "aarch64-linux" ]; |
| 17 | |
| 18 | pkgsFor = system: nixpkgs.legacyPackages.${system}; |
| 19 | |
| 20 | # What this flake builds (nix/packages.nix) and what it tests |
| 21 | # (nix/checks.nix). A flake says which outputs exist and what they are |
| 22 | # built from; what a package is and what a check does live in files. |
| 23 | packagesFor = |
| 24 | system: |
| 25 | import ./nix/packages.nix { |
| 26 | inherit lib; |
| 27 | pkgs = pkgsFor system; |
| 28 | }; |
| 29 | in |
| 30 | { |
| 31 | nixosModules.valley-host = ./nix/valley-host.nix; |
| 32 | nixosModules.default = self.nixosModules.valley-host; |
| 33 | |
| 34 | # The knowledge lint, for any project that keeps a `.the-valley/` graph. |
| 35 | # This is the check's primary form: a consuming project takes this flake |
| 36 | # as an input and instantiates the derivation over its own source, so the |
| 37 | # check a policy names is supplied by the instance rather than written |
| 38 | # again by every project the policy covers (dcr-f41f718). A whole |
| 39 | # consuming flake is: |
| 40 | # |
| 41 | # { |
| 42 | # inputs.the-valley.url = "github:gunk-dev/the-valley"; |
| 43 | # outputs = |
| 44 | # { self, the-valley }: |
| 45 | # { |
| 46 | # checks.x86_64-linux.knowledge-lint = the-valley.lib.knowledgeLint { |
| 47 | # system = "x86_64-linux"; |
| 48 | # src = self; |
| 49 | # }; |
| 50 | # }; |
| 51 | # } |
| 52 | # |
| 53 | # There is no nixpkgs input in that flake on purpose: cue and python come |
| 54 | # from this flake's pinned nixpkgs, so every project in a group runs the |
| 55 | # same lint against the same toolchain. `root` names the graph directory |
| 56 | # for a project that keeps its graph somewhere other than `.the-valley/`. |
| 57 | lib.knowledgeLint = |
| 58 | { |
| 59 | system, |
| 60 | src, |
| 61 | root ? ".the-valley", |
| 62 | }: |
| 63 | import ./nix/knowledge-lint.nix { |
| 64 | inherit src root; |
| 65 | pkgs = pkgsFor system; |
| 66 | }; |
| 67 | |
| 68 | apps = lib.genAttrs packageSystems ( |
| 69 | system: |
| 70 | let |
| 71 | packages = packagesFor system; |
| 72 | in |
| 73 | { |
| 74 | fmt = { |
| 75 | type = "app"; |
| 76 | program = lib.getExe packages.prose-fmt; |
| 77 | }; |
| 78 | attest = { |
| 79 | type = "app"; |
| 80 | program = lib.getExe packages.attest; |
| 81 | }; |
| 82 | integrator = { |
| 83 | type = "app"; |
| 84 | program = lib.getExe packages.integrator; |
| 85 | }; |
| 86 | identity = { |
| 87 | type = "app"; |
| 88 | program = lib.getExe packages.identity; |
| 89 | }; |
| 90 | sigverify = { |
| 91 | type = "app"; |
| 92 | program = lib.getExe packages.sigverify; |
| 93 | }; |
| 94 | } |
| 95 | ); |
| 96 | |
| 97 | packages = lib.genAttrs packageSystems ( |
| 98 | system: |
| 99 | let |
| 100 | packages = packagesFor system; |
| 101 | in |
| 102 | { |
| 103 | inherit (packages) |
| 104 | valley |
| 105 | attest |
| 106 | integrator |
| 107 | identity |
| 108 | sigverify |
| 109 | ; |
| 110 | default = packages.valley; |
| 111 | } |
| 112 | ); |
| 113 | |
| 114 | checks = lib.genAttrs systems ( |
| 115 | system: |
| 116 | import ./nix/checks.nix { |
| 117 | inherit lib self system; |
| 118 | pkgs = pkgsFor system; |
| 119 | packages = packagesFor system; |
| 120 | } |
| 121 | ); |
| 122 | }; |
| 123 | } |