config.scm 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340
  1. (add-to-load-path "/home/ton/guixsd/modules/")
  2. (setenv "GUIX_PACKAGE_PATH" "/home/ton/guixsd/modules/:$GUIX_PACKAGE_PATH")
  3. (use-modules
  4. (gnu)
  5. (gnu system)
  6. (gnu system nss)
  7. (gnu packages libusb)
  8. (guix monads)
  9. (guix store)
  10. (ice-9 rdelim)
  11. (srfi srfi-1)
  12. (linux-libre)
  13. ;; (i3-battery-warning)
  14. ;(cronjobs)
  15. )
  16. (use-service-modules
  17. desktop base xorg ssh avahi dbus networking cups mcron virtualization
  18. web pm nfs)
  19. (use-package-modules
  20. avahi xorg certs wm code wget admin emacs tmux
  21. ssh linux disk file gnuzilla version-control maths guile crypto gnupg
  22. password-utils rsync suckless gnome video xdisorg
  23. terminals ssh image-viewers web-browsers pulseaudio
  24. tex tor readline adns fontutils gnunet package-management
  25. networking connman lisp cryptsetup fonts python
  26. bittorrent engineering graphviz shells compression
  27. gnome enlightenment dns ghostscript kde-frameworks bash backup nfs)
  28. (define quercus-ip "192.168.10.42")
  29. (define (backup-home user)
  30. #~(let ((borg (string-append #$borg "/bin/borg"))
  31. (home (format #f "/home/~a" #$user)))
  32. (system*
  33. borg "--verbose" "-p"
  34. "create"
  35. "--exclude-caches"
  36. "--exclude" (format #f "~a/.cache/*" home)
  37. "--one-file-system"
  38. "--stats" "--list"
  39. "/mnt/borg::{hostname}-{utcnow}"
  40. home)
  41. (system*
  42. borg "--verbose" "-p"
  43. "prune"
  44. "--list"
  45. "--prefix" "{hostname}-"
  46. "--keep-within=1w"
  47. "--keep-daily=7"
  48. "--keep-weekly=4"
  49. "--keep-monthly=6"
  50. "/mnt/borg")))
  51. ;; test like
  52. ;; ,use (guix monad-repl)
  53. ;; ,enter-store-monad
  54. ;; (gexp->script "test" (backup-home "alex"))
  55. ;; ;; and note what the derivation produces. That's the script to run.
  56. ;; (mlet %store-monad ((script (gexp->script "test" (backup-home "alex"))))
  57. ;; (built-derivations (list script)))
  58. ;; then, run the script to do a manual backup.
  59. (define (backup-home-job)
  60. #~(job '(next-hour '(18))
  61. #$(backup-home "ton")
  62. #:user "ton"))
  63. (define battery-check-job
  64. #~(job '(next-minute '(5))
  65. (use-modules ((i3-battery-warning) #:prefix i3-battery-warning:))
  66. "i3-battery-warning:check&react"
  67. #:user "ton"
  68. "Checks battery and notifies user if power is needed"))
  69. (define updatedb-job
  70. ;; Run 'updatedb' at 3AM every day. Here we write the
  71. ;; job's action as a Scheme procedure.
  72. #~(job '(next-hour '(3))
  73. (lambda ()
  74. (execl (string-append #$findutils "/bin/updatedb")
  75. "updatedb"
  76. "--prunepaths=/tmp /var/tmp /gnu/store"))))
  77. ;(define tor-socket-check-job
  78. ;; Ensure that /var/run/tor/ exists and is owned by tor.
  79. ; #~(job '(next-hour)
  80. ; (lambda () ;; unless(not test)/when(test)?
  81. ; (unless (file-exists? "/var/run/tor")
  82. ; (mkdir "/var/run/tor" #o770)
  83. ; (chown "/var/run/tor" "tor" "tor")))))
  84. ;; Check? WTF!? Switch to python? or BASH? or wat? dis is silly.
  85. (define wake-up-job
  86. ;; Run music to wake me up.
  87. #~(job "03 45 * * *"
  88. (lambda ()
  89. (execl (string-append #$mpv "/bin/mpv")
  90. "mpv"
  91. "/home/ton/disk/music/electroswing/*"))))
  92. (define-public %ton-cronjobs (list updatedb-job
  93. ;;wake-up-job
  94. battery-check-job
  95. ;;backup-home-job ;; <- causes system build to fail...
  96. ))
  97. ;(define hp-laptop-monitor-settings
  98. ; (call-with-input-file "/home/ton/guixsd/dotfiles/etc/X11/xorg.conf.d/90-monitor.conf" read-string))
  99. ;(define mbp-trackpad-settings
  100. ; (call-with-input-file "/home/ton/guixsd/dotfiles/etc/X11/xorg.conf.d/60-mtrack.conf" read-string))
  101. (define (remove-services types services)
  102. (remove (lambda (service)
  103. (any (lambda (type)
  104. (eq? (service-kind service) type))
  105. types))
  106. services))
  107. (define ton-desktop-services
  108. (remove-services (list network-manager-service-type) ; upower-service-type)
  109. %desktop-services))
  110. ; (remove (lambda (service)
  111. ; (eq? (service-kind service) network-manager-service-type upower-service-type))
  112. ; %desktop-services))
  113. ;;network-manager-service-type
  114. (operating-system
  115. (host-name "merlin")
  116. (timezone "Europe/Oslo")
  117. (locale "en_US.UTF-8")
  118. (kernel linux-libre-4.14)
  119. (bootloader (bootloader-configuration
  120. (bootloader grub-efi-bootloader)
  121. (target "/boot/efi")))
  122. (kernel-arguments '("syscall.x32=y"
  123. "acpi_backlight=vendor"))
  124. (swap-devices '("/swapfile"))
  125. (file-systems (cons* (file-system
  126. (device (file-system-label "root"))
  127. (mount-point "/")
  128. (type "ext4"))
  129. (file-system
  130. (device (file-system-label "BOOT"))
  131. ;;(device (uuid "7A92-BDAA"))
  132. ; (title 'uuid)
  133. (mount-point "/boot/efi")
  134. (type "vfat"))
  135. (file-system
  136. (device (string-append quercus-ip ":/"))
  137. (mount-point "/home/ton/quercus-home/")
  138. (type "nfs")
  139. (mount? #f)
  140. (create-mount-point? #t))
  141. %base-file-systems))
  142. (issue "Mercury.\n")
  143. (users (list (user-account
  144. (name "ton")
  145. (comment "El brownie de casa Merlin")
  146. (group "users")
  147. (shell #~(string-append #$bash "/bin/bash"))
  148. (supplementary-groups '("wheel" "netdev" "audio" "video"
  149. "avahi" "tor"
  150. "users" "kvm" "input"
  151. ;;"libvirt"
  152. "lp" "lpadmin"
  153. ))
  154. (home-directory "/home/ton"))))
  155. ;;; Maybe use or adapt alezost-guile al/places.scm?
  156. ;;; Add visudo check into sudoers-file PROC - patch into GuixSD?
  157. (sudoers-file (local-file "/home/ton/guixsd/dotfiles/etc/sudoers"))
  158. (hosts-file (local-file "/home/ton/guixsd/dotfiles/etc/hosts"))
  159. (setuid-programs (cons*
  160. #~(string-append #$wireshark "/bin/dumpcap")
  161. %setuid-programs))
  162. (packages
  163. (cons* ;desktop environment scrot is "necessary" for i3lock-fancy
  164. i3-wm i3status i3lock-fancy scrot hicolor-icon-theme
  165. ;useful tools
  166. avahi zip unzip tmux htop tree mosh mcron
  167. the-silver-searcher psmisc wget file strace
  168. inotify-tools wgetpaste rsync dmenu openssh lsh
  169. feh stow mcelog readline libcap wcalc graphviz xdotool
  170. sudo
  171. ;; gvfs ; for automounting as user, check gvfsd as a service before
  172. ;; enabling
  173. ; fstools
  174. dosfstools nfs-utils
  175. ; X
  176. xbindkeys xterm xmodmap setxkbmap xclip xkill xbacklight
  177. xev xdpyinfo xrdb xrandr xfontsel gs-fonts
  178. ; audio
  179. pulseaudio pulsemixer
  180. ; laptop specific
  181. acpi cpupower ;;(TODO:cpupower... wat?)
  182. ; dev
  183. gnu-make python-3 binutils
  184. guile-lib
  185. ; misc tools
  186. units gnuplot
  187. ; terminals and emulators
  188. st termite xonsh fish bash
  189. ; Networking, crypto & security
  190. ;;tomb
  191. gnupg pwgen tor torsocks nmap adns iodine
  192. connman transmission pinentry pinentry-gtk2
  193. ;; password-store?
  194. ;;gnunet gnunet-gtk
  195. ;;isc-bind:utils
  196. ;;onionshare
  197. ;for HTTPS access
  198. nss-certs
  199. ; emacs
  200. emacs emacs-guix emacs-magit-popup emacs-smart-mode-line
  201. emacs-rainbow-delimiters emacs-rainbow-identifiers
  202. emacs-scheme-complete emacs-neotree emacs-ag flycheck
  203. emacs-undo-tree emacs-fill-column-indicator
  204. emacs-yasnippet emacs-yasnippet-snippets
  205. emacs-scheme-complete emacs-danneskjold-theme
  206. geiser guile-2.2 paredit emacs-debbugs
  207. %base-packages))
  208. (services
  209. (cons*
  210. (console-keymap-service "us")
  211. (service cups-service-type
  212. (cups-configuration
  213. (web-interface? #t)
  214. (browsing? #t)
  215. (default-paper-size "a4")))
  216. (service connman-service-type
  217. (connman-configuration
  218. (disable-vpn? #f)))
  219. ;; (service wpa-supplicant-service-type wpa-supplicant)
  220. (tor-service (local-file "/home/ton/guixsd/dotfiles/etc/tor/torrc"))
  221. ; (service libvirt-service-type
  222. ; (libvirt-configuration
  223. ; (unix-sock-group "libvirt")))
  224. (mcron-service %ton-cronjobs)
  225. (service nginx-service-type
  226. (nginx-configuration
  227. (server-blocks
  228. (list (nginx-server-configuration
  229. (server-name '("merlin.local"))
  230. (root "/home/ton/www/")
  231. ;;(https-port #f)
  232. (ssl-certificate #f)
  233. (ssl-certificate-key #f))))))
  234. (service rpcbind-service-type
  235. (rpcbind-configuration))
  236. ; Because i3lock-fancy is a wrapper around i3lock, this is correct...
  237. (screen-locker-service i3lock-color "i3lock")
  238. (service tlp-service-type
  239. (tlp-configuration
  240. (cpu-boost-on-ac? #t)))
  241. (service thermald-service-type)
  242. ; (upower-service
  243. ; #:use-percentage-for-policy? #t
  244. ; #:percentage-low 25
  245. ; #:percentage-critical 10
  246. ; #:percentage-action 5)
  247. ; #:critical-power-action 'suspend)
  248. ;Modify services! Xorg and so on!
  249. (modify-services ton-desktop-services
  250. ; (dbus-service config =>
  251. ; #:services (list connman
  252. ; avahi udisks upower accountsservice
  253. ; colord geoclue polkit elogind))
  254. (slim-service-type config =>
  255. (slim-configuration
  256. (inherit config)
  257. (startx (xorg-start-command))))
  258. ; #:configuration-file
  259. ; (xorg-configuration-file
  260. ; ;; #:modules (list xf86-input-mtrack)
  261. ; #:extra-config
  262. ; (list mbp-trackpad-settings))))))
  263. (upower-service-type config =>
  264. (upower-configuration
  265. (use-percentage-for-policy? #t)
  266. (percentage-low 25)
  267. (percentage-critical 10)
  268. (percentage-action 5)
  269. (ignore-lid? #:f)
  270. (watts-up-pro? #:f)
  271. (poll-batteries? #:t)
  272. (time-low 1200)
  273. (time-critical 300)
  274. (time-action 120)
  275. (critical-power-action 'hybrid-sleep)))
  276. ;; (guix-service-type config =>
  277. ;; (guix-configuration
  278. ;; (inherit config)
  279. ;; (extra-options '("--max-jobs=2" "--cores=2"))))
  280. )
  281. )) ; end services
  282. ;; Allow resolution of '.local' host names with mDNS.
  283. (name-service-switch %mdns-host-lookup-nss)
  284. )