在NixOS上配置twitch lambdabot作为服务

时间:2018-01-27 15:38:52

标签: linux haskell nix nixos lambdabot

我尝试了什么:

/etc/nixos/configuration.nix中的

  services.lambdabot.enable = true;
  services.lambdabot.script ="
rc /var/lib/lambdabot/.lambdabot/creds.rc
irc-connect twitch irc.chat.twitch.tv 6667 IsoMorpheus Lambda_Robots:_100%_Loyal
admin + twitch:IsoMorpheus
join twitch:#freeman42x";
/var/lib/lambdabot/.lambdabot/creds.rc中的

irc-password oauth:6q9hoi2notaellmugrr3alh9yjx8ua

然后:

nixos-rebuild switch

chown lambdabot /var/lib/lambdabot/.lambdabot/creds.rc

systemctl restart lambdabot

检查HTOP可以看出服务正在运行,但机器人没有连接到IRC频道。

manual的设置:

services.lambdabot.enable

    Enable the Lambdabot IRC bot

    Type: boolean

    Default: false

    Declared by:
    <nixpkgs/nixos/modules/services/networking/lambdabot.nix> 
services.lambdabot.script

    Lambdabot script

    Type: string

    Default: ""

    Declared by:
    <nixpkgs/nixos/modules/services/networking/lambdabot.nix> 

手动启动lambdabot它连接正常,它回复命令:

https://github.com/lambdabot/lambdabot/blob/1d1ed3e7980081c9f356f8d2fd8ca2771c0ed4f4/lambdabot-core/README.md#connecting

有关如何将其作为服务推出的任何建议吗?

1 个答案:

答案 0 :(得分:1)

[root@nixos:/home/neo]# systemctl status lambdabot
● lambdabot.service - Lambdabot daemon
Loaded: loaded (/nix/store/ifwgvglg3vzndk5wssb66vdz9j9rdflf-unit-lambdabot.service/lambdabot.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2018-01-27 23:53:33 EET; 1min 32s ago
Main PID: 4749 (lambdabot-start)
    Tasks: 8 (limit: 4915)
CGroup: /system.slice/lambdabot.service
        ├─4749 /nix/store/jgw8hxx7wzkyhb2dr9hwsd9h2caaasdc-bash-4.4-p12/bin/bash -e /nix/store/0c6ya3n4bz6id840f4gprv3ly24808rn-unit-script/bin/lambdabot-start
        ├─4753 /nix/store/jgw8hxx7wzkyhb2dr9hwsd9h2caaasdc-bash-4.4-p12/bin/bash -e /nix/store/0c6ya3n4bz6id840f4gprv3ly24808rn-unit-script/bin/lambdabot-start
        ├─4754 /nix/store/h0z0pf4ix0ilx5j1x6sk1rfkpjcyjhvc-lambdabot-5.1.0.1/bin/lambdabot
        └─4755 cat /run/lambdabot/offline

Jan 27 23:53:33 nixos systemd[1]: Started Lambdabot daemon.
Jan 27 23:53:37 nixos lambdabot-start[4749]: [WARNING] Plugin.seen: WARNING: failed to read Seen module state: Data.Binary.Get.runGet at position 0: not enough bytes
Jan 27 23:53:37 nixos lambdabot-start[4749]: CallStack (from HasCallStack):
Jan 27 23:53:37 nixos lambdabot-start[4749]:   error, called at libraries/binary/src/Data/Binary/Get.hs:342:5 in binary-0.8.3.0:Data.Binary.Get
Jan 27 23:53:37 nixos lambdabot-start[4749]: Plugin `offlineRC' failed with: /var/lib/lambdabot/.lambdabot/State: createDirectory: permission denied (Permission denied)

问题是我在creds.rc文件而不是整个文件夹上设置了权限,修复:

chown -R lambdabot:users /var/lib/lambdabot/.lambdabot