mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 04:05:40 +03:00
nixos/weechat: Allow switching between TUI and headless mode
weechat can run in TUI or headless mode. Introduce the option `headless` for specifying that. Based on the setting, it configures the appropriate binary in the `binary` option and it also configures the systemd unit accordingly. `headless` is disabled by default. This doesn't change the current behaviour. Signed-off-by: Felix Singer <felixsinger@posteo.net>
This commit is contained in:
parent
8ef264f0a9
commit
36c5aed6d3
1 changed files with 16 additions and 3 deletions
|
@ -29,10 +29,19 @@ in
|
|||
binary = lib.mkOption {
|
||||
type = lib.types.path;
|
||||
description = "Binary to execute.";
|
||||
default = "${cfg.package}/bin/weechat";
|
||||
default =
|
||||
if (!cfg.headless) then "${cfg.package}/bin/weechat" else "${cfg.package}/bin/weechat-headless";
|
||||
defaultText = lib.literalExpression ''"''${cfg.package}/bin/weechat"'';
|
||||
example = lib.literalExpression ''"''${cfg.package}/bin/weechat-headless"'';
|
||||
};
|
||||
|
||||
headless = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
description = ''
|
||||
Allows specifying if weechat should run in TUI or headless mode.
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf cfg.enable {
|
||||
|
@ -56,18 +65,22 @@ in
|
|||
|
||||
systemd.services.weechat = {
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
User = "weechat";
|
||||
Group = "weechat";
|
||||
ExecStart = lib.mkIf (cfg.headless) "${cfg.binary} --dir ${cfg.root} --stdout";
|
||||
StateDirectory = lib.mkIf (cfg.root == "/var/lib/weechat") "weechat";
|
||||
StateDirectoryMode = 750;
|
||||
RemainAfterExit = "yes";
|
||||
};
|
||||
script = "exec ${config.security.wrapperDir}/screen -Dm -S ${cfg.sessionName} ${cfg.binary} --dir ${cfg.root}";
|
||||
script =
|
||||
lib.mkIf (!cfg.headless)
|
||||
"exec ${config.security.wrapperDir}/screen -Dm -S ${cfg.sessionName} ${cfg.binary} --dir ${cfg.root}";
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
wants = [ "network.target" ];
|
||||
};
|
||||
|
||||
security.wrappers.screen = {
|
||||
security.wrappers.screen = lib.mkIf (!cfg.headless) {
|
||||
setuid = true;
|
||||
owner = "root";
|
||||
group = "root";
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue