summaryrefslogtreecommitdiff
path: root/johnlepikhin/system
diff options
context:
space:
mode:
authorEvgenii Lepikhin <e.lepikhin@corp.mail.ru>2023-02-04 09:57:47 +0300
committerEvgenii Lepikhin <e.lepikhin@corp.mail.ru>2023-02-04 09:58:06 +0300
commitbdf2bd5d35ed3c11658abf7f3f7a4b3b58075ec8 (patch)
treed25a41edec91c4cd2957a72354d0da2909911b56 /johnlepikhin/system
parentfeat: Added adb (diff)
downloadjohnlepikhin-guix-channel-bdf2bd5d35ed3c11658abf7f3f7a4b3b58075ec8.tar.gz
fix: feat: Added common system config
Diffstat (limited to 'johnlepikhin/system')
-rw-r--r--johnlepikhin/system/os.scm94
-rw-r--r--johnlepikhin/system/packages.scm38
-rw-r--r--johnlepikhin/system/services.scm226
3 files changed, 358 insertions, 0 deletions
diff --git a/johnlepikhin/system/os.scm b/johnlepikhin/system/os.scm
new file mode 100644
index 0000000..fa9c1d9
--- /dev/null
+++ b/johnlepikhin/system/os.scm
@@ -0,0 +1,94 @@
+;;; 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 os)
+ #:use-module (nongnu packages linux)
+ #:use-module (nongnu system linux-initrd)
+ #:use-module (gnu)
+ #:use-module (gnu system)
+ #:use-module (gnu system locale)
+ #:use-module (gnu system keyboard)
+ #:use-module (gnu system locale)
+ #:use-module (gnu system pam)
+ #:use-module (gnu system nss)
+ #:use-module (guix channels)
+ #:export (make-desktop-operating-system))
+
+(define* (make-desktop-operating-system
+ #:key
+ cryptroot-uuid
+ efi-uuid
+ hostname
+ users
+ services
+ packages
+ (linux-kernel linux-lts)
+ (timezone "Europe/Moscow"))
+ (operating-system
+ (kernel linux-kernel)
+ (kernel-arguments '("modprobe.blacklist=pcspkr,snd_pcsp"))
+ (initrd microcode-initrd)
+ (firmware
+ (list
+ sof-firmware
+ linux-firmware
+ realtek-firmware
+ iwlwifi-firmware
+ amdgpu-firmware
+ radeon-firmware
+ ibt-hw-firmware
+ i915-firmware
+ intel-microcode
+ amd-microcode))
+
+ (locale "en_US.utf8")
+ (locale-definitions
+ (list (locale-definition (source "en_US")
+ (name "en_US.UTF-8"))
+ (locale-definition (source "ru_RU")
+ (name "ru_RU.UTF-8"))))
+ (timezone timezone)
+ (keyboard-layout (keyboard-layout "us" "altgr-intl"))
+ (host-name hostname)
+ (users users)
+ (packages packages)
+ (services services)
+ ;; resolve .local hostnames with mDNS
+ (name-service-switch %mdns-host-lookup-nss)
+ (bootloader
+ (bootloader-configuration
+ (bootloader grub-efi-bootloader)
+ (targets (list "/boot/efi"))
+ (keyboard-layout keyboard-layout)))
+ (mapped-devices
+ (list (mapped-device
+ (source
+ (uuid cryptroot-uuid))
+ (target "cryptroot")
+ (type luks-device-mapping))))
+ (file-systems
+ (cons* (file-system
+ (mount-point "/boot/efi")
+ (device (uuid efi-uuid 'fat32))
+ (type "vfat"))
+ (file-system
+ (mount-point "/")
+ (device "/dev/mapper/cryptroot")
+ (type "ext4")
+ (dependencies mapped-devices))
+ %base-file-systems))))
diff --git a/johnlepikhin/system/packages.scm b/johnlepikhin/system/packages.scm
new file mode 100644
index 0000000..5d480a6
--- /dev/null
+++ b/johnlepikhin/system/packages.scm
@@ -0,0 +1,38 @@
+;;; 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 packages)
+ #:use-module (gnu system)
+ #:use-module (gnu packages networking)
+ #:use-module (gnu packages gnome)
+ #:use-module (gnu packages linux)
+ #:use-module (gnu packages admin)
+ #:use-module (gnu packages certs)
+ #:export (system-packages))
+
+(define system-packages
+ (cons*
+ network-manager-openvpn
+ net-tools
+ bluez
+ macchanger
+ wireshark
+ tcpdump
+ hostapd
+ powertop
+ %base-packages))
diff --git a/johnlepikhin/system/services.scm b/johnlepikhin/system/services.scm
new file mode 100644
index 0000000..72b1ee1
--- /dev/null
+++ b/johnlepikhin/system/services.scm
@@ -0,0 +1,226 @@
+;;; 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 services)
+ #:use-module (gnu services networking)
+ #:use-module (gnu services databases)
+ #:use-module (gnu services desktop)
+ #:use-module (gnu services mcron)
+ #:use-module (gnu services pm)
+ #:use-module (gnu services linux)
+ #:use-module (gnu services base)
+ #:use-module (gnu services ssh)
+ #:use-module (gnu services virtualization)
+ #:use-module (gnu services dns)
+ #:use-module (gnu services cups)
+ #:use-module (gnu services shepherd)
+ #:use-module (gnu services admin)
+ #:use-module (gnu services avahi)
+ #:use-module (gnu services dbus)
+ #:use-module (gnu services xorg)
+ #:use-module (gnu services sound)
+ #:use-module (gnu packages databases)
+ #:use-module (gnu packages gnome)
+ #:use-module (gnu packages networking)
+ #:use-module (gnu packages cups)
+ #:use-module (gnu packages xorg)
+ #:use-module (guix gexp)
+ #: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
+ (postgresql postgresql-10)
+ (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")))))))
+
+(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")
+ (requirement '(xorg-server))
+ (one-shot? #t)
+ (start #~(lambda _ (chmod "/sys/class/backlight/intel_backlight/brightness" #o666))))))
+
+(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
+ shepherd-root-service-type
+ public-backlight-brightness-service)))))
+
+(define guix-pull-job
+ #~(job "30 5 * * *"
+ "guix pull"))
+
+(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)))
+ (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))))
+ (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 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")))
+
+ tuned-desktop-services))