blob: 336b36049aef8477c92a3e127367fe1e8c0b62fa [file] [log] [blame]
# SPDX-FileCopyrightText: 2024 Auxolotl Infrastructure Contributors
# SPDX-FileCopyrightText: 2024 Clicks Codes
#
# SPDX-License-Identifier: GPL-3.0-only
{
description = "Clicks Infrastructure";
inputs = {
agenix.url = "github:ryantm/agenix";
agenix-rekey = {
url = "github:oddlama/agenix-rekey";
inputs.nixpkgs.follows = "nixpkgs";
};
deploy-rs = {
url = "github:serokell/deploy-rs";
inputs.nixpkgs.follows = "nixpkgs";
};
home-manager = {
url = "github:nix-community/home-manager";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
impermanence.url = "github:nix-community/impermanence";
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
snowfall-lib = {
url = "github:snowfallorg/lib";
inputs.nixpkgs.follows = "nixpkgs";
};
unstable.url = "github:nixos/nixpkgs/nixos-unstable";
aux--docs-site = {
url = "git+https://git.auxolotl.org/auxolotl/docs-site";
inputs.nixpkgs.follows = "nixpkgs";
inputs.snowfall-lib.follows = "snowfall-lib";
inputs.wiki.follows = "aux--wiki";
};
aux--wiki = {
url = "git+https://git.auxolotl.org/auxolotl/wiki";
flake = false;
};
};
outputs =
inputs:
let
lib = (inputs.snowfall-lib.mkLib {
inherit inputs;
src = ./.;
snowfall = {
namespace = "clicks";
};
}).snowfall.internal.system-lib;
in
lib.mkFlake {
overlays = [
inputs.agenix-rekey.overlays.default
];
systems.modules.nixos = [
inputs.agenix.nixosModules.default
inputs.agenix-rekey.nixosModules.default
inputs.impermanence.nixosModules.impermanence
{
config.clicks.defaults.enable = true;
# set defaults that are clicks-specific, such as our backups module
# being enabled...
}
];
deploy = lib.clicks.deploy.mkDeploy {
inherit (inputs) self;
overrides = {
teal.hostname = "teal.alpha.clicks.domains";
};
};
agenix-rekey = inputs.agenix-rekey.configure {
userFlake = inputs.self // { outPath = lib.pipe "" [
lib.snowfall.fs.get-snowfall-file
(lib.strings.removeSuffix "/")
]; };
nodes = inputs.self.nixosConfigurations;
};
outputs-builder = channels: {
specs = let
nixFiles = lib.snowfall.fs.get-nix-files-recursive ./.;
specFiles = builtins.filter (lib.clicks.strings.endsWith ".spec.nix") nixFiles;
importedSpecs = lib.forEach specFiles (file: {
name = builtins.unsafeDiscardStringContext (builtins.baseNameOf file);
value = import file {
inherit channels lib inputs;
};
});
in builtins.listToAttrs importedSpecs;
formatter = channels.nixpkgs.nixfmt-rfc-style;
checks = let
allChecks = {
deploy-rs = lib.deploy-rs.${channels.nixpkgs.system}.deployChecks inputs.self.deploy;
clicks = lib.clicks.checks channels.nixpkgs;
adhoc = let
nixFiles = lib.snowfall.fs.get-nix-files-recursive ./.;
checkFiles = builtins.filter (lib.clicks.strings.endsWith ".check.nix") nixFiles;
importedChecks = lib.forEach checkFiles (file: {
name = builtins.unsafeDiscardStringContext (builtins.baseNameOf file);
value = import file {
inherit channels lib inputs;
};
});
in builtins.listToAttrs importedChecks;
};
mergedChecks = lib.trivial.pipe allChecks [
(lib.attrsets.mapAttrsToList (sourceName: (lib.attrsets.mapAttrsToList (checkName: value: {
name = "${sourceName}:${checkName}";
inherit value;
}))))
lib.lists.flatten
builtins.listToAttrs
];
in mergedChecks;
};
};
}