mirror of
https://github.com/nix-community/home-manager.git
synced 2025-03-31 04:04:32 +00:00
Merge d99181fc07
into 1efd250317
This commit is contained in:
commit
d2e9844063
9 changed files with 259 additions and 0 deletions
modules
tests
|
@ -732,4 +732,10 @@
|
|||
github = "Noodlez1232";
|
||||
githubId = 12480453;
|
||||
};
|
||||
mipmip = {
|
||||
name = "Pim Snel";
|
||||
email = "post@pimsnel.com";
|
||||
github = "mipmip";
|
||||
githubId = 658612;
|
||||
};
|
||||
}
|
||||
|
|
|
@ -2158,7 +2158,15 @@ in {
|
|||
See https://github.com/WGUNDERWOOD/tex-fmt for more information.
|
||||
'';
|
||||
}
|
||||
{
|
||||
time = "2025-03-24T15:29:33+00:00";
|
||||
message = ''
|
||||
A new module is available: 'programs.smug'.
|
||||
|
||||
Session manager and task runner for tmux written in Go.
|
||||
See https://github.com/ivaaaan/smug for more information.
|
||||
'';
|
||||
}
|
||||
{
|
||||
time = "2025-03-24T22:31:45+00:00";
|
||||
message = ''
|
||||
|
|
|
@ -241,6 +241,7 @@ let
|
|||
./programs/sioyek.nix
|
||||
./programs/skim.nix
|
||||
./programs/sm64ex.nix
|
||||
./programs/smug.nix
|
||||
./programs/spotify-player.nix
|
||||
./programs/sqls.nix
|
||||
./programs/ssh.nix
|
||||
|
|
145
modules/programs/smug.nix
Normal file
145
modules/programs/smug.nix
Normal file
|
@ -0,0 +1,145 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
let
|
||||
cfg = config.programs.smug;
|
||||
iniFormat = pkgs.formats.yaml { };
|
||||
|
||||
mkOptionCommands = description:
|
||||
lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.listOf lib.types.str);
|
||||
default = null;
|
||||
description = description;
|
||||
};
|
||||
|
||||
mkOptionRoot = description:
|
||||
lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.str;
|
||||
default = null;
|
||||
description = description;
|
||||
};
|
||||
|
||||
in {
|
||||
meta.maintainers = with lib.hm.maintainers; [ mipmip ];
|
||||
|
||||
options.programs.smug = {
|
||||
|
||||
enable = lib.mkEnableOption "Smug session manager";
|
||||
|
||||
package = lib.mkPackageOption pkgs "smug" { nullable = true; };
|
||||
|
||||
projects = lib.mkOption {
|
||||
type = lib.types.attrsOf (lib.types.submodule [{
|
||||
options = {
|
||||
root = mkOptionRoot ''
|
||||
Root path in filesystem of the smug project. This is where tmux
|
||||
changes its directory to.
|
||||
|
||||
Application defaults to `$HOME`.
|
||||
'';
|
||||
|
||||
windows = lib.mkOption {
|
||||
type = lib.types.listOf (lib.types.submodule [{
|
||||
options = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
description = ''
|
||||
Name of the tmux window;
|
||||
'';
|
||||
};
|
||||
|
||||
root = mkOptionRoot
|
||||
"Root path of window. This is relative to the path of the smug project.";
|
||||
|
||||
commands =
|
||||
mkOptionCommands "Commands to execute when window starts.";
|
||||
|
||||
layout = lib.mkOption {
|
||||
type = lib.types.enum [
|
||||
"main-horizontal"
|
||||
"main-vertical"
|
||||
"even-vertical"
|
||||
"even-horizontal"
|
||||
"tiled"
|
||||
];
|
||||
description = ''
|
||||
Layout of window when opening panes.
|
||||
'';
|
||||
};
|
||||
|
||||
manual = lib.mkOption {
|
||||
type = lib.types.nullOr lib.types.bool;
|
||||
default = null;
|
||||
description = ''
|
||||
Start window only manually, using the -w arg
|
||||
'';
|
||||
};
|
||||
|
||||
panes = lib.mkOption {
|
||||
default = null;
|
||||
description = ''
|
||||
Panes to open in a window.
|
||||
'';
|
||||
type = lib.types.nullOr (lib.types.listOf
|
||||
(lib.types.submodule [{
|
||||
options = {
|
||||
root = mkOptionRoot
|
||||
"Root path of pane. This is relative to the path of the smug project.";
|
||||
commands = mkOptionCommands
|
||||
"Commands to execute when pane starts.";
|
||||
type = lib.mkOption {
|
||||
type = lib.types.enum [ "horizontal" "vertical" ];
|
||||
description = ''
|
||||
Type of pane.
|
||||
'';
|
||||
};
|
||||
};
|
||||
}]));
|
||||
};
|
||||
};
|
||||
}]);
|
||||
description = ''
|
||||
Windows to create in the project session
|
||||
'';
|
||||
};
|
||||
|
||||
env = lib.mkOption {
|
||||
type = lib.types.nullOr (lib.types.attrsOf lib.types.str);
|
||||
default = null;
|
||||
description = "Environment Variables to set in session.";
|
||||
};
|
||||
|
||||
beforeStart = mkOptionCommands
|
||||
"Commands to execute before the tmux-session starts.";
|
||||
|
||||
stop = mkOptionCommands
|
||||
"Commands to execute after the tmux-session is destroyed.";
|
||||
};
|
||||
}]);
|
||||
default = { };
|
||||
description = "Attribute set with project configurations.";
|
||||
};
|
||||
};
|
||||
|
||||
config = let
|
||||
cleanedProjects =
|
||||
lib.filterAttrsRecursive (name: value: value != null) cfg.projects;
|
||||
|
||||
mkProjects = lib.attrsets.mapAttrs' (k: v: {
|
||||
name = "${config.home.homeDirectory}/.config/smug/${k}.yml";
|
||||
value.source = let
|
||||
prjConf = lib.attrsets.mapAttrs' (name: value:
|
||||
(lib.attrsets.nameValuePair
|
||||
(if name == "beforeStart" then "before_start" else name) (value))) v
|
||||
// {
|
||||
session = k;
|
||||
windows = lib.lists.forEach v.windows (winprop:
|
||||
(lib.filterAttrsRecursive (name: value: value != null) winprop));
|
||||
};
|
||||
in iniFormat.generate "smug-project-${k}" prjConf;
|
||||
});
|
||||
|
||||
in lib.mkIf cfg.enable {
|
||||
home.packages = lib.mkIf (cfg.package != null) [ cfg.package ];
|
||||
home.file = mkProjects cleanedProjects;
|
||||
};
|
||||
}
|
|
@ -172,6 +172,7 @@ let
|
|||
"sioyek"
|
||||
"skhd"
|
||||
"sm64ex"
|
||||
"smug"
|
||||
"spotify-player"
|
||||
"starship"
|
||||
"taskwarrior"
|
||||
|
@ -389,6 +390,7 @@ in import nmtSrc {
|
|||
./modules/programs/sftpman
|
||||
./modules/programs/sioyek
|
||||
./modules/programs/sm64ex
|
||||
./modules/programs/smug
|
||||
./modules/programs/spotify-player
|
||||
./modules/programs/ssh
|
||||
./modules/programs/starship
|
||||
|
|
33
tests/modules/programs/smug/blogdemo.yml
Normal file
33
tests/modules/programs/smug/blogdemo.yml
Normal file
|
@ -0,0 +1,33 @@
|
|||
before_start:
|
||||
- docker-compose -f my-microservices/docker-compose.yml up -d
|
||||
env:
|
||||
FOO: bar
|
||||
root: ~/Developer/blog
|
||||
session: blogdemo
|
||||
stop:
|
||||
- docker stop $(docker ps -q)
|
||||
windows:
|
||||
- commands:
|
||||
- docker-compose start
|
||||
layout: main-vertical
|
||||
manual: true
|
||||
name: code
|
||||
panes:
|
||||
- commands:
|
||||
- docker-compose exec php /bin/sh
|
||||
- clear
|
||||
root: .
|
||||
type: horizontal
|
||||
root: blog
|
||||
- commands:
|
||||
- docker-compose start
|
||||
layout: tiled
|
||||
name: infrastructure
|
||||
panes:
|
||||
- commands:
|
||||
- docker-compose up -d
|
||||
- docker-compose exec php /bin/sh
|
||||
- clear
|
||||
root: .
|
||||
type: horizontal
|
||||
root: ~/Developer/blog/my-microservices
|
4
tests/modules/programs/smug/default.nix
Normal file
4
tests/modules/programs/smug/default.nix
Normal file
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
smug-settings = ./settings.nix;
|
||||
smug-empty-settings = ./empty-settings.nix;
|
||||
}
|
6
tests/modules/programs/smug/empty-settings.nix
Normal file
6
tests/modules/programs/smug/empty-settings.nix
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
programs.smug.enable = true;
|
||||
nmt.script = ''
|
||||
assertPathNotExists home-files/.config/smug
|
||||
'';
|
||||
}
|
54
tests/modules/programs/smug/settings.nix
Normal file
54
tests/modules/programs/smug/settings.nix
Normal file
|
@ -0,0 +1,54 @@
|
|||
{
|
||||
programs = {
|
||||
smug = {
|
||||
enable = true;
|
||||
|
||||
projects = {
|
||||
|
||||
blogdemo = {
|
||||
root = "~/Developer/blog";
|
||||
beforeStart = [
|
||||
"docker-compose -f my-microservices/docker-compose.yml up -d" # my-microservices/docker-compose.yml is a relative to `root`-al
|
||||
];
|
||||
env = { FOO = "bar"; };
|
||||
stop = [ "docker stop $(docker ps -q)" ];
|
||||
windows = [
|
||||
{
|
||||
name = "code";
|
||||
root = "blog";
|
||||
manual = true;
|
||||
layout = "main-vertical";
|
||||
commands = [ "docker-compose start" ];
|
||||
panes = [{
|
||||
type = "horizontal";
|
||||
root = ".";
|
||||
commands = [ "docker-compose exec php /bin/sh" "clear" ];
|
||||
}];
|
||||
}
|
||||
|
||||
{
|
||||
name = "infrastructure";
|
||||
root = "~/Developer/blog/my-microservices";
|
||||
layout = "tiled";
|
||||
commands = [ "docker-compose start" ];
|
||||
panes = [{
|
||||
type = "horizontal";
|
||||
root = ".";
|
||||
commands = [
|
||||
"docker-compose up -d"
|
||||
"docker-compose exec php /bin/sh"
|
||||
"clear"
|
||||
];
|
||||
}];
|
||||
}
|
||||
];
|
||||
};
|
||||
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
assertFileContent home-files/.config/smug/blogdemo.yml ${./blogdemo.yml}
|
||||
'';
|
||||
}
|
Loading…
Add table
Reference in a new issue