config.scm 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  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. (gnu packages cups)
  9. (gnu packages guile-xyz)
  10. (guix monads)
  11. (guix store)
  12. (ice-9 rdelim)
  13. (srfi srfi-1)
  14. (nongnu packages linux)
  15. ; (ton-nonfree)
  16. ; (ton-brother-filter)
  17. )
  18. (use-service-modules
  19. desktop base xorg sddm ssh avahi dbus networking cups mcron virtualization
  20. web pm nfs dns admin docker sound linux)
  21. (use-package-modules
  22. avahi xorg certs wm code wget admin emacs tmux guile
  23. ssh linux disk file gnuzilla version-control maths guile crypto gnupg
  24. password-utils rsync suckless gnome video xdisorg
  25. terminals ssh image-viewers web-browsers pulseaudio
  26. tor readline adns fontutils gnunet package-management
  27. networking lisp cryptsetup fonts python entr gtk nss
  28. bittorrent engineering graphviz shells compression
  29. gnome enlightenment dns ghostscript kde-frameworks bash backup nfs
  30. emacs-xyz printers)
  31. (define quercus-ip "192.168.10.42")
  32. (define (backup-home user)
  33. #~(let ((borg (string-append #$borg "/bin/borg"))
  34. (home (format #f "/home/~a" #$user)))
  35. (system*
  36. borg "--verbose" "-p"
  37. "create"
  38. "--exclude-caches"
  39. "--exclude" (format #f "~a/.cache/*" home)
  40. "--one-file-system"
  41. "--stats" "--list"
  42. "/mnt/borg::{hostname}-{utcnow}"
  43. home)
  44. (system*
  45. borg "--verbose" "-p"
  46. "prune"
  47. "--list"
  48. "--prefix" "{hostname}-"
  49. "---within=1w"
  50. "--keep-daily=7"
  51. "--keep-weekly=4"
  52. "--keep-monthly=6"
  53. "/mnt/borg")))
  54. ;; test like
  55. ;; ,use (guix monad-repl)
  56. ;; ,enter-store-monad
  57. ;; (gexp->script "test" (backup-home "alex"))
  58. ;; ;; and note what the derivation produces. That's the script to run.
  59. ;; (mlet %store-monad ((script (gexp->script "test" (backup-home "alex"))))
  60. ;; (built-derivations (list script)))
  61. ;; then, run the script to do a manual backup.
  62. (define backup-home-job
  63. #~(job '(next-hour '(18))
  64. #$(backup-home "ton")
  65. #:user "ton"))
  66. ;; Hei her er en forandring
  67. (define battery-check-job
  68. #~(job '(next-minute (range 0 60 5))
  69. (lambda ()
  70. (use-modules ((i3-battery-warning) #:prefix i3-battery-warning:))
  71. i3-battery-warning:check&react)
  72. #:user "ton"))
  73. (define updatedb-job
  74. ;; Run 'updatedb' at 3AM every day. Here we write the
  75. ;; job's action as a Scheme procedure.
  76. #~(job '(next-hour '(3))
  77. (lambda ()
  78. (execl (string-append #$findutils "/bin/updatedb")
  79. "updatedb"
  80. "--prunepaths=/tmp /var/tmp /gnu/store"))
  81. "Updatedb!"))
  82. ;(define tor-socket-check-job
  83. ;; Ensure that /var/run/tor/ exists and is owned by tor.
  84. ; #~(job '(next-hour)
  85. ; (lambda () ;; unless(not test)/when(test)?
  86. ; (unless (file-exists? "/var/run/tor")
  87. ; (mkdir "/var/run/tor" #o770)
  88. ; (chown "/var/run/tor" "tor" "tor")))))
  89. ;; Check? WTF!? Switch to python? or BASH? or wat? dis is silly.
  90. (define-public %ton-cronjobs (list updatedb-job
  91. battery-check-job
  92. ;;backup-home-job ;; <- causes system build to fail...
  93. ))
  94. ;(define hp-laptop-monitor-settings
  95. ; (call-with-input-file "/home/ton/guixsd/dotfiles/etc/X11/xorg.conf.d/90-monitor.conf" read-string))
  96. ;(define mbp-trackpad-settings
  97. ; (call-with-input-file "/home/ton/guixsd/dotfiles/etc/X11/xorg.conf.d/60-mtrack.conf" read-string))
  98. (define %powertop-service
  99. (simple-service 'powertop activation-service-type
  100. #~(zero? (system* #$(file-append powertop "/sbin/powertop")
  101. "--auto-tune"))))
  102. (define (remove-services types services)
  103. (remove (lambda (service)
  104. (any (lambda (type)
  105. (eq? (service-kind service) type))
  106. types))
  107. services))
  108. (define ton-desktop-services
  109. (remove-services (list upower-service-type );gdm-service-type)
  110. %desktop-services))
  111. ; (remove (lambda (service)
  112. ; (eq? (service-kind service) network-manager-service-type upower-service-type))
  113. ; %desktop-services))
  114. ;;network-manager-service-type
  115. (operating-system
  116. (host-name "merlin.browniehive.net")
  117. (timezone "Europe/Oslo")
  118. (locale "en_US.utf8")
  119. (kernel linux-libre-4.4)
  120. ;;(firmware (cons* ath9k-htc-firmware %base-firmware))
  121. ;;(kernel linux)
  122. ;;(firmware (cons* atheros-firmware iwlwifi-firmware %base-firmware))
  123. (bootloader (bootloader-configuration
  124. (bootloader grub-efi-bootloader)
  125. (target "/boot/efi")))
  126. (kernel-arguments '("syscall.x32=y"
  127. "acpi_backlight=vendor"))
  128. (swap-devices '("/swapfile"))
  129. (file-systems (cons* (file-system
  130. (device (file-system-label "root"))
  131. (mount-point "/")
  132. (type "ext4"))
  133. (file-system
  134. (device (file-system-label "BOOT"))
  135. (mount-point "/boot/efi")
  136. (type "vfat"))
  137. (file-system
  138. (device (string-append quercus-ip ":/"))
  139. (mount-point "/home/ton/quercus-home/")
  140. (type "nfs")
  141. (mount? #f)
  142. (create-mount-point? #t))
  143. %base-file-systems))
  144. (issue "Mercury.\n")
  145. (users (cons*
  146. (user-account
  147. (name "ton")
  148. (comment "El brownie de casa Merlin")
  149. (group "users")
  150. (shell #~(string-append #$bash "/bin/bash"))
  151. (supplementary-groups '("wheel" "netdev" "audio" "video"
  152. "avahi" "tor"
  153. "users" "kvm" "input"
  154. "libvirt" "docker"
  155. "lp" "lpadmin"
  156. ))
  157. (home-directory "/home/ton"))
  158. %base-user-accounts))
  159. ;;; Maybe use or adapt alezost-guile al/places.scm?
  160. ;;; Add visudo check into sudoers-file PROC - patch into GuixSD?
  161. (sudoers-file (local-file "/home/ton/guixsd/dotfiles/etc/sudoers"))
  162. (hosts-file (local-file "/home/ton/guixsd/dotfiles/etc/hosts"))
  163. (setuid-programs (cons*
  164. #~(string-append #$wireshark "/bin/dumpcap")
  165. %setuid-programs))
  166. (packages
  167. (cons*
  168. sway ;swaybg swaylock i3status ;;swayidle
  169. ;;desktop environment scrot is "necessary" for i3lock-fancy
  170. ;;i3-wm i3status i3lock-fancy scrot hicolor-icon-theme
  171. libvdpau-va-gl
  172. ;useful tools
  173. ; avahi zip unzip tree mosh mcron
  174. tmux htop
  175. the-silver-searcher psmisc wget file strace
  176. wgetpaste
  177. ; inotify-tools entr
  178. ; rsync dmenu openssh lsh feh stow mcelog wcalc graphviz xdotool
  179. readline libcap
  180. sudo glibc-locales
  181. ; gvfs ; for automounting as user
  182. ; fstools
  183. ; dosfstools nfs-utils
  184. ; X
  185. ;;xbindkeys xterm xmodmap setxkbmap xclip xkill
  186. ; light brightnessctl
  187. ;;mako ;; TODO:Necessary?
  188. xev ;;xdpyinfo xrdb xrandr xfontsel
  189. pango fontconfig
  190. font-gnu-unifont font-hack
  191. ; gs-fonts font-wqy-zenhei font-wqy-microhei font-adobe-source-han-sans font-inconsolata
  192. ; audio
  193. ; pulseaudio; pulsemixer
  194. ; laptop specific
  195. acpi cpupower ;;(TODO:cpupower... wat?)
  196. ; dev
  197. gnu-make python-3 binutils
  198. ; guile-lib guile-2.2
  199. ; terminals and emulators
  200. ; termite
  201. bash bash-completion
  202. ; Networking, crypto & security
  203. ; gnupg tor torsocks nmap adns iodine pinentry pinentry-gtk2
  204. ; tomb password-store gnunet nftables
  205. ;for HTTPS access
  206. nss-certs nss
  207. ; emacs
  208. ; emacs emacs-smart-mode-line emacs-rainbow-delimiters
  209. ; emacs-rainbow-identifiers emacs-ag emacs-flycheck emacs-undo-tree
  210. ; emacs-powerline emacs-magit emacs-danneskjold-theme emacs-linum-relative
  211. %base-packages))
  212. (services
  213. (cons*
  214. ; (service alsa-service-type
  215. ; (alsa-configuration
  216. ; (pulseaudio? #t)))
  217. (service cups-service-type
  218. (cups-configuration
  219. (web-interface? #t)
  220. (browsing? #t)
  221. (default-paper-size "A4")
  222. (extensions
  223. (list cups-filters brlaser))))
  224. ; (list cups-filters brother-mfc-j5730dw))))
  225. (service tor-service-type
  226. (tor-configuration
  227. (config-file (local-file "/home/ton/guixsd/dotfiles/etc/tor/torrc"))))
  228. (service openssh-service-type
  229. (openssh-configuration
  230. (port-number 22)
  231. (password-authentication? #f)))
  232. ; (service etc-service-type
  233. ; (list '("cgroupssss" ,(plain-file "" ""))
  234. ; ()))
  235. (service docker-service-type)
  236. (service libvirt-service-type
  237. (libvirt-configuration
  238. (unix-sock-group "libvirt")
  239. (tls-port "16555")))
  240. (service virtlog-service-type
  241. (virtlog-configuration
  242. (max-size 2)))
  243. (service mcron-service-type
  244. (mcron-configuration
  245. (jobs %ton-cronjobs)))
  246. (service nginx-service-type
  247. (nginx-configuration
  248. (server-blocks
  249. (list (nginx-server-configuration
  250. (server-name '("merlin.local"))
  251. (root "/home/ton/www/")
  252. (listen '("80"))
  253. (locations
  254. (list
  255. (nginx-location-configuration
  256. (uri "/rp-improv/")
  257. (body '("root /home/ton/; autoindex on;")))
  258. (nginx-location-configuration
  259. (uri "/files/")
  260. (body '("root /home/ton/www/; autoindex on;")))))
  261. (ssl-certificate #f)
  262. (ssl-certificate-key #f))))))
  263. (service nftables-service-type
  264. (nftables-configuration
  265. (ruleset (local-file "/home/ton/guixsd/dotfiles/etc/merlin-firewall.conf"))))
  266. ;; Fix
  267. ; (service dnsmasq-service-type
  268. ; (dnsmasq-configuration
  269. ; (local-service? #t)
  270. ; (no-resolv? #t)
  271. ; (servers '("82.196.9.45"
  272. ; "51.255.48.78"
  273. ; "51.15.98.97"))
  274. ; (listen-addresses '("127.0.0.1"))
  275. ; ))
  276. (extra-special-file "/usr/bin/env"
  277. (file-append coreutils "/bin/env"))
  278. (extra-special-file "/usr/bin/bash"
  279. (file-append bash "/bin/bash"))
  280. ;; Because i3lock-fancy is a wrapper around i3lock, this is correct...
  281. ;;(screen-locker-service i3lock-color "i3lock")
  282. (screen-locker-service swaylock "swaylock")
  283. (service tlp-service-type)
  284. (service thermald-service-type)
  285. (service upower-service-type
  286. (upower-configuration
  287. (use-percentage-for-policy? #t)
  288. (percentage-low 25)
  289. (percentage-critical 10)
  290. (percentage-action 5)
  291. ;;(ignore-lid? #:t)
  292. (watts-up-pro? #:f)
  293. (poll-batteries? #:t)
  294. (critical-power-action 'hybrid-sleep)))
  295. ;(service rottlog-service-type)
  296. (service tailon-service-type)
  297. (service earlyoom-service-type)
  298. ;;(earlyoom-configuration
  299. ;;(prefer-regexp "")
  300. ;;(avoid-regexp "")
  301. ;;(send-notification-command "")))
  302. %powertop-service
  303. (service sddm-service-type
  304. (sddm-configuration
  305. (display-server "wayland")
  306. (remember-last-user? #t)))
  307. ;Modify services! Xorg and so on!
  308. (remove (lambda (service)
  309. (let ((type (service-kind service)))
  310. (or (memq type
  311. (list
  312. gdm-service-type
  313. modem-manager-service-type))
  314. (eq? 'network-manager-applet
  315. (service-type-name type)))))
  316. (modify-services
  317. ton-desktop-services
  318. (elogind-service-type
  319. config =>
  320. (elogind-configuration
  321. (inherit config)
  322. (handle-lid-switch 'ignore)))
  323. (network-manager-service-type
  324. config =>
  325. (network-manager-configuration
  326. (inherit config)
  327. (dns "dnsmasq")))
  328. (ntp-service-type
  329. config =>
  330. (ntp-configuration
  331. (inherit config)
  332. (allow-large-adjustment? #t)))
  333. (guix-service-type config =>
  334. (guix-configuration
  335. (inherit config)
  336. (substitute-urls (cons*
  337. "https://ci.guix.info/"
  338. "https://berlin.guixsd.org"
  339. %default-substitute-urls))
  340. (extra-options '("--max-jobs=1" "--cores=1"))))
  341. ))
  342. )) ; end services
  343. ;; Allow resolution of '.local' host names with mDNS.
  344. ;;(name-service-switch %mdns-host-lookup-nss)
  345. (name-service-switch
  346. (name-service-switch
  347. (hosts (list %files ;first, check /etc/hosts
  348. ;; If the above did not succeed, try
  349. ;; with 'mdns_minimal'.
  350. (name-service
  351. (name "mdns_minimal")
  352. ;; 'mdns_minimal' is authoritative for
  353. ;; '.local'. When it returns "not found",
  354. ;; no need to try the next methods.
  355. (reaction (lookup-specification
  356. (not-found => return))))
  357. (name-service
  358. (name "gns")
  359. (reaction (lookup-specification
  360. (not-found => return))))
  361. ;; Then fall back to DNS.
  362. (name-service
  363. (name "dns"))
  364. ;; Finally, try with the "full" 'mdns'.
  365. (name-service
  366. (name "mdns"))))))
  367. )