mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-09 04:19:19 -08:00
feat(exports): service access
This commit is contained in:
parent
91918b8061
commit
871b1c5b2d
69 changed files with 1317 additions and 509 deletions
48
modules/system/exports/exports.nix
Normal file
48
modules/system/exports/exports.nix
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
config,
|
||||
name,
|
||||
lib,
|
||||
...
|
||||
}: let
|
||||
inherit (lib.options) mkOption mkEnableOption;
|
||||
cfg = config.exports;
|
||||
systemConfig = config;
|
||||
exportModule = {
|
||||
config,
|
||||
name,
|
||||
...
|
||||
}: {
|
||||
options = with lib.types; {
|
||||
enable = mkEnableOption "exported service";
|
||||
name = mkOption {
|
||||
type = str;
|
||||
default = name;
|
||||
};
|
||||
serviceName = mkOption {
|
||||
type = str;
|
||||
default = name;
|
||||
};
|
||||
id = mkOption {
|
||||
type = str;
|
||||
default = cfg.services.${config.serviceName}.id/* or config.name*/;
|
||||
};
|
||||
};
|
||||
};
|
||||
in {
|
||||
options.exports = with lib.types; {
|
||||
exports = mkOption {
|
||||
type = attrsOf (submoduleWith {
|
||||
modules = [exportModule];
|
||||
specialArgs = {
|
||||
machine = name;
|
||||
inherit systemConfig;
|
||||
};
|
||||
});
|
||||
default = {};
|
||||
};
|
||||
};
|
||||
|
||||
config = {
|
||||
_module.args.exports = cfg;
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue