summaryrefslogtreecommitdiff
path: root/guix/config-thinkpad.scm
diff options
context:
space:
mode:
Diffstat (limited to 'guix/config-thinkpad.scm')
-rw-r--r--guix/config-thinkpad.scm336
1 files changed, 336 insertions, 0 deletions
diff --git a/guix/config-thinkpad.scm b/guix/config-thinkpad.scm
new file mode 100644
index 0000000..e57facc
--- /dev/null
+++ b/guix/config-thinkpad.scm
@@ -0,0 +1,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)))