我试过的:
在/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可以看到服务正在运行,但bot未连接到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可以连接fine并回复命令:
https://github.com/lambdabot/lambdabot/blob/1d1ed3e7980081c9f356f8d2fd8ca2771c0ed4f4/lambdabot-core/README.md#connecting
关于如何将其作为一项服务推出,有什么建议吗?

最佳答案

[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

关于linux - 在NixOS上将twitch lambdabot配置为服务,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/48477392/

10-15 19:18