nixos/gitwatch: add message option

This commit is contained in:
Raphaël C.
2025-10-13 16:27:23 +02:00
parent 6650692457
commit fbc5e78b9c

View File

@@ -21,6 +21,7 @@ let
getvar = flag: var: optionalString (cfg."${var}" != null) "${flag} ${cfg."${var}"}"; getvar = flag: var: optionalString (cfg."${var}" != null) "${flag} ${cfg."${var}"}";
branch = getvar "-b" "branch"; branch = getvar "-b" "branch";
remote = getvar "-r" "remote"; remote = getvar "-r" "remote";
message = getvar "-m" "message";
in in
rec { rec {
inherit (cfg) enable; inherit (cfg) enable;
@@ -37,7 +38,7 @@ let
if [ -n "${cfg.remote}" ] && ! [ -d "${cfg.path}" ]; then if [ -n "${cfg.remote}" ] && ! [ -d "${cfg.path}" ]; then
git clone ${branch} "${cfg.remote}" "${cfg.path}" git clone ${branch} "${cfg.remote}" "${cfg.path}"
fi fi
gitwatch ${remote} ${branch} ${cfg.path} gitwatch ${remote} ${message} ${branch} ${cfg.path}
''; '';
serviceConfig.User = cfg.user; serviceConfig.User = cfg.user;
} }
@@ -56,6 +57,7 @@ in
user = "user"; user = "user";
path = "/home/user/watched-project"; path = "/home/user/watched-project";
remote = "git@github.com:me/my-project.git"; remote = "git@github.com:me/my-project.git";
message = "Auto-commit by gitwatch on %d";
}; };
disabled-repo = { disabled-repo = {
enable = false; enable = false;
@@ -84,6 +86,11 @@ in
type = nullOr str; type = nullOr str;
default = null; default = null;
}; };
message = lib.mkOption {
description = "Optional text to use in as commit message; all occurrences of `%d` will be replaced by formatted date/time";
type = nullOr str;
default = null;
};
branch = mkOption { branch = mkOption {
description = "Optional branch in remote repository"; description = "Optional branch in remote repository";
type = nullOr str; type = nullOr str;