blob: 00c6592e41e0c1b258e87b18468ab43f9673e52f [file] [log] [blame]
Skyler Greyf08a6192024-06-01 23:55:20 +00001# SPDX-FileCopyrightText: 2024 Auxolotl Infrastructure Contributors
2# SPDX-FileCopyrightText: 2024 Clicks Codes
3#
4# SPDX-License-Identifier: GPL-3.0-only
5
6{
Skyler Grey02c195e2024-06-22 01:35:26 +00007 description = "Clicks Infrastructure";
Skyler Greyf08a6192024-06-01 23:55:20 +00008
9 inputs = {
10 nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
11 unstable.url = "github:nixos/nixpkgs/nixos-unstable";
12
Skyler Greyf08a6192024-06-01 23:55:20 +000013
14 deploy-rs = {
15 url = "github:serokell/deploy-rs";
16 inputs.nixpkgs.follows = "nixpkgs";
17 };
Skyler Greyd3377402024-06-06 22:01:26 +000018
Skyler Greye6a8c712024-06-22 01:41:28 +000019 snowfall-lib = {
20 url = "github:snowfallorg/lib";
21 inputs.nixpkgs.follows = "nixpkgs";
22 };
23
Skyler Grey82ea8052024-06-08 22:56:00 +000024 sops-nix = {
25 url = "github:Mic92/sops-nix";
26 inputs = {
27 nixpkgs.follows = "unstable";
28 nixpkgs-stable.follows = "nixpkgs";
29 };
30 };
31
Skyler Greyd3377402024-06-06 22:01:26 +000032 impermanence.url = "github:nix-community/impermanence";
Skyler Greyf08a6192024-06-01 23:55:20 +000033 };
34
35 outputs =
36 inputs:
37 let
Skyler Greye6a8c712024-06-22 01:41:28 +000038 lib = (inputs.snowfall-lib.mkLib {
Skyler Greyf08a6192024-06-01 23:55:20 +000039 inherit inputs;
40
41 src = ./.;
42
43 snowfall = {
44 namespace = "clicks";
45 };
Skyler Greye6a8c712024-06-22 01:41:28 +000046 }).snowfall.internal.system-lib;
Skyler Greyf08a6192024-06-01 23:55:20 +000047 in
48 lib.mkFlake {
49 overlays = with inputs; [ ];
50
Skyler Grey82ea8052024-06-08 22:56:00 +000051 systems.modules.nixos = [
52 inputs.impermanence.nixosModules.impermanence
53 inputs.sops-nix.nixosModules.sops
54 ];
Skyler Greyd3377402024-06-06 22:01:26 +000055
Skyler Greye6a8c712024-06-22 01:41:28 +000056 deploy = lib.clicks.deploy.mkDeploy {
Skyler Greyf08a6192024-06-01 23:55:20 +000057 inherit (inputs) self;
58 overrides = {
Skyler Grey8ef34812024-06-09 19:42:15 +000059 teal.hostname = "teal.alpha.clicks.domains";
Skyler Greyf08a6192024-06-01 23:55:20 +000060 };
61 };
62
Skyler Greye6a8c712024-06-22 01:41:28 +000063 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 Greyf08a6192024-06-01 23:55:20 +000074
Skyler Greye6a8c712024-06-22 01:41:28 +000075 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 Greyf08a6192024-06-01 23:55:20 +000093 };
94}