The world's most clever kitty cat
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve Module

Ben C 97676be4 f788f310

+71 -15
+15 -15
nix/checks/check.nix
··· 1 - { pkgs 2 - , lib 3 - , ... 4 - }: 5 - let 1 + { 2 + pkgs, 3 + lib, 4 + ... 5 + }: let 6 6 ruff = lib.getExe pkgs.ruff; 7 7 src = ./../..; 8 8 in 9 - pkgs.runCommand "bingus-lint" 10 - { 11 - PYTHONPATH = "${pkgs.bingus-env}/lib/python3.12/site-packages"; 12 - RUFF_NO_CACHE = "true"; 13 - } '' 14 - cd ${src}; 9 + pkgs.runCommand "bingus-lint" 10 + { 11 + PYTHONPATH = "${pkgs.bingus}/lib/python3.12/site-packages"; 12 + RUFF_NO_CACHE = "true"; 13 + } '' 14 + cd ${src}; 15 15 16 - ${ruff} format --check 17 - ${ruff} check 16 + ${ruff} format --check 17 + ${ruff} check 18 18 19 - mkdir $out 20 - '' 19 + mkdir $out 20 + ''
+56
nix/nixosModule.nix
··· 1 + { 2 + pkgs, 3 + lib, 4 + config, 5 + ... 6 + }: let 7 + cfg = config.services.bingus-bot; 8 + in { 9 + options.services.bingus-bot = { 10 + enable = lib.mkOption { 11 + type = lib.types.bool; 12 + default = false; 13 + example = true; 14 + description = "Whether to enable Bingus, a Discord bot that uses Markov Chains"; 15 + }; 16 + 17 + tokenFile = lib.mkOption { 18 + default = "/etc/bingus/token"; 19 + type = lib.types.path; 20 + description = "Path to a file containing the bot token that the service will authenticate to Discord with"; 21 + }; 22 + 23 + replyChannels = lib.mkOption { 24 + default = []; 25 + type = lib.types.listOf lib.types.number; 26 + description = "List of Discord channel IDs that the bot should have a chance to reply in"; 27 + }; 28 + }; 29 + 30 + config = lib.mkIf cfg.enable { 31 + systemd.services.bingus = let 32 + replyChannelsStr = lib.strings.concatStrings (lib.strings.intersperse "," (builtins.map builtins.toString cfg.replyChannels)); 33 + in { 34 + wantedBy = ["multi-user.target"]; 35 + after = ["network.target"]; 36 + 37 + environment.REPLY_CHANNELS = replyChannelsStr; 38 + 39 + script = '' 40 + export TOKEN=$(cat "$CREDENTIALS_DIRECTORY/BINGUS_BOT_TOKEN") 41 + export BRAIN_FILE=$XDG_STATE_HOME/brain.msgpackz 42 + ${pkgs.bingus}/bin/bingus 43 + ''; 44 + 45 + serviceConfig = { 46 + Restart = "always"; 47 + RestartSec = "5s"; 48 + User = "bingus-bot"; 49 + Group = "bingus-bot"; 50 + StateDirectory = "bingus"; 51 + DynamicUser = true; 52 + LoadCredential = "BINGUS_BOT_TOKEN:${cfg.tokenFile}"; 53 + }; 54 + }; 55 + }; 56 + }