blob: 5500287dd3480b84db32d4927327c3e4e4c6ee02 [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 Greyc4ab9c62024-08-08 21:01:44 +000071 inputs.agenix.nixosModules.default
72 inputs.agenix-rekey.nixosModules.default
73 inputs.impermanence.nixosModules.impermanence
Skyler Grey4bf2de52024-07-29 17:55:05 +000074 {
75 config.clicks.defaults.enable = true;
76 # set defaults that are clicks-specific, such as our backups module
77 # being enabled...
78 }
Skyler Greyc4ab9c62024-08-08 21:01:44 +000079 ];
Skyler Greyd3377402024-06-06 22:01:26 +000080
Skyler Greye6a8c712024-06-22 01:41:28 +000081 deploy = lib.clicks.deploy.mkDeploy {
Skyler Greyf08a6192024-06-01 23:55:20 +000082 inherit (inputs) self;
83 overrides = {
Skyler Grey8ef34812024-06-09 19:42:15 +000084 teal.hostname = "teal.alpha.clicks.domains";
Skyler Greyf08a6192024-06-01 23:55:20 +000085 };
86 };
87
Skyler Grey67cf8aa2024-07-28 13:21:32 +000088 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 Greye6a8c712024-06-22 01:41:28 +000096 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 {
103 inherit channels lib;
104 };
105 });
106 in builtins.listToAttrs importedSpecs;
Skyler Greyf08a6192024-06-01 23:55:20 +0000107
Skyler Greye6a8c712024-06-22 01:41:28 +0000108 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;
114 };
115
116 mergedChecks = lib.trivial.pipe allChecks [
117 (lib.attrsets.mapAttrsToList (sourceName: (lib.attrsets.mapAttrsToList (checkName: value: {
118 name = "${sourceName}:${checkName}";
119 inherit value;
120 }))))
121 lib.lists.flatten
122 builtins.listToAttrs
123 ];
124 in mergedChecks;
125 };
Skyler Greyf08a6192024-06-01 23:55:20 +0000126 };
127}