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