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 | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 64 | in |
| 65 | lib.mkFlake { |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 66 | overlays = [ |
| 67 | inputs.agenix-rekey.overlays.default |
| 68 | ]; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 69 | |
Skyler Grey | 82ea805 | 2024-06-08 22:56:00 +0000 | [diff] [blame] | 70 | systems.modules.nixos = [ |
Skyler Grey | c4ab9c6 | 2024-08-08 21:01:44 +0000 | [diff] [blame] | 71 | inputs.agenix.nixosModules.default |
| 72 | inputs.agenix-rekey.nixosModules.default |
| 73 | inputs.impermanence.nixosModules.impermanence |
Skyler Grey | 4bf2de5 | 2024-07-29 17:55:05 +0000 | [diff] [blame] | 74 | { |
| 75 | config.clicks.defaults.enable = true; |
| 76 | # set defaults that are clicks-specific, such as our backups module |
| 77 | # being enabled... |
| 78 | } |
Skyler Grey | c4ab9c6 | 2024-08-08 21:01:44 +0000 | [diff] [blame] | 79 | ]; |
Skyler Grey | d337740 | 2024-06-06 22:01:26 +0000 | [diff] [blame] | 80 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 81 | deploy = lib.clicks.deploy.mkDeploy { |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 82 | inherit (inputs) self; |
| 83 | overrides = { |
Skyler Grey | 8ef3481 | 2024-06-09 19:42:15 +0000 | [diff] [blame] | 84 | teal.hostname = "teal.alpha.clicks.domains"; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 85 | }; |
| 86 | }; |
| 87 | |
Skyler Grey | 67cf8aa | 2024-07-28 13:21:32 +0000 | [diff] [blame] | 88 | agenix-rekey = inputs.agenix-rekey.configure { |
| 89 | userFlake = inputs.self // { outPath = lib.pipe "" [ |
| 90 | lib.snowfall.fs.get-snowfall-file |
| 91 | (lib.strings.removeSuffix "/") |
| 92 | ]; }; |
| 93 | nodes = inputs.self.nixosConfigurations; |
| 94 | }; |
| 95 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 96 | outputs-builder = channels: { |
| 97 | specs = let |
| 98 | nixFiles = lib.snowfall.fs.get-nix-files-recursive ./.; |
| 99 | specFiles = builtins.filter (lib.clicks.strings.endsWith ".spec.nix") nixFiles; |
| 100 | importedSpecs = lib.forEach specFiles (file: { |
| 101 | name = builtins.unsafeDiscardStringContext (builtins.baseNameOf file); |
| 102 | value = import file { |
Skyler Grey | 4d6b6a4 | 2024-08-05 18:08:19 +0000 | [diff] [blame] | 103 | inherit channels lib inputs; |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 104 | }; |
| 105 | }); |
| 106 | in builtins.listToAttrs importedSpecs; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 107 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 108 | formatter = channels.nixpkgs.nixfmt-rfc-style; |
| 109 | |
| 110 | checks = let |
| 111 | allChecks = { |
| 112 | deploy-rs = lib.deploy-rs.${channels.nixpkgs.system}.deployChecks inputs.self.deploy; |
| 113 | clicks = lib.clicks.checks channels.nixpkgs; |
Skyler Grey | 1306895 | 2024-08-20 22:56:49 +0000 | [diff] [blame^] | 114 | adhoc = let |
| 115 | nixFiles = lib.snowfall.fs.get-nix-files-recursive ./.; |
| 116 | checkFiles = builtins.filter (lib.clicks.strings.endsWith ".check.nix") nixFiles; |
| 117 | importedChecks = lib.forEach checkFiles (file: { |
| 118 | name = builtins.unsafeDiscardStringContext (builtins.baseNameOf file); |
| 119 | value = import file { |
| 120 | inherit channels lib inputs; |
| 121 | }; |
| 122 | }); |
| 123 | in builtins.listToAttrs importedChecks; |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame] | 124 | }; |
| 125 | |
| 126 | mergedChecks = lib.trivial.pipe allChecks [ |
| 127 | (lib.attrsets.mapAttrsToList (sourceName: (lib.attrsets.mapAttrsToList (checkName: value: { |
| 128 | name = "${sourceName}:${checkName}"; |
| 129 | inherit value; |
| 130 | })))) |
| 131 | lib.lists.flatten |
| 132 | builtins.listToAttrs |
| 133 | ]; |
| 134 | in mergedChecks; |
| 135 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 136 | }; |
| 137 | } |