Small modules config restructure
Changed variables names in every module
This commit is contained in:
1 parent
c1d2e52bf8
commit
c92b90e406
83 files changed
+616
-523
No files matched your search
@@ -1,12 +1,12 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
rootCfg = config.selfhosted.mihomo;
|
||||
moduleCfg = config.selfhosted.mihomo;
|
||||
subUrl = config.sops.placeholder."mihomo/subscription_url";
|
||||
secret = config.sops.placeholder."mihomo/secret";
|
||||
in
|
||||
{
|
||||
config = mkIf rootCfg.enable {
|
||||
config = mkIf moduleCfg.enable {
|
||||
sops.templates."mihomo.yaml".content = ''
|
||||
mixed-port: 7890
|
||||
allow-lan: true
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
rootCfg = config.selfhosted.mihomo;
|
||||
cfg = rootCfg.core;
|
||||
rootCfg = config.selfhosted;
|
||||
common = rootCfg.common;
|
||||
moduleCfg = rootCfg.mihomo;
|
||||
cfg = moduleCfg.core;
|
||||
hostDataPath = "${common.dataDir}/mihomo";
|
||||
in
|
||||
{
|
||||
@@ -21,7 +22,7 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf rootCfg.enable {
|
||||
config = mkIf moduleCfg.enable {
|
||||
virtualisation.oci-containers.containers.${cfg.name} = {
|
||||
image = "docker.io/metacubex/mihomo:v1.19.30";
|
||||
ports = [
|
||||
@@ -41,8 +42,8 @@ in
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
};
|
||||
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
||||
preStart = ''
|
||||
mkdir -p ${hostDataPath}/providers
|
||||
cp -f ${config.sops.templates."mihomo.yaml".path} ${hostDataPath}/config.yaml
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
{ config, lib, ... }:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
rootCfg = config.selfhosted.mihomo;
|
||||
cfg = rootCfg.dashboard;
|
||||
rootCfg = config.selfhosted;
|
||||
common = rootCfg.common;
|
||||
moduleCfg = rootCfg.mihomo;
|
||||
cfg = moduleCfg.dashboard;
|
||||
in
|
||||
{
|
||||
options.selfhosted.mihomo.dashboard = {
|
||||
@@ -18,7 +19,7 @@ in
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf rootCfg.enable {
|
||||
config = mkIf moduleCfg.enable {
|
||||
virtualisation.oci-containers.containers.${cfg.name} = {
|
||||
image = "ghcr.io/zephyruso/zashboard:v3.19.0";
|
||||
ports = [
|
||||
@@ -34,10 +35,10 @@ in
|
||||
serviceConfig = {
|
||||
Restart = lib.mkOverride 90 "always";
|
||||
};
|
||||
wantedBy = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${rootCfg.targetName}.target" ];
|
||||
requires = [ "${common.backend}-${rootCfg.core.name}.service" ];
|
||||
after = [ "${common.backend}-${rootCfg.core.name}.service" ];
|
||||
wantedBy = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
||||
partOf = [ "${common.backend}-${moduleCfg.targetName}.target" ];
|
||||
requires = [ "${common.backend}-${moduleCfg.core.name}.service" ];
|
||||
after = [ "${common.backend}-${moduleCfg.core.name}.service" ];
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -5,8 +5,9 @@
|
||||
}:
|
||||
with lib;
|
||||
let
|
||||
common = config.selfhosted.common;
|
||||
cfg = config.selfhosted.mihomo;
|
||||
rootCfg = config.selfhosted;
|
||||
common = rootCfg.common;
|
||||
moduleCfg = rootCfg.mihomo;
|
||||
in
|
||||
{
|
||||
imports = [
|
||||
@@ -15,21 +16,21 @@ in
|
||||
];
|
||||
|
||||
options.selfhosted.mihomo = {
|
||||
enable = mkEnableOption "Enable ${cfg.targetName} root target";
|
||||
enable = mkEnableOption "Enable ${moduleCfg.targetName} root target";
|
||||
targetName = mkOption {
|
||||
type = types.str;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
config = mkIf moduleCfg.enable {
|
||||
sops.secrets = {
|
||||
"mihomo/subscription_url" = { };
|
||||
"mihomo/secret" = { };
|
||||
};
|
||||
|
||||
systemd.targets."${common.backend}-${cfg.targetName}" = {
|
||||
systemd.targets."${common.backend}-${moduleCfg.targetName}" = {
|
||||
unitConfig = {
|
||||
Description = "Root target for ${cfg.targetName}";
|
||||
Description = "Root target for ${moduleCfg.targetName}";
|
||||
};
|
||||
wantedBy = [ "${common.backend}-${common.rootTarget.name}.target" ];
|
||||
partOf = [ "${common.backend}-${common.rootTarget.name}.target" ];
|
||||
@@ -39,8 +40,8 @@ in
|
||||
# set proxy for build time
|
||||
systemd.services.nix-daemon =
|
||||
let
|
||||
mihomoService = "${common.backend}-${cfg.core.name}.service";
|
||||
socksPort = "${toString cfg.core.hostMixedPort}";
|
||||
mihomoService = "${common.backend}-${moduleCfg.core.name}.service";
|
||||
socksPort = "${toString moduleCfg.core.hostMixedPort}";
|
||||
in
|
||||
{
|
||||
after = [ "${mihomoService}" ];
|
||||
|
||||
Reference in new issue
Block a user