blob: b22ff26e33aacf543c80c634c4638f27203e0f60 [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 Greyf08a6192024-06-01 23:55:20 +000010 deploy-rs = {
11 url = "github:serokell/deploy-rs";
12 inputs.nixpkgs.follows = "nixpkgs";
13 };
Skyler Greyd3377402024-06-06 22:01:26 +000014
Skyler Greyd7e1acd2024-06-22 14:42:11 +000015 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 Greye6a8c712024-06-22 01:41:28 +000026 snowfall-lib = {
27 url = "github:snowfallorg/lib";
28 inputs.nixpkgs.follows = "nixpkgs";
29 };
30
Skyler Grey82ea8052024-06-08 22:56:00 +000031 sops-nix = {
32 url = "github:Mic92/sops-nix";
33 inputs = {
34 nixpkgs.follows = "unstable";
35 nixpkgs-stable.follows = "nixpkgs";
36 };
37 };
38
Skyler Greyd7e1acd2024-06-22 14:42:11 +000039 unstable.url = "github:nixos/nixpkgs/nixos-unstable";
Skyler Greyf08a6192024-06-01 23:55:20 +000040 };
41
42 outputs =
43 inputs:
44 let
Skyler Greye6a8c712024-06-22 01:41:28 +000045 lib = (inputs.snowfall-lib.mkLib {
Skyler Greyf08a6192024-06-01 23:55:20 +000046 inherit inputs;
47
48 src = ./.;
49
50 snowfall = {
51 namespace = "clicks";
52 };
Skyler Greye6a8c712024-06-22 01:41:28 +000053 }).snowfall.internal.system-lib;
Skyler Greyf08a6192024-06-01 23:55:20 +000054 in
55 lib.mkFlake {
56 overlays = with inputs; [ ];
57
Skyler Grey82ea8052024-06-08 22:56:00 +000058 systems.modules.nixos = [
59 inputs.impermanence.nixosModules.impermanence
60 inputs.sops-nix.nixosModules.sops
61 ];
Skyler Greyd3377402024-06-06 22:01:26 +000062
Skyler Greye6a8c712024-06-22 01:41:28 +000063 deploy = lib.clicks.deploy.mkDeploy {
Skyler Greyf08a6192024-06-01 23:55:20 +000064 inherit (inputs) self;
65 overrides = {
Skyler Grey8ef34812024-06-09 19:42:15 +000066 teal.hostname = "teal.alpha.clicks.domains";
Skyler Greyf08a6192024-06-01 23:55:20 +000067 };
68 };
69
Skyler Greye6a8c712024-06-22 01:41:28 +000070 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 Greyf08a6192024-06-01 23:55:20 +000081
Skyler Greye6a8c712024-06-22 01:41:28 +000082 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 Greyf08a6192024-06-01 23:55:20 +0000100 };
101}