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 = { |
| 10 | nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; |
| 11 | unstable.url = "github:nixos/nixpkgs/nixos-unstable"; |
| 12 | |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 13 | |
| 14 | deploy-rs = { |
| 15 | url = "github:serokell/deploy-rs"; |
| 16 | inputs.nixpkgs.follows = "nixpkgs"; |
| 17 | }; |
Skyler Grey | d337740 | 2024-06-06 22:01:26 +0000 | [diff] [blame] | 18 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame^] | 19 | snowfall-lib = { |
| 20 | url = "github:snowfallorg/lib"; |
| 21 | inputs.nixpkgs.follows = "nixpkgs"; |
| 22 | }; |
| 23 | |
Skyler Grey | 82ea805 | 2024-06-08 22:56:00 +0000 | [diff] [blame] | 24 | sops-nix = { |
| 25 | url = "github:Mic92/sops-nix"; |
| 26 | inputs = { |
| 27 | nixpkgs.follows = "unstable"; |
| 28 | nixpkgs-stable.follows = "nixpkgs"; |
| 29 | }; |
| 30 | }; |
| 31 | |
Skyler Grey | d337740 | 2024-06-06 22:01:26 +0000 | [diff] [blame] | 32 | impermanence.url = "github:nix-community/impermanence"; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 33 | }; |
| 34 | |
| 35 | outputs = |
| 36 | inputs: |
| 37 | let |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame^] | 38 | lib = (inputs.snowfall-lib.mkLib { |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 39 | inherit inputs; |
| 40 | |
| 41 | src = ./.; |
| 42 | |
| 43 | snowfall = { |
| 44 | namespace = "clicks"; |
| 45 | }; |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame^] | 46 | }).snowfall.internal.system-lib; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 47 | in |
| 48 | lib.mkFlake { |
| 49 | overlays = with inputs; [ ]; |
| 50 | |
Skyler Grey | 82ea805 | 2024-06-08 22:56:00 +0000 | [diff] [blame] | 51 | systems.modules.nixos = [ |
| 52 | inputs.impermanence.nixosModules.impermanence |
| 53 | inputs.sops-nix.nixosModules.sops |
| 54 | ]; |
Skyler Grey | d337740 | 2024-06-06 22:01:26 +0000 | [diff] [blame] | 55 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame^] | 56 | deploy = lib.clicks.deploy.mkDeploy { |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 57 | inherit (inputs) self; |
| 58 | overrides = { |
Skyler Grey | 8ef3481 | 2024-06-09 19:42:15 +0000 | [diff] [blame] | 59 | teal.hostname = "teal.alpha.clicks.domains"; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 60 | }; |
| 61 | }; |
| 62 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame^] | 63 | outputs-builder = channels: { |
| 64 | specs = let |
| 65 | nixFiles = lib.snowfall.fs.get-nix-files-recursive ./.; |
| 66 | specFiles = builtins.filter (lib.clicks.strings.endsWith ".spec.nix") nixFiles; |
| 67 | importedSpecs = lib.forEach specFiles (file: { |
| 68 | name = builtins.unsafeDiscardStringContext (builtins.baseNameOf file); |
| 69 | value = import file { |
| 70 | inherit channels lib; |
| 71 | }; |
| 72 | }); |
| 73 | in builtins.listToAttrs importedSpecs; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 74 | |
Skyler Grey | e6a8c71 | 2024-06-22 01:41:28 +0000 | [diff] [blame^] | 75 | formatter = channels.nixpkgs.nixfmt-rfc-style; |
| 76 | |
| 77 | checks = let |
| 78 | allChecks = { |
| 79 | deploy-rs = lib.deploy-rs.${channels.nixpkgs.system}.deployChecks inputs.self.deploy; |
| 80 | clicks = lib.clicks.checks channels.nixpkgs; |
| 81 | }; |
| 82 | |
| 83 | mergedChecks = lib.trivial.pipe allChecks [ |
| 84 | (lib.attrsets.mapAttrsToList (sourceName: (lib.attrsets.mapAttrsToList (checkName: value: { |
| 85 | name = "${sourceName}:${checkName}"; |
| 86 | inherit value; |
| 87 | })))) |
| 88 | lib.lists.flatten |
| 89 | builtins.listToAttrs |
| 90 | ]; |
| 91 | in mergedChecks; |
| 92 | }; |
Skyler Grey | f08a619 | 2024-06-01 23:55:20 +0000 | [diff] [blame] | 93 | }; |
| 94 | } |