1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
| | ;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2022 ( <paren@disroot.org>
;;;
;;; 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 <http://www.gnu.org/licenses/>.
(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:
\f
;;;
;;; Senpai.
;;;
(define-record-type* <home-senpai-configuration>
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.")))
|