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
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
|
;; -*- geiser-scheme-implementation: guile -*-
(use-modules (gnu)
(gnu packages)
(srfi srfi-1))
(use-service-modules
desktop
databases
networking
ssh
xorg
docker
virtualization
dbus
linux
pm
vpn
nix)
(use-package-modules
wm
lisp
bash
linux
python
gnome
gawk
xorg
xdisorg)
;; (define-public linux-libre-custom
;; (package
;; (inherit linux-libre)
;; (native-inputs
;; `(("kconfig" ,(local-file "fb.config"))
;; ,@(alist-delete "kconfig"
;; (package-native-inputs linux-libre))))))
(define %cpupower-service
(simple-service
'cpupower activation-service-type
#~(zero? (system* #$(file-append cpupower "/bin/cpupower")
"frequency-set" "--governor" "schedutil"))))
(define %x86-energy-perf-policy-service
(simple-service
'x86-energy-perf-policy-service activation-service-type
#~(zero? (system* #$(file-append x86-energy-perf-policy "/bin/x86_energy_perf_policy")
"--turbo-enable" "0"
"--hwp-desired" "16"))))
(define %thinkfan-service
(simple-service
'thinkfan activation-service-type
#~(zero? (system* #$(file-append thinkfan "/sbin/thinkfan")))))
(define i915-config
(plain-file "i915.conf"
"options i915 enable_fbc=1 enable_dc=0 modeset=1 enable_psr=0"))
(define drm-kms-config
(plain-file "drm_kms.conf"
"options drm_kms_helper poll=N"))
(define thinkpad-acpi-config
(plain-file "thinkpad_acpi.conf"
"options thinkpad_acpi fan_control=1"))
;; tp_thermal /proc/acpi/ibm/thermal
(define thinkfan-config
(plain-file "thinkfan.conf"
"\
hwmon /sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp3_input
hwmon /sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp5_input
hwmon /sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp1_input
hwmon /sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp4_input
hwmon /sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp6_input
hwmon /sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp7_input
hwmon /sys/devices/platform/thinkpad_hwmon/hwmon/hwmon4/temp8_input
hwmon /sys/devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/hwmon/hwmon1/temp1_input
hwmon /sys/devices/pci0000:00/0000:00:1f.2/ata2/host1/target1:0:0/1:0:0:0/hwmon/hwmon2/temp1_input
# hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon6/temp3_input
# hwmon /sys/devices/platform/coretemp.0/hwmon/hwmon6/temp2_input
hwmon /sys/devices/virtual/thermal/thermal_zone0/hwmon0/temp1_input
hwmon /sys/devices/virtual/thermal/thermal_zone0/hwmon0/temp2_input
tp_fan /proc/acpi/ibm/fan
(0, 0, 35)
(1, 30, 40)
(2, 35, 50)
(3, 45, 60)
(4, 55, 65)
(5, 60, 70)
(6, 65, 75)
(7, 70, 85)
(\"level full-speed\", 78, 120)"))
(define fancontrol-config
(plain-file "fancontrol"
"
INTERVAL=10
DEVPATH=hwmon0=devices/virtual/thermal/thermal_zone0 hwmon1=devices/platform/thinkpad_hwmon
DEVNAME=hwmon0=acpitz hwmon5=thinkpad
FCTEMPS=hwmon1/pwm1=hwmon0/temp1_input
FCFANS= hwmon1/pwm1=hwmon5/fan1_input
MINTEMP=hwmon1/pwm1=20
MAXTEMP=hwmon1/pwm1=50
MINSTART=hwmon1/pwm1=150
MINSTOP=hwmon1/pwm1=50
MINPWM=hwmon1/pwm1=10"))
(operating-system
(locale "ru_RU.utf8")
(timezone "Europe/Tbilisi")
(keyboard-layout
(keyboard-layout
"us,ru"
#:options
'("grp:shifts_toggle"
"caps:ctrl_modifier")))
;; (kernel linux-libre-5.19)
;; (kernel-loadable-modules '(acpi-call-linux-module))
(kernel-arguments
'("consoleblank=0"
;; "processor.max_cstate=3" ; Disable power savings
;; "intel_idle.max_cstate=0" ; (cstate 3-4 provides
;; ; high freq cpu noice)
"vblank_mode=0"
;;"vm.swappiness=5"
"thinkpad_acpi.fan_control=1"
"acpi_sleep=s3_bios"
"acpi_osi=Linux"
"i915.modeset=1"
;; "i915.enable_dc=0"
;; "i915.enable_psr=0"
"rootfstype=ext4"
"KVM"
"loglevel=7"
;;"logo"
"ahci.mobile_lpm_policy=1"
"intremap=off" ; Fix for failed to map dmar2
"modprobe.blacklist=pcspkr,usbmouse,usbkbd,glx"))
(host-name "w96k-x200t")
(users
(cons*
(user-account
(name "w96k")
(comment "Mikhail Kirillov")
(group "users")
(home-directory "/home/w96k")
(supplementary-groups
'("wheel" "netdev" "audio" "video" "kvm" "docker")))
%base-user-accounts))
(packages
(append
(map
specification->package
'("xterm"
"xinit"
"xorg-server"
"font-gnu-unifont"
"font-gnu-freefont"
"mesa"
"mesa-utils"
"ratpoison"
"wmname"
"windowmaker"
"nss-certs"
"docker-compose"
"thinkfan"
"cpupower"
"lm-sensors"
"x86-energy-perf-policy"
"git"
"stow"
"lm-sensors"
"xset"
"cpuid"
;; Video Codecs stuff
"gstreamer"
"gst-plugins-base"
"gst-plugins-good"
"gst-plugins-bad"
"gst-plugins-ugly"
"gst-libav"
;; "intel-vaapi-driver-g45-h264"
"libva-utils"
"igt-gpu-tools"
;; Xorg
"xev"
"xset"
"xrdb"
"xhost"
"xmodmap"
"setxkbmap"
"xrandr"
"arandr"
"xss-lock"
"libinput"
"xinput"
"xf86-input-libinput"
;; "xf86-video-fbdev"
"xf86-video-intel"
"qemu"))
%base-packages))
(services
(cons*
(service docker-service-type)
(service thermald-service-type)
(service virtlog-service-type)
(service libvirt-service-type
(libvirt-configuration (unix-sock-group "libvirt")))
(service openssh-service-type)
(service tor-service-type)
;;Wacom tablet support
(service inputattach-service-type
(inputattach-configuration
(device "/dev/ttyS4")
(device-type "wacom")))
(service kernel-module-loader-service-type
'("thinkpad_acpi"
"msr"
"coretemp"
"acpi_cpufreq"
"overlay"))
(simple-service 'thinkpad-acpi-config etc-service-type
(list `("modprobe.d/thinkpad_acpi.conf"
,thinkpad-acpi-config)))
;; (simple-service 'fancontrol-config etc-service-type
;; (list `("fancontrol"
;; ,fancontrol-config)))
;; (simple-service 'thinkfan-config etc-service-type
;; (list `("thinkfan.conf"
;; ,thinkfan-config)))
(simple-service 'i915-config etc-service-type
(list `("modprobe.d/i915.conf"
,i915-config)))
(simple-service 'drm-kms-config etc-service-type
(list `("modprobe.d/drm_kms.conf"
,drm-kms-config)))
;; (service openvpn-client-service-type
;; (openvpn-client-configuration
;; (persist-tun? #t)
;; (remote
;; (list
;; (openvpn-remote-configuration
;; (name "nyc.vpn.riseup.net")
;; (port 1196))))))
(service special-files-service-type
`(("/bin/bash" ,(file-append bash "/bin/bash"))
("/bin/python" ,(file-append python "/bin/python3"))
("/bin/python3" ,(file-append python "/bin/python3"))
("/bin/awk" ,(file-append gawk "/usr/bin/awk"))
("/usr/bin/awk" ,(file-append gawk "/usr/bin/awk"))
("/lib64/ld-linux-x86-64.so.2"
,(file-append (canonical-package glibc)
"/lib/ld-linux-x86-64.so.2"))))
(service nix-service-type
(nix-configuration
(extra-config '("trusted-users = root w96k"))))
(service postgresql-service-type)
%cpupower-service
;; Doesn't start on boot sadly :(
%thinkfan-service
%x86-energy-perf-policy-service
(screen-locker-service xlockmore "xlock")
;; (service xorg-server-service-type
;; (xorg-configuration
;; (keyboard-layout keyboard-layout)))
;; (service hurd-vm-service-type
;; (hurd-vm-configuration
;; (disk-size (* 8 (expt 2 30))) ;12GiB
;; (memory-size 1024)))
(service slim-service-type
(slim-configuration
(xorg-configuration
(xorg-configuration
(drivers '("modesetting"))
(keyboard-layout keyboard-layout)))))
(modify-services %desktop-services
(delete gdm-service-type))))
(bootloader
(bootloader-configuration
(bootloader grub-bootloader)
(target "/dev/sda")
(keyboard-layout keyboard-layout)))
(swap-devices
(list
(swap-space
(target "/dev/sda1"))))
(file-systems
(cons*
(file-system
(mount-point "/")
(device
(uuid "c184f446-df67-4103-b28e-465ac8776f10"
'ext4))
(type "ext4")
(options "discard"))
;; Thinkpad doc HDD
;;(file-system
;;(mount-point "/media/hdd/")
;;(device
;; (uuid "71cb0818-baf3-4f7f-8bc2-7e2b0cca3488"
;; 'ext4))
;; (type "ext4"))
%base-file-systems)))
|