blob: 7959b514737618b7631b814c8afca7a5225c2b43 (
about) (
plain)
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
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
|
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2023 Evgenii Lepikhin <johnlepikhin@gmail.com>
;;;
;;; This file is not 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 (johnlepikhin system services)
#:use-module (gnu packages cups)
#:use-module (gnu packages databases)
#:use-module (gnu packages gnome)
#:use-module (gnu packages linux)
#:use-module (gnu packages geo)
#:use-module (gnu packages networking)
#:use-module (gnu packages xorg)
#:use-module (gnu services admin)
#:use-module (gnu services authentication)
#:use-module (gnu services avahi)
#:use-module (gnu services base)
#:use-module (gnu services cups)
#:use-module (gnu services databases)
#:use-module (gnu services dbus)
#:use-module (gnu services desktop)
#:use-module (gnu services dns)
#:use-module (gnu services docker)
#:use-module (gnu services linux)
#:use-module (gnu services mcron)
#:use-module (gnu services networking)
#:use-module (gnu services pm)
#:use-module (gnu services shepherd)
#:use-module (gnu services sound)
#:use-module (gnu services ssh)
#:use-module (gnu services virtualization)
#:use-module (gnu services xorg)
#:use-module (gnu services)
#:use-module (guix gexp)
#:use-module (srfi srfi-1)
#:export (make-system-services
postgresql-dev-service))
(define nonguix-signing-key
"(public-key
(ecc
(curve Ed25519)
(q #C1FD53E5D4CE971933EC50C9F307AE2171A2D3B52C804642A7A35F84F3A4EA98#)
))")
(define bordeaux-signing-key
"(public-key
(ecc
(curve Ed25519)
(q #7D602902D3A2DBB83F8A0FB98602A754C5493B0B778C8D1DD4E0F41DE14DE34F#)
))")
(define-public postgresql-dev-service
(service postgresql-service-type
(postgresql-configuration
;; PostGIS compiled for PostgreSQL 14
(postgresql postgresql-14)
(extension-packages (list postgis))
(config-file
(postgresql-config-file
(log-destination "stderr")
(hba-file
(plain-file "pg_hba.conf"
"
local all all trust
host all all 127.0.0.1/32 md5
host all all ::1/128 md5")
("work_mem" "500 MB")
("max_parallel_workers_per_gather" "6")))))))
(define-public tuned-desktop-services
(cons*
(modify-services
%desktop-services
;; (delete gdm-service-type)
(pulseaudio-service-type
config =>
(pulseaudio-configuration
(client-conf '((autospawn . no)))))
(guix-service-type
config =>
(guix-configuration
(inherit config)
(substitute-urls
(list
"https://substitutes.nonguix.org"
"https://ci.guix.gnu.org"
"https://bordeaux.guix.gnu.org/"))
(discover? #t)
(authorized-keys
(append
(list
(plain-file "non-guix.pub" nonguix-signing-key)
(plain-file "bordeaux.guix.gnu.org.pub" bordeaux-signing-key))
%default-authorized-guix-keys))))
(upower-service-type
config =>
(upower-configuration
(inherit config)
;; уходить в сон когда батарейки осталось на 10 минут
(time-action 600)))
(elogind-service-type
config =>
(elogind-configuration
(inherit config)
(handle-power-key 'suspend)
(handle-lid-switch-external-power 'suspend)
(handle-lid-switch 'suspend)))
(network-manager-service-type
config => (network-manager-configuration
(inherit config)
(dns "dnsmasq")
(vpn-plugins
(list network-manager-openvpn))))
(avahi-service-type
config =>
(avahi-configuration
(ipv6? #f))))))
(define (public-backlight-brightness-service _)
(list (shepherd-service
(provision '(public-backlight-brightness))
(documentation "Grant R/W to /sys/class/backlight/*/brightness for all users")
(one-shot? #t)
(start #~(lambda _ (system "/run/current-system/profile/bin/chmod 666 /sys/class/backlight/*/brightness"))))))
(define (add-brightnessctl-package config)
(list brightnessctl))
(define public-backlight-brightness-service-type
(service-type
(name 'public-backlight-brightness)
(description "Grant R/W to /sys/class/backlight/*/brightness for all users")
(extensions
(list
(service-extension
profile-service-type add-brightnessctl-package)
(service-extension
shepherd-root-service-type public-backlight-brightness-service)))))
(define guix-pull-job
#~(job "30 5 * * *"
"guix pull"))
(define guix-gc-job
#~(job "30 4 * * *"
"guix gc -F 30G"))
;; trim free blocks on SSD
(define fstrim-job
#~(job "40 2 * * *" "fstrim -v /"))
(define* (make-system-services
#:key
(zram-size "2G"))
(cons*
(set-xorg-configuration
(xorg-configuration
(modules (cons xf86-input-synaptics %default-xorg-modules))))
(service gnome-desktop-service-type)
(service openssh-service-type)
(service bluetooth-service-type
(bluetooth-configuration
(auto-enable? #t)
(experimental #t)
(fast-connectable? #t)))
(simple-service 'dbus-extras
dbus-root-service-type
(list blueman))
(service unattended-upgrade-service-type
(unattended-upgrade-configuration
(schedule "30 02 * * */3")))
(service public-backlight-brightness-service-type '())
(service hostapd-service-type
(hostapd-configuration
(interface "wlan0_API")
(ssid "My Network")
(channel 12)))
(service tlp-service-type
(tlp-configuration
(cpu-scaling-governor-on-ac (list "performance"))
(cpu-scaling-governor-on-bat (list "powersave"))
(sched-powersave-on-bat? #f)
(cpu-boost-on-ac? #t)
(max-lost-work-secs-on-bat 180)
(cpu-scaling-min-freq-on-bat (* 400 1000))
(cpu-scaling-max-freq-on-bat (* 800 1000))
(cpu-scaling-min-freq-on-ac (* 2300 1000))
(cpu-scaling-max-freq-on-ac (* 4500 1000))))
(service mcron-service-type
(mcron-configuration
(jobs
(list
guix-pull-job
guix-gc-job
fstrim-job))))
(service cups-service-type
(cups-configuration
(default-language "en")
(web-interface? #t)
(extensions
(list cups-filters brlaser hplip foo2zjs foomatic-filters))))
(service zram-device-service-type
(zram-device-configuration
(size zram-size)
(compression-algorithm 'zstd)))
(service libvirt-service-type
(libvirt-configuration
(unix-sock-group "libvirt")))
(service virtlog-service-type)
(service openvswitch-service-type)
(service qemu-binfmt-service-type
(qemu-binfmt-configuration
(platforms
(fold delete %qemu-platforms
(lookup-qemu-platforms "i386" "x86_64")))))
(service guix-publish-service-type
(guix-publish-configuration
(host "0.0.0.0")
(port 3000)
(advertise? #t) ;advertise using Avahi.
(cache #f)
(ttl #f)))
(service earlyoom-service-type
(earlyoom-configuration
(prefer-regexp "(cc1(plus)?|.rustc-real|ghc|Web Content|rust-analyzer)")
(avoid-regexp "xmonad")))
(service docker-service-type)
;; (service fprintd-service-type)
tuned-desktop-services))
|