blob: 26d1cc9fe3c1cde8fd1c5ccda72d7949ab464a63 [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
Samuel Shuertc6f63032024-12-31 11:09:23 -050022 flake-utils.url = "github:numtide/flake-utils";
23
24 headscale = {
25 url = "github:juanfont/headscale?ref=refs/tags/v0.24.0-beta.2";
26 inputs.nixpkgs.follows = "unstable";
27 inputs.flake-utils.follows = "flake-utils";
28 };
29
Skyler Greyd7e1acd2024-06-22 14:42:11 +000030 home-manager = {
31 url = "github:nix-community/home-manager";
32 inputs.nixpkgs.follows = "nixpkgs";
33 };
34
Skyler Greyd7e1acd2024-06-22 14:42:11 +000035 impermanence.url = "github:nix-community/impermanence";
36
Samuel Shuertc6f63032024-12-31 11:09:23 -050037 lix-module = {
38 url = "git+https://git.lix.systems/lix-project/nixos-module?ref=refs/tags/2.91.1-2";
39 inputs.nixpkgs.follows = "nixpkgs";
40 };
41
42 nixpkgs.url = "github:nixos/nixpkgs/nixos-24.11";
Skyler Greyd7e1acd2024-06-22 14:42:11 +000043
Skyler Greye6a8c712024-06-22 01:41:28 +000044 snowfall-lib = {
45 url = "github:snowfallorg/lib";
46 inputs.nixpkgs.follows = "nixpkgs";
47 };
48
Skyler Greyd7e1acd2024-06-22 14:42:11 +000049 unstable.url = "github:nixos/nixpkgs/nixos-unstable";
Skyler Grey3299e4f2024-07-04 00:33:43 +000050
Samuel Shuertc6f63032024-12-31 11:09:23 -050051 whisk.url = "github:freshlybakedcake/whisk";
52
53
Skyler Grey3299e4f2024-07-04 00:33:43 +000054 aux--docs-site = {
55 url = "git+https://git.auxolotl.org/auxolotl/docs-site";
56 inputs.nixpkgs.follows = "nixpkgs";
57 inputs.snowfall-lib.follows = "snowfall-lib";
58 inputs.wiki.follows = "aux--wiki";
59 };
Samuel Shuertc6f63032024-12-31 11:09:23 -050060
Skyler Grey3299e4f2024-07-04 00:33:43 +000061 aux--wiki = {
62 url = "git+https://git.auxolotl.org/auxolotl/wiki";
63 flake = false;
64 };
Skyler Greyf08a6192024-06-01 23:55:20 +000065 };
66
67 outputs =
68 inputs:
69 let
Skyler Greye6a8c712024-06-22 01:41:28 +000070 lib = (inputs.snowfall-lib.mkLib {
Skyler Greyf08a6192024-06-01 23:55:20 +000071 inherit inputs;
72
73 src = ./.;
74
75 snowfall = {
76 namespace = "clicks";
77 };
Skyler Greye6a8c712024-06-22 01:41:28 +000078 }).snowfall.internal.system-lib;
Skyler Greyf08a6192024-06-01 23:55:20 +000079 in
80 lib.mkFlake {
Skyler Grey67cf8aa2024-07-28 13:21:32 +000081 overlays = [
Samuel Shuertc6f63032024-12-31 11:09:23 -050082 inputs.agenix-rekey.overlays.default
Skyler Grey67cf8aa2024-07-28 13:21:32 +000083 ];
Skyler Greyf08a6192024-06-01 23:55:20 +000084
Skyler Grey82ea8052024-06-08 22:56:00 +000085 systems.modules.nixos = [
Skyler Greyc4ab9c62024-08-08 21:01:44 +000086 inputs.agenix.nixosModules.default
87 inputs.agenix-rekey.nixosModules.default
88 inputs.impermanence.nixosModules.impermanence
Skyler Grey4bf2de52024-07-29 17:55:05 +000089 {
90 config.clicks.defaults.enable = true;
91 # set defaults that are clicks-specific, such as our backups module
92 # being enabled...
93 }
Samuel Shuertc6f63032024-12-31 11:09:23 -050094 inputs.lix-module.nixosModules.default
Skyler Greyc4ab9c62024-08-08 21:01:44 +000095 ];
Skyler Greyd3377402024-06-06 22:01:26 +000096
Skyler Greye6a8c712024-06-22 01:41:28 +000097 deploy = lib.clicks.deploy.mkDeploy {
Skyler Greyf08a6192024-06-01 23:55:20 +000098 inherit (inputs) self;
99 overrides = {
Skyler Grey8ef34812024-06-09 19:42:15 +0000100 teal.hostname = "teal.alpha.clicks.domains";
Skyler Greyf08a6192024-06-01 23:55:20 +0000101 };
102 };
103
Skyler Grey67cf8aa2024-07-28 13:21:32 +0000104 agenix-rekey = inputs.agenix-rekey.configure {
105 userFlake = inputs.self // { outPath = lib.pipe "" [
106 lib.snowfall.fs.get-snowfall-file
107 (lib.strings.removeSuffix "/")
108 ]; };
109 nodes = inputs.self.nixosConfigurations;
110 };
111
Skyler Greye6a8c712024-06-22 01:41:28 +0000112 outputs-builder = channels: {
113 specs = let
114 nixFiles = lib.snowfall.fs.get-nix-files-recursive ./.;
115 specFiles = builtins.filter (lib.clicks.strings.endsWith ".spec.nix") nixFiles;
116 importedSpecs = lib.forEach specFiles (file: {
117 name = builtins.unsafeDiscardStringContext (builtins.baseNameOf file);
118 value = import file {
Skyler Grey4d6b6a42024-08-05 18:08:19 +0000119 inherit channels lib inputs;
Skyler Greye6a8c712024-06-22 01:41:28 +0000120 };
121 });
122 in builtins.listToAttrs importedSpecs;
Skyler Greyf08a6192024-06-01 23:55:20 +0000123
Skyler Greye6a8c712024-06-22 01:41:28 +0000124 formatter = channels.nixpkgs.nixfmt-rfc-style;
125
126 checks = let
127 allChecks = {
128 deploy-rs = lib.deploy-rs.${channels.nixpkgs.system}.deployChecks inputs.self.deploy;
129 clicks = lib.clicks.checks channels.nixpkgs;
Skyler Grey13068952024-08-20 22:56:49 +0000130 adhoc = let
131 nixFiles = lib.snowfall.fs.get-nix-files-recursive ./.;
132 checkFiles = builtins.filter (lib.clicks.strings.endsWith ".check.nix") nixFiles;
133 importedChecks = lib.forEach checkFiles (file: {
134 name = builtins.unsafeDiscardStringContext (builtins.baseNameOf file);
135 value = import file {
136 inherit channels lib inputs;
137 };
138 });
139 in builtins.listToAttrs importedChecks;
Skyler Greye6a8c712024-06-22 01:41:28 +0000140 };
141
142 mergedChecks = lib.trivial.pipe allChecks [
143 (lib.attrsets.mapAttrsToList (sourceName: (lib.attrsets.mapAttrsToList (checkName: value: {
144 name = "${sourceName}:${checkName}";
145 inherit value;
146 }))))
147 lib.lists.flatten
148 builtins.listToAttrs
149 ];
150 in mergedChecks;
151 };
Skyler Greyf08a6192024-06-01 23:55:20 +0000152 };
153}