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