forked from clan/clan-core
clanCore: refactor flake-module.nix into smaller files
This commit is contained in:
parent
963533e6c1
commit
8ee72ba5fa
@ -41,7 +41,6 @@
|
||||
|
||||
./lib/flake-module.nix
|
||||
./nixosModules/flake-module.nix
|
||||
./nixosModules/clanCore/flake-module.nix
|
||||
];
|
||||
});
|
||||
}
|
||||
|
17
nixosModules/clanCore/default.nix
Normal file
17
nixosModules/clanCore/default.nix
Normal file
@ -0,0 +1,17 @@
|
||||
{
|
||||
imports = [
|
||||
./backups.nix
|
||||
./imports.nix
|
||||
./meshnamed
|
||||
./metadata.nix
|
||||
./networking.nix
|
||||
./nix-settings.nix
|
||||
./options.nix
|
||||
./outputs.nix
|
||||
./packages.nix
|
||||
./schema.nix
|
||||
./secrets
|
||||
./vm.nix
|
||||
./zerotier
|
||||
];
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
{ self, inputs, lib, ... }: {
|
||||
flake.nixosModules.clanCore = { config, pkgs, options, ... }: {
|
||||
imports = [
|
||||
./backups.nix
|
||||
./clan-imports
|
||||
./secrets
|
||||
./zerotier
|
||||
./meshnamed
|
||||
./networking.nix
|
||||
./packages.nix
|
||||
./nix-settings.nix
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
# just some example options. Can be removed later
|
||||
./vm.nix
|
||||
./options.nix
|
||||
];
|
||||
options.clanSchema = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "The json schema for the .clan options namespace";
|
||||
default = self.lib.jsonschema.parseOptions options.clan;
|
||||
};
|
||||
options.clanCore = {
|
||||
clanName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
the name of the clan
|
||||
'';
|
||||
};
|
||||
clanDir = lib.mkOption {
|
||||
type = lib.types.either lib.types.path lib.types.str;
|
||||
description = ''
|
||||
the location of the flake repo, used to calculate the location of facts and secrets
|
||||
'';
|
||||
};
|
||||
clanIcon = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
description = ''
|
||||
the location of the clan icon
|
||||
'';
|
||||
};
|
||||
machineName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
the name of the machine
|
||||
'';
|
||||
};
|
||||
clanPkgs = lib.mkOption {
|
||||
default = self.packages.${pkgs.system};
|
||||
defaultText = "self.packages.${pkgs.system}";
|
||||
internal = true;
|
||||
};
|
||||
};
|
||||
# TODO: factor these out into a separate interface.nix.
|
||||
# Also think about moving these options out of `system.clan`.
|
||||
# Maybe we should not re-use the already polluted confg.system namespace
|
||||
# and instead have a separate top-level namespace like `clanOutputs`, with
|
||||
# well defined options marked as `internal = true;`.
|
||||
options.system.clan = lib.mkOption {
|
||||
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
|
||||
'';
|
||||
default = "${pkgs.coreutils}/bin/true";
|
||||
};
|
||||
generateSecrets = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = ''
|
||||
script to generate secrets
|
||||
'';
|
||||
default = "${pkgs.coreutils}/bin/true";
|
||||
};
|
||||
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
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
utility outputs for clan management of this machine
|
||||
'';
|
||||
};
|
||||
# optimization for faster secret generate/upload and machines update
|
||||
config = {
|
||||
system.clan.deployment.data = {
|
||||
inherit (config.system.clan) uploadSecrets generateSecrets;
|
||||
inherit (config.clan.networking) deploymentAddress;
|
||||
inherit (config.clanCore) secretsUploadDirectory;
|
||||
};
|
||||
system.clan.deployment.file = pkgs.writeText "deployment.json" (builtins.toJSON config.system.clan.deployment.data);
|
||||
};
|
||||
};
|
||||
}
|
32
nixosModules/clanCore/metadata.nix
Normal file
32
nixosModules/clanCore/metadata.nix
Normal file
@ -0,0 +1,32 @@
|
||||
{ lib, pkgs, ... }: {
|
||||
options.clanCore = {
|
||||
clanName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
the name of the clan
|
||||
'';
|
||||
};
|
||||
clanDir = lib.mkOption {
|
||||
type = lib.types.either lib.types.path lib.types.str;
|
||||
description = ''
|
||||
the location of the flake repo, used to calculate the location of facts and secrets
|
||||
'';
|
||||
};
|
||||
clanIcon = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.path;
|
||||
description = ''
|
||||
the location of the clan icon
|
||||
'';
|
||||
};
|
||||
machineName = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
the name of the machine
|
||||
'';
|
||||
};
|
||||
clanPkgs = lib.mkOption {
|
||||
defaultText = "self.packages.${pkgs.system}";
|
||||
internal = true;
|
||||
};
|
||||
};
|
||||
}
|
76
nixosModules/clanCore/outputs.nix
Normal file
76
nixosModules/clanCore/outputs.nix
Normal file
@ -0,0 +1,76 @@
|
||||
{ config, lib, pkgs, ... }: {
|
||||
# TODO: factor these out into a separate interface.nix.
|
||||
# Also think about moving these options out of `system.clan`.
|
||||
# Maybe we should not re-use the already polluted confg.system namespace
|
||||
# and instead have a separate top-level namespace like `clanOutputs`, with
|
||||
# well defined options marked as `internal = true;`.
|
||||
options.system.clan = lib.mkOption {
|
||||
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
|
||||
'';
|
||||
default = "${pkgs.coreutils}/bin/true";
|
||||
};
|
||||
generateSecrets = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = ''
|
||||
script to generate secrets
|
||||
'';
|
||||
default = "${pkgs.coreutils}/bin/true";
|
||||
};
|
||||
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
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
description = ''
|
||||
utility outputs for clan management of this machine
|
||||
'';
|
||||
};
|
||||
# optimization for faster secret generate/upload and machines update
|
||||
config = {
|
||||
system.clan.deployment.data = {
|
||||
inherit (config.system.clan) uploadSecrets generateSecrets;
|
||||
inherit (config.clan.networking) deploymentAddress;
|
||||
inherit (config.clanCore) secretsUploadDirectory;
|
||||
};
|
||||
system.clan.deployment.file = pkgs.writeText "deployment.json" (builtins.toJSON config.system.clan.deployment.data);
|
||||
};
|
||||
|
||||
}
|
11
nixosModules/clanCore/schema.nix
Normal file
11
nixosModules/clanCore/schema.nix
Normal file
@ -0,0 +1,11 @@
|
||||
{ options, lib, ... }:
|
||||
let
|
||||
jsonschema = import ../../lib/jsonschema { inherit lib; };
|
||||
in
|
||||
{
|
||||
options.clanSchema = lib.mkOption {
|
||||
type = lib.types.attrs;
|
||||
description = "The json schema for the .clan options namespace";
|
||||
default = jsonschema.parseOptions options.clan;
|
||||
};
|
||||
}
|
@ -1,6 +1,13 @@
|
||||
{ ... }: {
|
||||
{ inputs, self, ... }: {
|
||||
flake.nixosModules = {
|
||||
hidden-ssh-announce.imports = [ ./hidden-ssh-announce.nix ];
|
||||
installer.imports = [ ./installer ];
|
||||
clanCore.imports = [
|
||||
inputs.sops-nix.nixosModules.sops
|
||||
./clanCore
|
||||
({ pkgs, lib, ... }: {
|
||||
clanCore.clanPkgs = lib.mkDefault self.packages.${pkgs.hostPlatform.system};
|
||||
})
|
||||
];
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user