blob: 1c7ddb5e97ece96455714044ef0f1fddf426553f [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 = {
Skyler Grey67cf8aa2024-07-28 13:21:32 +000010 agenix.url = "github:ryantm/agenix";
11
12 agenix-rekey = {
13 url = "github:oddlama/agenix-rekey";
14 inputs.nixpkgs.follows = "nixpkgs";
15 };
16
Skyler Greyf08a6192024-06-01 23:55:20 +000017 deploy-rs = {
18 url = "github:serokell/deploy-rs";
19 inputs.nixpkgs.follows = "nixpkgs";
20 };
Skyler Greyd3377402024-06-06 22:01:26 +000021
Skyler Greyd7e1acd2024-06-22 14:42:11 +000022 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 Greye6a8c712024-06-22 01:41:28 +000033 snowfall-lib = {
34 url = "github:snowfallorg/lib";
35 inputs.nixpkgs.follows = "nixpkgs";
36 };
37
Skyler Greyd7e1acd2024-06-22 14:42:11 +000038 unstable.url = "github:nixos/nixpkgs/nixos-unstable";
Skyler Grey3299e4f2024-07-04 00:33:43 +000039
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 Greyf08a6192024-06-01 23:55:20 +000050 };
51
52 outputs =
53 inputs:
54 let
Skyler Greye6a8c712024-06-22 01:41:28 +000055 lib = (inputs.snowfall-lib.mkLib {
Skyler Greyf08a6192024-06-01 23:55:20 +000056 inherit inputs;
57
58 src = ./.;
59
60 snowfall = {
61 namespace = "clicks";
62 };
Skyler Greye6a8c712024-06-22 01:41:28 +000063 }).snowfall.internal.system-lib;
Skyler Greyf08a6192024-06-01 23:55:20 +000064 in
65 lib.mkFlake {
Skyler Grey67cf8aa2024-07-28 13:21:32 +000066 overlays = [
67 inputs.agenix-rekey.overlays.default
68 ];
Skyler Greyf08a6192024-06-01 23:55:20 +000069
Skyler Grey82ea8052024-06-08 22:56:00 +000070 systems.modules.nixos = [
Skyler Grey67cf8aa2024-07-28 13:21:32 +000071 inputs.agenix.nixosModules.default
72 inputs.agenix-rekey.nixosModules.default
Skyler Grey82ea8052024-06-08 22:56:00 +000073 inputs.impermanence.nixosModules.impermanence
Skyler Grey82ea8052024-06-08 22:56:00 +000074 ];
Skyler Greyd3377402024-06-06 22:01:26 +000075
Skyler Greye6a8c712024-06-22 01:41:28 +000076 deploy = lib.clicks.deploy.mkDeploy {
Skyler Greyf08a6192024-06-01 23:55:20 +000077 inherit (inputs) self;
78 overrides = {
Skyler Grey8ef34812024-06-09 19:42:15 +000079 teal.hostname = "teal.alpha.clicks.domains";
Skyler Greyf08a6192024-06-01 23:55:20 +000080 };
81 };
82
Skyler Grey67cf8aa2024-07-28 13:21:32 +000083 agenix-rekey = inputs.agenix-rekey.configure {
84 userFlake = inputs.self // { outPath = lib.pipe "" [
85 lib.snowfall.fs.get-snowfall-file
86 (lib.strings.removeSuffix "/")
87 ]; };
88 nodes = inputs.self.nixosConfigurations;
89 };
90
Skyler Greye6a8c712024-06-22 01:41:28 +000091 outputs-builder = channels: {
92 specs = let
93 nixFiles = lib.snowfall.fs.get-nix-files-recursive ./.;
94 specFiles = builtins.filter (lib.clicks.strings.endsWith ".spec.nix") nixFiles;
95 importedSpecs = lib.forEach specFiles (file: {
96 name = builtins.unsafeDiscardStringContext (builtins.baseNameOf file);
97 value = import file {
98 inherit channels lib;
99 };
100 });
101 in builtins.listToAttrs importedSpecs;
Skyler Greyf08a6192024-06-01 23:55:20 +0000102
Skyler Greye6a8c712024-06-22 01:41:28 +0000103 formatter = channels.nixpkgs.nixfmt-rfc-style;
104
105 checks = let
106 allChecks = {
107 deploy-rs = lib.deploy-rs.${channels.nixpkgs.system}.deployChecks inputs.self.deploy;
108 clicks = lib.clicks.checks channels.nixpkgs;
109 };
110
111 mergedChecks = lib.trivial.pipe allChecks [
112 (lib.attrsets.mapAttrsToList (sourceName: (lib.attrsets.mapAttrsToList (checkName: value: {
113 name = "${sourceName}:${checkName}";
114 inherit value;
115 }))))
116 lib.lists.flatten
117 builtins.listToAttrs
118 ];
119 in mergedChecks;
120 };
Skyler Greyf08a6192024-06-01 23:55:20 +0000121 };
122}