smug: add project session setting

Add an optional session setting so that session names can be different
than the smug project name. This also enables using template variables
when naming sessions.
This commit is contained in:
James Davidson 2026-03-15 12:56:59 -07:00 committed by Bruno BELANYI
parent ecf019baf4
commit f72ed9c97d
4 changed files with 37 additions and 3 deletions

View file

@ -37,9 +37,17 @@ in
projects = lib.mkOption {
type = lib.types.attrsOf (
lib.types.submodule [
lib.types.submodule (
{ name, ... }:
{
options = {
session = lib.mkOption {
type = lib.types.str;
default = name;
description = "Session name for the smug project.";
example = lib.literalExpression ''{ session = "project-\''${worktree}"; }'';
};
root = mkOptionRoot ''
Root path in filesystem of the smug project. This is where tmux
changes its directory to.
@ -139,7 +147,7 @@ in
stop = mkOptionCommands "Commands to execute after the tmux-session is destroyed.";
};
}
]
)
);
default = { };
description = "Attribute set with project configurations.";
@ -161,7 +169,7 @@ in
(lib.attrsets.nameValuePair (if name == "beforeStart" then "before_start" else name) value)
) v
// {
session = k;
session = v.session;
windows = lib.lists.forEach v.windows (
winprop: (lib.filterAttrsRecursive (name: value: value != null) winprop)
);