;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2022 ( ;;; ;;; This file is part of GNU Guix. ;;; ;;; GNU Guix is free software; you can redistribute it and/or modify it ;;; under the terms of the GNU General Public License as published by ;;; the Free Software Foundation; either version 3 of the License, or (at ;;; your option) any later version. ;;; ;;; GNU Guix is distributed in the hope that it will be useful, but ;;; WITHOUT ANY WARRANTY; without even the implied warranty of ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ;;; GNU General Public License for more details. ;;; ;;; You should have received a copy of the GNU General Public License ;;; along with GNU Guix. If not, see . (define-module (gnu home services irc) #:use-module (gnu home services) #:use-module (guix gexp) #:use-module (guix packages) #:use-module (guix records) #:use-module (srfi srfi-1) #:use-module (srfi srfi-26) #:export (home-senpai-service-type home-senpai-configuration)) ;;; Commentary: ;;; ;;; This module contains home services for Internet Relay Chat. ;;; ;;; Code: ;;; ;;; Senpai. ;;; (define-record-type* home-senpai-configuration make-home-senpai-configuration home-senpai-configuration? (address home-senpai-address) ;string (nickname home-senpai-nickname) ;string (username home-senpai-username ;string | #f (default #f)) (realname home-senpai-realname ;string | #f (default #f)) (password home-senpai-password) ;string | file-like, list of string (channels home-senpai-channels ;list of string | #f (default #f)) (highlight-words home-senpai-highlight-words ;list of string | #f (default #f)) (highlight-beep? home-senpai-highlight-beep? ;boolean (default #f)) (highlight-script home-senpai-highlight-script ;file-like | #f (default #f)) (nicknames-width home-senpai-nicknames-width ;integer (default 14)) (channels-width home-senpai-channels-width ;integer (default 16)) (members-width home-senpai-members-width ;integer (default 16)) (message-width home-senpai-message-width ;integer (default 0)) (tls? home-senpai-tls? ;boolean (default #t)) (typing-notify? home-senpai-typing-notify? ;boolean (default #t)) (mouse? home-senpai-mouse? ;boolean (default #t)) (prompt-color home-senpai-prompt-color ;integer | string (default -1)) (unread-color home-senpai-unread-color ;integer | string (default -1)) (debug? home-senpai-debug? ;boolean (default #f))) (define (home-senpai-xdg-configuration-files config) (define (string-field name field) (let ((value (field config))) (if value (list name " \"" value "\"\n") '()))) (define (string-list-field name field) (let ((value (field config))) (if value (append (list name) (concatenate (map (cute list " \"" <> "\"") value)) (list "\n")) '()))) (define (integer-field name field) (let ((value (field config))) (if value (list name " " (number->string value) "\n") '()))) (define (colour-field name field) (let ((value (field config))) (if (string? value) (string-field name (compose (cute string-append "#" <>) field)) (integer-field name field)))) (define (boolean-field name field) (let ((value (field config))) (list name " " (if value "true" "false") "\n"))) (define (symbol-field name field) (string-field name (compose symbol->string field))) (define* (record-field name #:rest fields) (append (list name " {\n") (concatenate fields) (list "}\n"))) `(("senpai/sen.scfg" ,(apply mixed-text-file "senpai.scfg" (append (string-field "address" home-senpai-address) (string-field "nickname" home-senpai-nickname) (string-field "username" home-senpai-username) (string-field "realname" home-senpai-realname) (if (list? (home-senpai-password config)) (string-list-field "password-cmd" home-senpai-password) (string-field "password" home-senpai-password)) (string-list-field "channel" home-senpai-channels) (string-list-field "highlight" home-senpai-highlight-words) (boolean-field "on-highlight-beep" home-senpai-highlight-beep?) (string-field "on-highlight-path" home-senpai-highlight-script) (record-field "pane-widths" (integer-field "nicknames" home-senpai-nicknames-width) (integer-field "channels" home-senpai-channels-width) (integer-field "members" home-senpai-members-width) (integer-field "text" home-senpai-message-width)) (boolean-field "tls" home-senpai-tls?) (boolean-field "typings" home-senpai-typing-notify?) (boolean-field "mouse" home-senpai-mouse?) (record-field "colors" (colour-field "prompt" home-senpai-prompt-color) (colour-field "unread" home-senpai-unread-color)) (boolean-field "debug" home-senpai-debug?)))))) (define home-senpai-service-type (service-type (name 'home-senpai) (extensions (list (service-extension home-xdg-configuration-files-service-type home-senpai-xdg-configuration-files))) (description "Configure senpai, a terminal-based IRC client designed for use with bouncers.")))