mirror of
https://github.com/nix-community/home-manager.git
synced 2025-11-08 19:46:05 +01:00
shpool: init shpool module
This commit is contained in:
parent
e44549074a
commit
f27974d3b4
2 changed files with 109 additions and 0 deletions
11
modules/misc/news/2025/08/2025-08-30_18-07-19.nix
Normal file
11
modules/misc/news/2025/08/2025-08-30_18-07-19.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
time = "2025-08-30T16:07:19+00:00";
|
||||||
|
condition = true;
|
||||||
|
message = ''
|
||||||
|
A new module is available: 'services.shpool'.
|
||||||
|
|
||||||
|
shpool is a service that enables session persistence by allowing the creation of named shell sessions owned by shpool so that the session is not lost if the connection drops.
|
||||||
|
|
||||||
|
Read about it at https://github.com/shell-pool/shpool
|
||||||
|
'';
|
||||||
|
}
|
||||||
98
modules/services/shpool.nix
Normal file
98
modules/services/shpool.nix
Normal file
|
|
@ -0,0 +1,98 @@
|
||||||
|
{
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
getExe
|
||||||
|
mkEnableOption
|
||||||
|
mkIf
|
||||||
|
mkOption
|
||||||
|
mkPackageOption
|
||||||
|
;
|
||||||
|
|
||||||
|
cfg = config.services.shpool;
|
||||||
|
format = pkgs.formats.toml { };
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = with lib.maintainers; [ fredeb ];
|
||||||
|
|
||||||
|
options.services.shpool = {
|
||||||
|
enable = mkEnableOption "shpool";
|
||||||
|
package = mkPackageOption pkgs "shpool" { nullable = true; };
|
||||||
|
|
||||||
|
settings = lib.mkOption {
|
||||||
|
type = format.type;
|
||||||
|
default = { };
|
||||||
|
example = {
|
||||||
|
prompt_prefix = "[$SHPOOL_SESSION_NAME]";
|
||||||
|
session_restore_mode.lines = 1000;
|
||||||
|
|
||||||
|
keybinding = [
|
||||||
|
{
|
||||||
|
binding = "Ctrl-a d";
|
||||||
|
action = "detach";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
motd = "never";
|
||||||
|
};
|
||||||
|
description = ''
|
||||||
|
Configuration to use for shpool. See
|
||||||
|
<https://github.com/shell-pool/shpool/blob/master/CONFIG.md>
|
||||||
|
for available options.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd = mkEnableOption "systemd service and socket for shpool" // mkOption { default = true; };
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
|
||||||
|
systemd.user = {
|
||||||
|
services.shpool = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Shpool - Shell Session Pool";
|
||||||
|
Requires = [ "shpool.socket" ];
|
||||||
|
};
|
||||||
|
|
||||||
|
Service = {
|
||||||
|
Type = "simple";
|
||||||
|
ExecStart = "${getExe cfg.package} daemon";
|
||||||
|
KillMode = "mixed";
|
||||||
|
TimeoutStopSec = "2s";
|
||||||
|
SendSIGHUP = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "default.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
sockets.shpool = {
|
||||||
|
Unit = {
|
||||||
|
Description = "Shpool Shell Session Pooler";
|
||||||
|
};
|
||||||
|
|
||||||
|
Socket = {
|
||||||
|
ListenStream = "%t/shpool/shpool.socket";
|
||||||
|
SocketMode = "0600";
|
||||||
|
RemoveOnStop = "yes";
|
||||||
|
FlushPending = "yes";
|
||||||
|
};
|
||||||
|
Install = {
|
||||||
|
WantedBy = [ "sockets.target" ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
home.packages = [ cfg.package ];
|
||||||
|
|
||||||
|
xdg.configFile = lib.mkIf (cfg.settings != { }) {
|
||||||
|
"shpool/config.toml".source = format.generate "config.toml" cfg.settings;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue