2023-08-28 09:09:05 +00:00
|
|
|
{ self, inputs, lib, ... }: {
|
2023-09-29 09:56:02 +00:00
|
|
|
flake.nixosModules.clanCore = { config, pkgs, options, ... }: {
|
2023-09-02 16:28:31 +00:00
|
|
|
imports = [
|
|
|
|
./secrets
|
2023-09-26 13:55:41 +00:00
|
|
|
./zerotier
|
2023-09-14 14:57:38 +00:00
|
|
|
./networking.nix
|
2023-09-02 16:28:31 +00:00
|
|
|
inputs.sops-nix.nixosModules.sops
|
2023-09-02 17:15:29 +00:00
|
|
|
# just some example options. Can be removed later
|
|
|
|
./bloatware
|
2023-09-14 14:57:19 +00:00
|
|
|
./vm.nix
|
2023-09-22 12:29:25 +00:00
|
|
|
./options.nix
|
2023-09-02 16:28:31 +00:00
|
|
|
];
|
|
|
|
options.clanSchema = lib.mkOption {
|
|
|
|
type = lib.types.attrs;
|
|
|
|
description = "The json schema for the .clan options namespace";
|
|
|
|
default = self.lib.jsonschema.parseOptions options.clan;
|
|
|
|
};
|
2023-08-30 13:24:33 +00:00
|
|
|
options.clanCore = {
|
2023-08-28 09:09:05 +00:00
|
|
|
clanDir = lib.mkOption {
|
2023-09-02 16:28:31 +00:00
|
|
|
type = lib.types.either lib.types.path lib.types.str;
|
2023-08-28 09:09:05 +00:00
|
|
|
description = ''
|
|
|
|
the location of the flake repo, used to calculate the location of facts and secrets
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
machineName = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
the name of the machine
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
clanPkgs = lib.mkOption {
|
|
|
|
default = self.packages.${pkgs.system};
|
2023-09-22 13:03:08 +00:00
|
|
|
defaultText = "self.packages.${pkgs.system}";
|
|
|
|
internal = true;
|
2023-08-28 09:09:05 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
options.system.clan = lib.mkOption {
|
2023-10-05 15:08:31 +00:00
|
|
|
type = lib.types.submodule {
|
|
|
|
options = {
|
|
|
|
deployment.data = lib.mkOption {
|
|
|
|
type = lib.types.attrs;
|
|
|
|
description = ''
|
|
|
|
the data to be written to the deployment.json file
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
deployment.file = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
|
|
|
description = ''
|
|
|
|
the location of the deployment.json file
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
deploymentAddress = lib.mkOption {
|
|
|
|
type = lib.types.str;
|
|
|
|
description = ''
|
|
|
|
the address of the deployment server
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
secretsUploadDirectory = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
|
|
|
description = ''
|
|
|
|
the directory on the deployment server where secrets are uploaded
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
uploadSecrets = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
|
|
|
description = ''
|
|
|
|
script to upload secrets to the deployment server
|
|
|
|
'';
|
2023-10-06 16:34:49 +00:00
|
|
|
default = "${pkgs.coreutils}/bin/true";
|
2023-10-05 15:08:31 +00:00
|
|
|
};
|
|
|
|
generateSecrets = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
|
|
|
description = ''
|
|
|
|
script to generate secrets
|
|
|
|
'';
|
2023-10-06 16:34:49 +00:00
|
|
|
default = "${pkgs.coreutils}/bin/true";
|
2023-10-05 15:08:31 +00:00
|
|
|
};
|
|
|
|
vm.config = lib.mkOption {
|
|
|
|
type = lib.types.attrs;
|
|
|
|
description = ''
|
|
|
|
the vm config
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
vm.create = lib.mkOption {
|
|
|
|
type = lib.types.path;
|
|
|
|
description = ''
|
|
|
|
json metadata about the vm
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2023-08-28 09:09:05 +00:00
|
|
|
description = ''
|
|
|
|
utility outputs for clan management of this machine
|
|
|
|
'';
|
|
|
|
};
|
2023-09-29 09:56:02 +00:00
|
|
|
# optimization for faster secret generate/upload and machines update
|
|
|
|
config = {
|
2023-10-04 06:27:00 +00:00
|
|
|
system.clan.deployment.data = {
|
2023-09-29 09:56:02 +00:00
|
|
|
inherit (config.system.clan) uploadSecrets generateSecrets;
|
|
|
|
inherit (config.clan.networking) deploymentAddress;
|
2023-09-29 16:30:11 +00:00
|
|
|
inherit (config.clanCore) secretsUploadDirectory;
|
2023-09-29 09:56:02 +00:00
|
|
|
};
|
2023-10-04 06:27:00 +00:00
|
|
|
system.clan.deployment.file = pkgs.writeText "deployment.json" (builtins.toJSON config.system.clan.deployment.data);
|
2023-09-29 09:56:02 +00:00
|
|
|
};
|
2023-08-28 09:09:05 +00:00
|
|
|
};
|
|
|
|
}
|