Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 1 | # SPDX-FileCopyrightText: 2024 Auxolotl Infrastructure Contributors |
| 2 | # SPDX-FileCopyrightText: 2024 Clicks Codes |
| 3 | # |
| 4 | # SPDX-License-Identifier: GPL-3.0-only |
| 5 | |
| 6 | { |
Skyler Grey | 02c195e | 2024-06-22 01:35:26 +0000 | [diff] [blame] | 7 | description = "Clicks Infrastructure"; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 8 | |
| 9 | inputs = { |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 10 | agenix.url = "github:ryantm/agenix"; |
| 11 | |
| 12 | agenix-rekey = { |
| 13 | url = "github:oddlama/agenix-rekey"; |
| 14 | inputs.nixpkgs.follows = "nixpkgs"; |
| 15 | }; |
| 16 | |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 17 | deploy-rs = { |
| 18 | url = "github:serokell/deploy-rs"; |
| 19 | inputs.nixpkgs.follows = "nixpkgs"; |
| 20 | }; |
Skyler Grey | d337740 | 2024-06-06 22:01:26 +0000 | [diff] [blame] | 21 | |
Skyler Grey | d7e1acd | 2024-06-22 14:42:11 +0000 | [diff] [blame] | 22 | home-manager = { |
| 23 | url = "github:nix-community/home-manager"; |
| 24 | inputs.nixpkgs.follows = "nixpkgs"; |
| 25 | }; |
| 26 | |
| 27 | flake-utils.url = "github:numtide/flake-utils"; |
| 28 | |
| 29 | impermanence.url = "github:nix-community/impermanence"; |
| 30 | |
| 31 | nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; |
| 32 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 33 | snowfall-lib = { |
| 34 | url = "github:snowfallorg/lib"; |
| 35 | inputs.nixpkgs.follows = "nixpkgs"; |
| 36 | }; |
| 37 | |
Skyler Grey | d7e1acd | 2024-06-22 14:42:11 +0000 | [diff] [blame] | 38 | unstable.url = "github:nixos/nixpkgs/nixos-unstable"; |
Skyler Grey | 3299e4f | 2024-07-04 00:33:43 +0000 | [diff] [blame] | 39 | |
| 40 | aux--docs-site = { |
| 41 | url = "git+https://git.auxolotl.org/auxolotl/docs-site"; |
| 42 | inputs.nixpkgs.follows = "nixpkgs"; |
| 43 | inputs.snowfall-lib.follows = "snowfall-lib"; |
| 44 | inputs.wiki.follows = "aux--wiki"; |
| 45 | }; |
| 46 | aux--wiki = { |
| 47 | url = "git+https://git.auxolotl.org/auxolotl/wiki"; |
| 48 | flake = false; |
| 49 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 50 | }; |
| 51 | |
| 52 | outputs = |
| 53 | inputs: |
| 54 | let |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 55 | lib = (inputs.snowfall-lib.mkLib { |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 56 | inherit inputs; |
| 57 | |
| 58 | src = ./.; |
| 59 | |
| 60 | snowfall = { |
| 61 | namespace = "clicks"; |
| 62 | }; |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 63 | }).snowfall.internal.system-lib; |
Skyler Grey | 38d4a3e | 2024-08-02 19:47:04 +0000 | [diff] [blame^] | 64 | |
| 65 | nixosModuleDependencies = { |
| 66 | agenix = inputs.agenix.nixosModules.default; |
| 67 | agenix-rekey = inputs.agenix-rekey.nixosModules.default; |
| 68 | impermanence = inputs.impermanence.nixosModules.impermanence; |
| 69 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 70 | in |
| 71 | lib.mkFlake { |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 72 | overlays = [ |
| 73 | inputs.agenix-rekey.overlays.default |
| 74 | ]; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 75 | |
Skyler Grey | 82ea805 | 2024-06-08 22:56:00 +0000 | [diff] [blame] | 76 | systems.modules.nixos = [ |
Skyler Grey | 4bf2de5 | 2024-07-29 17:55:05 +0000 | [diff] [blame] | 77 | { |
| 78 | config.clicks.defaults.enable = true; |
| 79 | # set defaults that are clicks-specific, such as our backups module |
| 80 | # being enabled... |
| 81 | } |
Skyler Grey | 38d4a3e | 2024-08-02 19:47:04 +0000 | [diff] [blame^] | 82 | ] ++ (lib.attrsets.attrValues nixosModuleDependencies); |
Skyler Grey | d337740 | 2024-06-06 22:01:26 +0000 | [diff] [blame] | 83 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 84 | deploy = lib.clicks.deploy.mkDeploy { |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 85 | inherit (inputs) self; |
| 86 | overrides = { |
Skyler Grey | 8ef3481 | 2024-06-09 19:42:15 +0000 | [diff] [blame] | 87 | teal.hostname = "teal.alpha.clicks.domains"; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 88 | }; |
| 89 | }; |
| 90 | |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 91 | agenix-rekey = inputs.agenix-rekey.configure { |
| 92 | userFlake = inputs.self // { outPath = lib.pipe "" [ |
| 93 | lib.snowfall.fs.get-snowfall-file |
| 94 | (lib.strings.removeSuffix "/") |
| 95 | ]; }; |
| 96 | nodes = inputs.self.nixosConfigurations; |
| 97 | }; |
| 98 | |
Skyler Grey | 38d4a3e | 2024-08-02 19:47:04 +0000 | [diff] [blame^] | 99 | # We need to re-export dependencies, as this is *invalid* unless |
| 100 | # environment.persistence is defined, so importing all our modules will |
| 101 | # otherwise break evaluation |
| 102 | # |
| 103 | # config = lib.mkIf false { |
| 104 | # environment.persistence = { |
| 105 | # ... |
| 106 | # }; |
| 107 | # }; |
| 108 | # |
| 109 | modules.nixos = lib.attrsets.mapAttrs' (name: value: { |
| 110 | name = "dependency/${name}"; |
| 111 | inherit value; |
| 112 | }) nixosModuleDependencies; |
| 113 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 114 | outputs-builder = channels: { |
| 115 | specs = let |
| 116 | nixFiles = lib.snowfall.fs.get-nix-files-recursive ./.; |
| 117 | specFiles = builtins.filter (lib.clicks.strings.endsWith ".spec.nix") nixFiles; |
| 118 | importedSpecs = lib.forEach specFiles (file: { |
| 119 | name = builtins.unsafeDiscardStringContext (builtins.baseNameOf file); |
| 120 | value = import file { |
| 121 | inherit channels lib; |
| 122 | }; |
| 123 | }); |
| 124 | in builtins.listToAttrs importedSpecs; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 125 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 126 | formatter = channels.nixpkgs.nixfmt-rfc-style; |
| 127 | |
| 128 | checks = let |
| 129 | allChecks = { |
| 130 | deploy-rs = lib.deploy-rs.${channels.nixpkgs.system}.deployChecks inputs.self.deploy; |
| 131 | clicks = lib.clicks.checks channels.nixpkgs; |
| 132 | }; |
| 133 | |
| 134 | mergedChecks = lib.trivial.pipe allChecks [ |
| 135 | (lib.attrsets.mapAttrsToList (sourceName: (lib.attrsets.mapAttrsToList (checkName: value: { |
| 136 | name = "${sourceName}:${checkName}"; |
| 137 | inherit value; |
| 138 | })))) |
| 139 | lib.lists.flatten |
| 140 | builtins.listToAttrs |
| 141 | ]; |
| 142 | in mergedChecks; |
| 143 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 144 | }; |
| 145 | } |