sway.scm 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546
  1. ;; Copyright © 2021 Joshua Branson <jbranso@dismail.de>
  2. ;; This is an operating system configuration template
  3. ;; for a "basic desktop" setup using the sway window manager
  4. ;;
  5. ;;
  6. ;; I am trying to make my computer a LIFE computer.
  7. ;; This means that it would NOT run any graphical program.
  8. ;;
  9. ;; gnucode │ hey guix!
  10. ;; gnucode │ I'm wanting to try to run guix from a console for a while...Essentially I would just start emacs after I login.
  11. ;; gnucode │ But I think I would be tempted to give up this experiment after a few days...Is there someway that I could give a friend my "sudo" password and force myself to only use the console for a while? ie: make it impossible for me on "Guix System" to run X or wayland?
  12. ;; guixy │ gnucode: If it's a guix system, use the base services.
  13. ;; guixy │ Don't include any desktop services
  14. ;; gnucode │ guixy: thanks! That's a great way to do it!
  15. ;; guixy │ gnucode: I've been trying to get startx to work from that setup for a while now. I probably would have had more success if I understood x a little better.
  16. ;; guixy │ gnucode: But if you can get a user-run startx to work let me know :)
  17. ;; gnucode │ guixy: I would reccomend just running sway with %desktop-services.
  18. ;; gnucode │ guixy: I know it is possible to use %base-services and get a user-run startx. BUT I think you have to define various programs to be setuid, which %desktop-services does for you.
  19. ;; guixy │ s/package-location/source-location
  20. ;; guixy │ gnucode: Then you'd be good as long as those programs aren't setuid.
  21. ;; guixy │ And you can control setuid in config.scm
  22. ;; gnucode │ guixy: I'm actually tempted to make my laptop NOT have a sound server...I'm going really old school. :)
  23. ;; gnucode │ BUT thanks for mentioning that I can just make various programs NOT setuid. I hadn't thought of that.
  24. (add-to-load-path (dirname (current-filename)))
  25. (use-modules
  26. (gnu)
  27. (guix)
  28. ;;(guile-web)
  29. (srfi srfi-1)
  30. ;;(secret nginx)
  31. ;;(secret hostfile)
  32. ;; (sway-service)
  33. ;;(endlessh-service)
  34. ;;(services myvpn)
  35. ;;(opensmtpd-records)
  36. ((gnu services mail)
  37. #:hide (opensmtpd-configuration
  38. opensmtpd-configuration?
  39. opensmtpd-service-type
  40. %default-opensmtpd-config-file)))
  41. (use-service-modules
  42. admin
  43. avahi
  44. base
  45. databases
  46. desktop
  47. dict
  48. linux
  49. ;;mail
  50. mcron
  51. networking
  52. sound
  53. ssh
  54. sysctl
  55. xorg
  56. vpn
  57. virtualization
  58. web)
  59. (use-package-modules base databases perl geo idutils ;;gnome
  60. package-management
  61. )
  62. (define mbsync-every-5-minutes
  63. ;; Every 5 minutes
  64. ;; The job's action is a shell command.
  65. #~(job "*/5 * * * *" ;Vixie cron syntax
  66. "mbsync -c /home/joshua/.mbsyncrc -a"
  67. #:user "joshua"))
  68. (define %15-minutes (* 15 60))
  69. ;;I do not use zile. So no need to have it.
  70. (define %my-base-packages
  71. (remove (lambda (package)
  72. (member (package-name package)
  73. (list "zile")))
  74. (cons* postgresql %base-packages)))
  75. (define (auto-login-to-tty config tty user)
  76. (if (string=? tty (mingetty-configuration-tty config))
  77. (mingetty-configuration
  78. (inherit config)
  79. (auto-login user))
  80. config))
  81. (define %current-directory "/home/joshua/prog/gnu/guix/guix-config/")
  82. ;; allegedly %desktop-services now contains network-manager-applet...? Can I remove that?
  83. (define %my-desktop-services
  84. (modify-services %desktop-services
  85. (delete bluetooth-service)
  86. ;;elogind-service
  87. (delete gdm-service-type)
  88. (delete geoclue-service)
  89. ;; I customize my pulseaudio-service down below,
  90. ;; so I need to remove it here.
  91. ;;
  92. ;; I would prefer to instead of copying the file, just modify the default script
  93. ;; certainly guile can take the default script, change a line, and pass back
  94. ;; the modified file.
  95. ;;
  96. ;; This bit of code lets me change the input and out speakers and microphones for my laptop
  97. ;; so that I can use the nice headset that I have.
  98. ;;(service pulseaudio-service-type
  99. ;; (pulseaudio-configuration
  100. ;; (script-file
  101. ;; (local-file
  102. ;; (string-append %current-directory "/pulse/default.pa")))))
  103. (pulseaudio-service-type config =>
  104. (pulseaudio-configuration
  105. (inherit config)
  106. (script-file
  107. (local-file
  108. (string-append %current-directory "/pulse/default.pa")))))
  109. ;;(delete network-manager-service-type)
  110. (mingetty-service-type config =>
  111. (auto-login-to-tty config "tty2" "joshua"))
  112. (guix-service-type config =>
  113. (guix-configuration
  114. (inherit config)
  115. (max-silent-time %15-minutes)
  116. ;; TODO would this work? it would be like adding --fallback by default.
  117. ;; (fallback #t)
  118. ;;(timeout %15-minutes)
  119. ;; ok specifying the --fallback breaks the daemon. weird.
  120. ;; (extra-options '("--fallback"))
  121. ;; I have two CPUs...
  122. (discover? #t)
  123. (extra-options '("--max-jobs=2"))
  124. ))
  125. ;; (network-manager-service-type config =>
  126. ;; (network-manager-configuration
  127. ;; (inherit config)
  128. ;; ;;(dns "none") ;;DO NOT update resolve.conf
  129. ;; ;;(vpn-plugins (list network-manager-openvpn))
  130. ;; ))
  131. ;; ;; <dstolfa> jab`: you can also check `sysctl kernel.unprivileged_bpf_disabled`,
  132. ;; ;; if that returns 1, that means it only works with root
  133. (sysctl-service-type config =>
  134. (sysctl-configuration
  135. (settings (append '(
  136. ("vm.swappiness" . "30")
  137. ;;disable ipv6
  138. ("net.ipv6.conf.all.disable_ipv6" . "1")
  139. ("net.ipv6.conf.all.disable_policy" . "1")
  140. ("net.ipv6.conf.default.disable_ipv6" . "1")
  141. ("net.ipv6.conf.default.disable_policy" . "1")
  142. ("net.ipv6.conf.enp0s10.disable_ipv6" . "1")
  143. ("net.ipv6.conf.enp0s10.disable_policy" . "1")
  144. ("net.ipv6.conf.lo.disable_ipv6" . "1")
  145. ("net.ipv6.conf.lo.disable_policy" . "1")
  146. ;; disable ebpf in kernel virtual machine
  147. ("sysctl kernel.unprivileged_bpf_disabled" . "1")
  148. )
  149. %default-sysctl-settings))))
  150. ))
  151. (operating-system
  152. (host-name "winky")
  153. ;;(hosts-file (local-file (string-append %current-directory "my-hosts-file")))
  154. ;;(host-file (text-file* "hosts" "::1 localhost dobby\n"))
  155. ;;(host-file (text-file "hosts" "::1 localhost dobby\n"))
  156. (hosts-file
  157. (plain-file "hosts"
  158. (string-append
  159. "127.0.0.1 localhost dobby\n"
  160. "127.0.0.1 localhost dobby\n"
  161. "127.0.0.1 www.norm.com norm.com norm\n"
  162. "127.0.0.1 www.test.com test.com test\n"
  163. "127.0.0.1 guile.web.server.com guile.web.com www.date.com date.com\n"
  164. "127.0.0.1 local.gnucode.me\n"
  165. ;; this is my guix linode server
  166. "45.56.66.20 locke-lamora lamora locke\n"
  167. "46.23.94.164 sam\n" ;; my openBSD.amsterdam vm
  168. "127.0.0.1 local.propernaming.org"
  169. ;;%other-hosts-file-lines
  170. "::1 localhost dobby"
  171. )))
  172. (timezone "America/Indiana/Indianapolis")
  173. (locale "en_US.utf8")
  174. ;;(initrd-modules (list "e1000e" "i915" %base-initrd-modules))
  175. ;; when I reboot, does cat /proc/cmdline still show that I blacklisted:
  176. ;; modprobe.blacklist=usbmouse,usbkbd ?
  177. (kernel-arguments (append
  178. (list "modprobe.blacklist=pcspkr")
  179. %default-kernel-arguments))
  180. (keyboard-layout (keyboard-layout "us" "dvorak"
  181. #:model "thinkpad"
  182. #:options '("ctrl:swapcaps")))
  183. ;; Boot in "legacy" BIOS mode, assuming /dev/sdX is the
  184. ;; target hard disk, and "my-root" is the label of the target
  185. ;; root file system.
  186. (bootloader (bootloader-configuration
  187. (bootloader grub-bootloader)
  188. (keyboard-layout keyboard-layout)
  189. (targets (list "/dev/sda"))
  190. (menu-entries
  191. (list
  192. (menu-entry
  193. (label "Debian 10")
  194. (linux "/boot/vmlinuz-4.19.0-8-amd64")
  195. (linux-arguments '("root=/dev/sda3" "quiet"
  196. ;; [KNL,x86] Disable symmetric multithreading (SMT).
  197. ;; Force disable SMT, cannot be undone via the sysfs control file.
  198. ;; "nosmt=force"
  199. ;; this is not necessary for me because my processor doesn't support it.
  200. ;; cat /sys/devices/system/cpu/smt/control --> notsupported
  201. ;; https://serverfault.com/questions/235825/disable-hyperthreading-from-within-linux-no-access-to-bios
  202. ; "iomem=relaxed"
  203. ; the above is useful when I reflash retroboot. retroboot.org
  204. ))
  205. (initrd "/boot/initrd.img-4.19.0-8-amd64"))))))
  206. (file-systems
  207. (cons*
  208. (file-system
  209. (mount-point "/")
  210. (device
  211. (uuid "4bf80701-e54e-44eb-817f-b2f52f5af80e"
  212. 'ext4))
  213. (type "ext4"))
  214. ;;(file-system
  215. ;; (mount-point "/mnt/debian")
  216. ;; (device "/dev/sda3")
  217. ;; (type "ext4"))
  218. %base-file-systems))
  219. (users (cons* (user-account
  220. (name "joshua")
  221. (comment "Joshua Branson")
  222. (group "users")
  223. (home-directory "/home/joshua")
  224. (supplementary-groups
  225. '("audio" "kvm" "netdev" "video" "wheel"
  226. ;;"wireshark"
  227. )))
  228. ;; I was using this as an account to try to update the video of guix's front page.
  229. ;; (user-account
  230. ;; (name "hermione")
  231. ;; (comment "Hermione Granger")
  232. ;; (group "users")
  233. ;; (home-directory "/home/hermione")
  234. ;; (supplementary-groups
  235. ;; '("audio" "video")))
  236. ;;(user-group (name "wireshark"))
  237. %base-user-accounts))
  238. ;; (skeletons (cons*
  239. ;; `(".config/termite/config")
  240. ;; %default-skeletons))
  241. ;; Globally-installed packages.
  242. (packages (append (map specification->package
  243. '("sway" "nss-certs" ;;"nix"
  244. ))
  245. %my-base-packages
  246. ))
  247. ;; Add services to the baseline: a DHCP client and
  248. ;; an SSH server.
  249. (services
  250. (cons*
  251. (service dicod-service-type)
  252. ;; (service dhcp-client-service-type)
  253. ;; I could use getmail... service type... I do not believe that
  254. ;; the getmail service synchrozies between the maildir and remote service
  255. ;; (service getmail-service-type (getmail-configuration
  256. ;; (getmail-configuration-file (getmail-retriever-configuration
  257. ;; (server "jbranso@dismail.de") (username "jbranso@dismail.de")
  258. ;; ;; this is the SSL/TLS port STARTTLS Port is 143 (port 993)
  259. ;; (password "some password here") ;; This is what I should use
  260. ;; (password-command)) (getmail-destination-configuration (type
  261. ;; "Maildir") (path "/home/joshua/.mail/dismail.de/")))))
  262. ;; https://lists.gnu.org/archive/html/help-guix/2016-08/msg00061.html
  263. ;; https://help.ubuntu.com/community/Dovecot
  264. ;;https://help.ubuntu.com/community/DovecotLDAP
  265. (dovecot-service #:config
  266. (dovecot-configuration
  267. (mail-location "maildir:~/.mail/dismail.de:LAYOUT=fs")
  268. (listen '("127.0.0.1"))
  269. ;; this will change a login of "joshua" to a login of "joshua@dismail.de"
  270. ;;(auth-default-realm "dismail.de")
  271. ;; I do not need ssl support in a locally running dovecot. :)
  272. (ssl? "no")
  273. ;; I have find this useful if dovecot cannot find
  274. ;; my mail
  275. (mail-debug? #t)
  276. ;;currently the only way to login to dovecot is to use
  277. ;; joshua and my regular user password
  278. ;; joshua@dismail.de fails and
  279. ;; jbranso@dismial.de fails.
  280. (protocols
  281. (list (protocol-configuration
  282. (name "imap")
  283. (mail-max-userip-connections 1))))
  284. (services (list
  285. (service-configuration
  286. (kind "imap")
  287. (client-limit 1)))) ))
  288. ;; enable gpg
  289. ;;
  290. ;; GPG_TTY=$(tty)
  291. ;; export GPG_TTY
  292. ;; # start the gpg agent
  293. ;; gpgconf --kill gpg-agent # (just in case it’s already running)
  294. ;; eval $(gpg-agent --daemon) # start the gpg-agent
  295. ;; (service gpg-agent-service-type)
  296. ;; this is a service that will reclaim memory in memory tight situations
  297. (service earlyoom-service-type
  298. (earlyoom-configuration
  299. (prefer-regexp "icecat|chromium|firefox")))
  300. ;; (service gnome-desktop-service-type)
  301. ;; (service hurd-vm-service-type
  302. ;; (hurd-vm-configuration
  303. ;; ;; hopefully that is 50GB
  304. ;; ;;(disk-size (* 50000 (expt 2 20)))
  305. ;; (image "/home/joshua/prog/gnu/guix/hurd/vm/hurd-guix-created-50GB.img")
  306. ;; (memory-size 4868) ; 5GB
  307. ;; (options '())
  308. ;; ))
  309. ;; (service endlessh-service-type
  310. ;; (endlessh-configuration
  311. ;; (port-number 22)
  312. ;; (log-level 1)))
  313. (service mcron-service-type
  314. (mcron-configuration
  315. (jobs (list mbsync-every-5-minutes))))
  316. (service nftables-service-type
  317. (nftables-configuration
  318. (ruleset
  319. (local-file (string-append %current-directory "nftables.conf")))))
  320. (service nginx-service-type
  321. (nginx-configuration
  322. (server-blocks
  323. (list
  324. (nginx-server-configuration
  325. (server-name '("date.com"))
  326. (listen '("date.com"))
  327. (root "/home/joshua/prog/guile/decent-dating/")
  328. (locations
  329. (list
  330. (nginx-location-configuration
  331. (uri "/")
  332. (body '("proxy_pass http://date.com:8082;")))
  333. (nginx-location-configuration
  334. (uri "/css/")
  335. (body '("root /home/joshua/prog/guile/decent-dating/;")))
  336. (nginx-location-configuration
  337. (uri "/img/")
  338. (body '("root /home/joshua/prog/guile/decent-dating/;")))
  339. )))
  340. (nginx-server-configuration
  341. (server-name '("local.gnucode.me"))
  342. (listen '("local.gnucode.me"))
  343. (root "/home/joshua/prog/guile/gnucode.me/site/")
  344. (locations
  345. (list
  346. (nginx-location-configuration
  347. (uri "/form/")
  348. (body '("proxy_pass http://local.gnucode.me:8081;")))
  349. (nginx-location-configuration
  350. (uri "/form/css/")
  351. (body '("root /home/joshua/prog/guile/;")))
  352. )))
  353. ;; (nginx-server-configuration
  354. ;; (server-name '("local.propernaming.org"))
  355. ;; (listen '("local.propernaming.org"))
  356. ;; (root "/home/joshua/prog/guile/propernaming/site/")
  357. ;; (locations
  358. ;; (list
  359. ;; (nginx-location-configuration
  360. ;; (uri "/css/")
  361. ;; (body '("root /home/joshua/prog/guile/propernaming/site/;")))
  362. ;; )))
  363. ;;%nginx-servers
  364. ))))
  365. ;; (service postgresql-service-type
  366. ;; (postgresql-configuration
  367. ;; (postgresql postgresql-13)
  368. ;; ;; this is for zipcode things for my dating site
  369. ;; (extension-packages (list postgis))))
  370. ;; (let ([interface "wlp2s0"]
  371. ;; [receive-action (opensmtpd-action-local-delivery-configuration
  372. ;; (name "receive")
  373. ;; (method (opensmtpd-maildir-configuration
  374. ;; (pathname "/home/%{rcpt.user}/Maildir")
  375. ;; (junk #t)))
  376. ;; (virtual "vusers"))]
  377. ;; [smtp.gnucode.me (opensmtpd-pki
  378. ;; (domain "smtp.gnucode.me")
  379. ;; (cert "sway.scm")
  380. ;; (key "sway-service.scm"))])
  381. ;; (service opensmtpd-service-type
  382. ;; (opensmtpd-configuration
  383. ;; (mta-max-deferred 50)
  384. ;; (queue
  385. ;; (opensmtpd-queue-configuration
  386. ;; (compression #t)))
  387. ;; (smtp
  388. ;; (opensmtpd-smtp-configuration
  389. ;; (max-message-size "10M")))
  390. ;; (srs
  391. ;; (opensmtpd-srs-configuration
  392. ;; (ttl-delay "5d")))
  393. ;; (tables (list
  394. ;; (opensmtpd-table
  395. ;; (name "aliases")
  396. ;; (values
  397. ;; (list
  398. ;; (cons "webmaster" "root")
  399. ;; (cons "postmaster" "root")
  400. ;; (cons "abuse" "root"))))
  401. ;; (opensmtpd-table
  402. ;; (name "creds")
  403. ;; (values
  404. ;; (list
  405. ;; (cons "joshua"
  406. ;; "$6$Ec4m8FgKjT2F/03Y$k66ABdse9TzCX6qaALB3WBL9GC1rmAWJmaoSjFMpbhzat7DOpFqpnOwpbZ34wwsQYIK8RQlqwM1I/v6vsRq86."))))
  407. ;; (opensmtpd-table
  408. ;; (name "vdoms")
  409. ;; (values (list "gnucode.me"
  410. ;; "gnu-hurd.com")))
  411. ;; (opensmtpd-table
  412. ;; (name "vusers")
  413. ;; (values (list (cons "joshua@gnucode.me" "joshua")
  414. ;; (cons "jbranso@gnucode.me" "joshua")
  415. ;; (cons "postmaster@gnucode.me" "joshua"))))))
  416. ;; (listen-ons
  417. ;; (list
  418. ;; ;; this forum help suggests that I listen on 0.0.0.0 and NOT eth0
  419. ;; ;; https://serverfault.com/questions/726795/opensmtpd-wont-work-at-reboot
  420. ;; ;; this listens for email from the outside world
  421. ;; (opensmtpd-listen-on
  422. ;; (interface interface)
  423. ;; (port 25)
  424. ;; (secure-connection "tls")
  425. ;; (pki smtp.gnucode.me)
  426. ;; )
  427. ;; ;; this lets local users logged into the system via ssh send email
  428. ;; (opensmtpd-listen-on
  429. ;; (interface "lo")
  430. ;; (port 25)
  431. ;; (secure-connection "tls")
  432. ;; (pki smtp.gnucode.me))
  433. ;; (opensmtpd-listen-on
  434. ;; (interface interface)
  435. ;; (port 465)
  436. ;; (secure-connection "smtps")
  437. ;; (pki smtp.gnucode.me)
  438. ;; (auth "creds")
  439. ;; ;;(filter )
  440. ;; )
  441. ;; (opensmtpd-listen-on
  442. ;; (interface interface)
  443. ;; (port 587)
  444. ;; (secure-connection "tls-require")
  445. ;; (pki smtp.gnucode.me)
  446. ;; (auth "creds")
  447. ;; ;;(filter )
  448. ;; )))
  449. ;; (matches (list
  450. ;; (opensmtpd-match
  451. ;; (action (opensmtpd-relay-configuration
  452. ;; (name "send")))
  453. ;; (for "for any")
  454. ;; (from "from any")
  455. ;; (auth #t))
  456. ;; (opensmtpd-match
  457. ;; (action receive-action)
  458. ;; (from "from any")
  459. ;; (for "for domain <vdoms>"))
  460. ;; (opensmtpd-match
  461. ;; (action receive-action)
  462. ;; (for "for local"))))
  463. ;; ;; (filter-chains
  464. ;; ;; (list
  465. ;; ;; (opensmtpd-filter-chain
  466. ;; ;; (name "dropDumbEmails")
  467. ;; ;; (filter-names (list "nofcrdnsDisconnect"
  468. ;; ;; "nordnsDisconnect")))))
  469. ;; ;; (filter-phases
  470. ;; ;; (list (opensmtpd-filter-phase
  471. ;; ;; (name "nofcrdnsDisconnect")
  472. ;; ;; (phase-name "connect")
  473. ;; ;; (conditions (list "!fcrdns"))
  474. ;; ;; (decision "disconnect")
  475. ;; ;; (message "You have not set up forward confirmed DNS."))
  476. ;; ;; (opensmtpd-filter-phase
  477. ;; ;; (name "nordnsDisconnect")
  478. ;; ;; (phase-name "connect")
  479. ;; ;; (conditions (list "!rdns"))
  480. ;; ;; (decision "reject")
  481. ;; ;; (message "You have not set up reverse DNS."))))
  482. ;; )))
  483. ;; (service sway-service-type)
  484. ;;Ludo is adding rotlog service to %base-services. (service
  485. ;;rottlog-service-type)
  486. ;; make guix system autoupgrade itself once a week!
  487. ;; this is currently failing...see /var/log/unattended-upgrade.log
  488. (service unattended-upgrade-service-type
  489. (unattended-upgrade-configuration
  490. (schedule "30 01 * * 0")
  491. (system-expiration (* 3 30 24 3600))))
  492. (extra-special-file "/usr/bin/perl"
  493. (file-append perl "/bin/perl"))
  494. ;; currently does not work so not enabling it.
  495. ;; (service wireguard-service-type
  496. ;; (wireguard-configuration
  497. ;; (private-key "/home/joshua/prog/gnu/guix/guix-config/wireguard-keys/laptop.private.key")
  498. ;; (peers
  499. ;; (list
  500. ;; (wireguard-peer
  501. ;; (name "my client laptop")
  502. ;; (endpoint "wireguard.gnucode.me:51820")
  503. ;; (public-key "9zhoGW8DYr9zJHFbzBZUSBQHWlY6h/9HeoNzrC58dTc=")
  504. ;; (allowed-ips '("0.0.0.0/0")))))))
  505. ;; Fedora is including a zram device by default
  506. (service zram-device-service-type
  507. (zram-device-configuration
  508. (size "512M")))
  509. %my-desktop-services)))