aboutsummaryrefslogtreecommitdiff
path: root/nixpkgs/nixos/modules/services/misc/weechat.nix
diff options
context:
space:
mode:
Diffstat (limited to 'nixpkgs/nixos/modules/services/misc/weechat.nix')
-rw-r--r--nixpkgs/nixos/modules/services/misc/weechat.nix58
1 files changed, 58 insertions, 0 deletions
diff --git a/nixpkgs/nixos/modules/services/misc/weechat.nix b/nixpkgs/nixos/modules/services/misc/weechat.nix
new file mode 100644
index 00000000000..c6ff540ea12
--- /dev/null
+++ b/nixpkgs/nixos/modules/services/misc/weechat.nix
@@ -0,0 +1,58 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+
+let
+ cfg = config.services.weechat;
+in
+
+{
+ options.services.weechat = {
+ enable = mkEnableOption "weechat";
+ root = mkOption {
+ description = "Weechat state directory.";
+ type = types.str;
+ default = "/var/lib/weechat";
+ };
+ sessionName = mkOption {
+ description = "Name of the `screen' session for weechat.";
+ default = "weechat-screen";
+ type = types.str;
+ };
+ binary = mkOption {
+ description = "Binary to execute (by default \${weechat}/bin/weechat).";
+ example = literalExample ''
+ ''${pkgs.weechat}/bin/weechat-headless
+ '';
+ default = "${pkgs.weechat}/bin/weechat";
+ };
+ };
+
+ config = mkIf cfg.enable {
+ users = {
+ groups.weechat = {};
+ users.weechat = {
+ createHome = true;
+ group = "weechat";
+ home = cfg.root;
+ isSystemUser = true;
+ };
+ };
+
+ systemd.services.weechat = {
+ environment.WEECHAT_HOME = cfg.root;
+ serviceConfig = {
+ User = "weechat";
+ Group = "weechat";
+ RemainAfterExit = "yes";
+ };
+ script = "exec ${config.security.wrapperDir}/screen -Dm -S ${cfg.sessionName} ${cfg.binary}";
+ wantedBy = [ "multi-user.target" ];
+ wants = [ "network.target" ];
+ };
+
+ security.wrappers.screen.source = "${pkgs.screen}/bin/screen";
+ };
+
+ meta.doc = ./weechat.xml;
+}