mirror of
https://github.com/SebastianStork/nixos-config.git
synced 2026-03-22 17:49:07 +01:00
62 lines
1.5 KiB
Nix
62 lines
1.5 KiB
Nix
{
|
|
config,
|
|
inputs,
|
|
pkgs,
|
|
lib,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.custom.services.comin;
|
|
|
|
postDeploymentScript =
|
|
pkgs.writeShellApplication {
|
|
name = "comin-post-deployment";
|
|
runtimeInputs = [ pkgs.git ];
|
|
text = ''
|
|
if [[ "$COMIN_STATUS" != "done" ]]; then
|
|
echo "Deployment not successful (status: $COMIN_STATUS), skipping branch update"
|
|
exit 0
|
|
fi
|
|
|
|
token=$(cat "${config.sops.secrets."git/push-token".path}")
|
|
repo_url="https://x-access-token:$token@github.com/SebastianStork/nixos-config.git"
|
|
|
|
git -C /var/lib/comin/repository push --force "$repo_url" "$COMIN_GIT_SHA:refs/heads/deployed/$COMIN_HOSTNAME"
|
|
|
|
echo "Updated deployed/$COMIN_HOSTNAME to $COMIN_GIT_SHA"
|
|
'';
|
|
}
|
|
|> lib.getExe;
|
|
in
|
|
{
|
|
imports = [ inputs.comin.nixosModules.comin ];
|
|
|
|
options.custom.services.comin = {
|
|
enable = lib.mkEnableOption "";
|
|
metricsPort = lib.mkOption {
|
|
type = lib.types.port;
|
|
default = 4243;
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
sops.secrets."git/push-token" = { };
|
|
|
|
services.comin = {
|
|
enable = true;
|
|
remotes = lib.singleton {
|
|
name = "origin";
|
|
url = "https://github.com/SebastianStork/nixos-config.git";
|
|
branches = {
|
|
main.name = "deploy";
|
|
testing.operation = "switch";
|
|
};
|
|
};
|
|
exporter = {
|
|
listen_address = "127.0.0.1";
|
|
port = cfg.metricsPort;
|
|
};
|
|
postDeploymentCommand = postDeploymentScript;
|
|
};
|
|
};
|
|
}
|