cfg cosmetics
This commit is contained in:
parent
277617594e
commit
46155b9cb8
@ -45,7 +45,10 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
config = lib.mkMerge [
|
config = lib.mkMerge [
|
||||||
(lib.mkIf cfg.main.enable {
|
(let
|
||||||
|
cfg = config.mj.services.deployerbot.main;
|
||||||
|
in
|
||||||
|
lib.mkIf cfg.enable {
|
||||||
# TODO: git config --global user.email bot@jakstys.lt
|
# TODO: git config --global user.email bot@jakstys.lt
|
||||||
users.users.deployerbot-main = {
|
users.users.deployerbot-main = {
|
||||||
description = "Deployerbot Main";
|
description = "Deployerbot Main";
|
||||||
@ -54,9 +57,9 @@ in {
|
|||||||
group = "deployerbot-main";
|
group = "deployerbot-main";
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
createHome = true;
|
createHome = true;
|
||||||
uid = cfg.main.uidgid;
|
uid = cfg.uidgid;
|
||||||
};
|
};
|
||||||
users.groups.deployerbot-main.gid = cfg.main.uidgid;
|
users.groups.deployerbot-main.gid = cfg.uidgid;
|
||||||
|
|
||||||
systemd.services.deployerbot = {
|
systemd.services.deployerbot = {
|
||||||
description = "Update all known systems";
|
description = "Update all known systems";
|
||||||
@ -70,12 +73,12 @@ in {
|
|||||||
LoadCredential = ["ssh-key:/etc/ssh/ssh_host_ed25519_key"];
|
LoadCredential = ["ssh-key:/etc/ssh/ssh_host_ed25519_key"];
|
||||||
};
|
};
|
||||||
script = let
|
script = let
|
||||||
deployDerivationsStr = builtins.concatStringsSep " " cfg.main.deployDerivations;
|
deployDerivationsStr = builtins.concatStringsSep " " cfg.deployDerivations;
|
||||||
in ''
|
in ''
|
||||||
set -x
|
set -x
|
||||||
export GIT_SSH_COMMAND="ssh -i ''${CREDENTIALS_DIRECTORY}/ssh-key"
|
export GIT_SSH_COMMAND="ssh -i ''${CREDENTIALS_DIRECTORY}/ssh-key"
|
||||||
if [[ ! -d config ]]; then
|
if [[ ! -d config ]]; then
|
||||||
git clone ${cfg.main.repo} config
|
git clone ${cfg.repo} config
|
||||||
cd config
|
cd config
|
||||||
else
|
else
|
||||||
cd config
|
cd config
|
||||||
@ -93,7 +96,7 @@ in {
|
|||||||
--accept-flake-config
|
--accept-flake-config
|
||||||
|
|
||||||
# Optional deployments
|
# Optional deployments
|
||||||
${lib.concatLines (map mkOptional cfg.main.deployIfPresent)}
|
${lib.concatLines (map mkOptional cfg.deployIfPresent)}
|
||||||
|
|
||||||
# done
|
# done
|
||||||
git push origin main
|
git push origin main
|
||||||
@ -110,7 +113,11 @@ in {
|
|||||||
|
|
||||||
nix.settings.trusted-users = ["deployerbot-main"];
|
nix.settings.trusted-users = ["deployerbot-main"];
|
||||||
})
|
})
|
||||||
(lib.mkIf cfg.follower.enable {
|
|
||||||
|
(let
|
||||||
|
cfg = config.mj.services.deployerbot.follower;
|
||||||
|
in
|
||||||
|
lib.mkIf cfg.enable {
|
||||||
users.users = {
|
users.users = {
|
||||||
deployerbot-follower = {
|
deployerbot-follower = {
|
||||||
description = "Deployerbot Follower";
|
description = "Deployerbot Follower";
|
||||||
@ -120,13 +127,13 @@ in {
|
|||||||
extraGroups = ["wheel"];
|
extraGroups = ["wheel"];
|
||||||
isSystemUser = true;
|
isSystemUser = true;
|
||||||
createHome = true;
|
createHome = true;
|
||||||
uid = cfg.follower.uidgid;
|
uid = cfg.uidgid;
|
||||||
openssh.authorizedKeys.keys = let
|
openssh.authorizedKeys.keys = let
|
||||||
restrictedPubKey = "from=\"${builtins.concatStringsSep "," cfg.follower.sshAllowSubnets}\" " + cfg.follower.publicKey;
|
restrictedPubKey = "from=\"${builtins.concatStringsSep "," cfg.sshAllowSubnets}\" " + cfg.publicKey;
|
||||||
in [restrictedPubKey];
|
in [restrictedPubKey];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
users.groups.deployerbot-follower.gid = cfg.follower.uidgid;
|
users.groups.deployerbot-follower.gid = cfg.uidgid;
|
||||||
nix.settings.trusted-users = ["deployerbot-follower"];
|
nix.settings.trusted-users = ["deployerbot-follower"];
|
||||||
})
|
})
|
||||||
];
|
];
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
pkgs,
|
pkgs,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
cfg = config.mj.services.nsd-acme;
|
||||||
mkHook = zone: let
|
mkHook = zone: let
|
||||||
rc = config.services.nsd.remoteControl;
|
rc = config.services.nsd.remoteControl;
|
||||||
fullZone = "_acme-endpoint.${zone}";
|
fullZone = "_acme-endpoint.${zone}";
|
||||||
@ -84,7 +85,7 @@ in {
|
|||||||
};
|
};
|
||||||
|
|
||||||
# TODO assert services.nsd.enable
|
# TODO assert services.nsd.enable
|
||||||
config = lib.mkIf config.mj.services.nsd-acme.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
services.nsd.remoteControl.enable = true;
|
services.nsd.remoteControl.enable = true;
|
||||||
services.nsd.extraConfig = ''
|
services.nsd.extraConfig = ''
|
||||||
pattern:
|
pattern:
|
||||||
@ -186,7 +187,7 @@ in {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
config.mj.services.nsd-acme.zones;
|
cfg.zones;
|
||||||
|
|
||||||
systemd.timers =
|
systemd.timers =
|
||||||
lib.mapAttrs'
|
lib.mapAttrs'
|
||||||
@ -201,14 +202,14 @@ in {
|
|||||||
after = ["network-online.target"];
|
after = ["network-online.target"];
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
config.mj.services.nsd-acme.zones;
|
cfg.zones;
|
||||||
|
|
||||||
mj.base.unitstatus.units =
|
mj.base.unitstatus.units =
|
||||||
lib.mkIf config.mj.base.unitstatus.enable
|
lib.mkIf config.mj.base.unitstatus.enable
|
||||||
(
|
(
|
||||||
["nsd-control-setup"]
|
["nsd-control-setup"]
|
||||||
++ map (z: "nsd-acme-${z}")
|
++ map (z: "nsd-acme-${z}")
|
||||||
(lib.attrNames config.mj.services.nsd-acme.zones)
|
(lib.attrNames cfg.zones)
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user