/ acer.scm
acer.scm
  1  (use-modules   (ice-9 match)
  2    (gnu)
  3    (guix packages)
  4    (nonguix)
  5    (rosenthal)
  6    (sops secrets)
  7    (guix gexp)
  8    (gnu services cuirass)
  9    (gnu services containers)
 10    (gnu services docker)
 11    (gnu services linux)
 12    (gnu services networking)
 13    (gnu services pm)
 14    (gnu services security)
 15    (gnu services security-token)
 16    (gnu services ssh)
 17    (gnu services sysctl)
 18    (gnu services xorg)
 19    (gnu services syncthing)
 20    (rosenthal services keyboard)
 21    (rosenthal services monitoring)
 22    (rosenthal services networking)
 23    (rosenthal services shellutils)
 24    (rosenthal services web)
 25    (sops services sops)
 26    (gnu home services)
 27    (gnu home services dotfiles)
 28    (gnu home services shepherd)
 29    (gnu home services fontutils)
 30    (gnu home services gnupg)
 31    (gnu home services shells)
 32    (sops home services sops)
 33    (gnu packages android)
 34    (gnu packages cpp)
 35    (gnu packages fcitx5)
 36    (gnu packages file-systems)
 37    (gnu packages games)
 38    (gnu packages gnome-xyz)
 39    (gnu packages gnupg)
 40    (gnu packages guile)
 41    (gnu packages java)
 42    (gnu packages linux)
 43    (gnu packages mail)
 44    (gnu packages python-xyz)
 45    (gnu packages rust)
 46    (gnu packages rust-apps)
 47    (gnu packages security-token)
 48    (gnu packages shells)
 49    (gnu packages ssh)
 50    (gnu packages terminals)
 51    (gnu packages video)
 52    (gnu packages xorg)
 53    (gnu packages zig-xyz)
 54    (rosenthal packages password-utils))
 55  
 56  (define (home-radicle-shepherd-service config)
 57    (list (shepherd-service (provision '(radicle))
 58                            (documentation "Start radicle")
 59                            (start #~(make-forkexec-constructor (list (string-append #$radicle
 60                                                                       "/bin/radicle-node")
 61                                                                      "--force")))
 62                            (stop #~(make-kill-destructor)))))
 63  
 64  (define-public home-radicle-service-type
 65    (service-type (name 'home-radicle)
 66                  (extensions (list (service-extension
 67                                     home-shepherd-service-type
 68                                     home-radicle-shepherd-service)))
 69                  (default-value #f)
 70                  (description "Launch the radicle node")))
 71  (define %xdg-data-home
 72    (or (getenv "XDG_DATA_HOME")
 73        (in-vicinity (getenv "HOME") ".local/share")))
 74  
 75  ;; Source: <https://wiki.archlinux.org/title/XDG_Base_Directory>
 76  (define %xdg-base-directory-env-vars
 77    '(;; bash
 78      ("HISTFILE" . "$XDG_STATE_HOME/bash/history")
 79      ;; docker
 80      ("DOCKER_CONFIG" . "$XDG_CONFIG_HOME/docker")
 81      ;; gdb
 82      ("GDBHISTFILE" . "$XDG_STATE_HOME/gdb/history")
 83      ;; go
 84      ("GOMODCACHE" . "$XDG_CACHE_HOME/go/mod")
 85      ("GOPATH" . "$XDG_DATA_HOME/go")
 86      ;; gradle
 87      ("GRADLE_USER_HOME" . "$XDG_DATA_HOME/gradle")
 88      ;; guile
 89      ("GUILE_HISTORY" . "$XDG_STATE_HOME/guile/history")
 90      ;; java
 91      ("_JAVA_OPTIONS" . "-Djava.util.prefs.userRoot=$XDG_CONFIG_HOME/java")
 92      ;; luanti
 93      ("MINETEST_USER_PATH" . "$XDG_DATA_HOME/luanti")
 94      ;; node
 95      ("NPM_CONFIG_USERCONFIG" . "$XDG_CONFIG_HOME/npm/npmrc")
 96      ;; nvidia-driver
 97      ("CUDA_CACHE_PATH" . "$XDG_CACHE_HOME/nv")
 98      ;; password-store
 99      ("PASSWORD_STORE_DIR" . "$XDG_DATA_HOME/pass")
100      ;; python
101      ;; TODO: Python 3.13.
102      ("PYTHON_HISTORY" . "$XDG_STATE_HOME/python/history")
103      ;; rust
104      ("CARGO_HOME" . "$XDG_DATA_HOME/cargo")
105      ;; sqlite
106      ("SQLITE_HISTORY" . "$XDG_STATE_HOME/sqlite_history")
107      ;; wget
108      ("WGETRC" . "$XDG_CONFIG_HOME/wgetrc")))
109  (define %guix-keys
110    (list (plain-file "dorphine.pub"
111            "(public-key (ecc (curve Ed25519)
112  (q #A279175682D0DAE3E11268E67E1F3FA47C38D7E509F7725567CF891E248E719F#)))")
113          (plain-file "nuporta.pub"
114            "(public-key (ecc (curve Ed25519)
115  (q #552F670D5005D7EB6ACF05284A1066E52156B51D75DE3EBD3030CD046675D543#)))")
116          (plain-file "ignamma.pub"
117            "(public-key (ecc (curve Ed25519)
118  (q #6FEEB15C4363F9975EB15C908EC911A4362E486DA642431FA2438C0B1C3D55F5#)))")
119          (plain-file "workers-hako.pub"
120            "(public-key (ecc (curve Ed25519)
121  (q #7927EA1162184C1FAA62D20C111121A4604F00956E69F0FEB89EEE1721647897#)))")
122          (plain-file "workers-poesty.pub"
123            "(public-key (ecc (curve Ed25519)
124  (q #8C4662FA0BC955B33261EEA5AA15F33081A7BEC991E5F990F7382F0988459B37#)))")
125          ;; Guix Moe
126          (plain-file "guix-moe-old.pub"
127            "(public-key (ecc (curve Ed25519)
128  (q #374EC58F5F2EC0412431723AF2D527AD626B049D657B5633AAAEBC694F3E33F9#)))")
129          (plain-file "guix-moe.pub"
130            "(public-key (ecc (curve Ed25519)
131  (q #552F670D5005D7EB6ACF05284A1066E52156B51D75DE3EBD3030CD046675D543#)))")
132          ;; Nonguix
133          (plain-file "nonguix.pub"
134            "(public-key (ecc (curve Ed25519)
135  (q #C1FD53E5D4CE971933EC50C9F307AE2171A2D3B52C804642A7A35F84F3A4EA98#)))")))
136  (define %network-manager-ipv6-privacy
137    `("ip6-privacy.conf"
138      ,(plain-file "ip6-privacy.conf" "\
139  # Use IPv6 Privacy Extensions.
140  [connection]
141  ipv6.ip6-privacy=2\n")))
142  
143  ;; NOTE: When using on cloud machines, refer to the terms of the provider
144  ;; first.
145  (define %network-manager-random-mac-address
146    `("rand_mac.conf"
147     ,(plain-file "rand_mac.conf" "\
148  # Generate a random MAC for each network connection and associate the two
149  # permanently.
150  [connection-mac-randomization]
151  ethernet.cloned-mac-address=stable
152  wifi.cloned-mac-address=stable\n")))
153  
154  (define %os
155    (operating-system
156      (host-name "windows")
157      (timezone "Asia/Kolkata")
158      (keyboard-layout
159       (keyboard-layout "us" "" #:options '("ctrl:nocaps")))
160      (bootloader
161           (bootloader-configuration
162             (bootloader grub-efi-bootloader)
163             (targets '("/boot/efi"))
164             (keyboard-layout keyboard-layout)))
165      (kernel linux)
166      (initrd microcode-initrd)
167          (firmware (cons* linux-firmware sof-firmware %base-firmware))
168          (kernel-arguments
169           (cons* "kernel.sysrq=1"
170                  "memtest=3"
171                  "modprobe.blacklist=amdgpu,pcspkr,hid_nintendo"
172                  "zswap.enabled=1"
173                  "zswap.max_pool_percent=90"
174                  %default-kernel-arguments))
175          (file-systems (append (list
176    (file-system
177      (mount-point "/boot/efi")
178      (device (uuid "61F0-B1B7"
179                    'fat32))
180      (type "vfat"))
181    (file-system
182      (mount-point "/")
183      (device (uuid
184        "d3550e19-5bef-4b2b-b55b-ea48919e20d1"
185        'ext4))
186      (type "ext4"))) %base-file-systems))
187          (swap-devices
188           (list (swap-space
189                   (target
190                    (uuid "101b0d73-bede-445b-9f90-63c7a43b3e09")))))
191          (users (cons*   (user-account
192      (name "akshit")
193      (group "users")
194      (supplementary-groups '("audio" "docker" "kvm" "plugdev" "video" "wheel"))
195      (shell (file-append fish "/bin/fish"))) %base-user-accounts))
196          (packages
197           (append (specifications->packages
198                    '(;; CLI Utilities.
199                      "curl"
200                      "dconf"
201                      "fd"
202      		"jujutsu"
203                      "git"
204                      "gnupg"
205                      "mosh"
206                      "ncurses"
207                      "ripgrep"
208                      "rsync"
209                      ;"sops"
210                      "unzip"
211  
212                      ;; Desktop applications.
213                      ;"digikam"
214                      ;"gimp"
215                      "imv"
216                      ;"kdenlive"
217                      ;"libreoffice"
218                      "obs-nvidia"
219                      ;"telegram-desktop"
220                      "zathura"
221                      "zathura-pdf-poppler"
222  
223                      ;; Necessary things
224                      "nss-certs"
225  
226                        "niri"
227    "wl-clipboard"
228    "xdg-desktop-portal-gnome"
229    "xdg-desktop-portal-gtk"
230    "xdg-utils"
231    "font-adobe-source-serif"
232    "font-apple-new-york"
233    "font-apple-sf-pro"
234    "font-chiron-hei-hk"
235    "font-chiron-sung-hk"
236    "font-google-noto"
237    "font-google-noto-emoji"
238    "font-nerd-symbols"
239    "font-sarasa-gothic"
240    "font-victor-mono"
241  "radicle"
242    "librewolf"
243    "adaptive-tab-bar-colour-icecat"
244    "bitwarden-icecat"
245    "livemarks-icecat"
246    "ohmyech-icecat"
247    "ublock-origin-icecat"
248    "mpv-nvidia"
249    "mangohud"
250    "steam-nvidia"
251    "exo"
252    "file-roller"
253    "thunar"
254    "thunar-archive-plugin"
255    "thunar-media-tags-plugin"
256    "thunar-volman"
257    "tumbler"
258    "wezterm"
259    "emacs-pgtk"
260    "emacs-gcmh"
261    "emacs-no-littering"
262    "emacs-beancount"
263    "emacs-caddyfile-mode"
264    "emacs-edit-indirect"
265    "emacs-fish-mode"
266    "emacs-json-mode"
267    "emacs-kdl-mode"
268    "emacs-markdown-mode"
269    "emacs-nftables-mode"
270    "emacs-zig-mode"
271    "python"
272    "rust"
273    "rust:cargo"
274    "zig"))
275                   %base-packages))
276          (services
277           (cons*   (service guix-home-service-type
278      `(("akshit" ,(home-environment
279                   (services
280                    (cons*   (service home-dotfiles-service-type
281      (home-dotfiles-configuration
282        (directories '("files/dotfiles"))))
283    (simple-service 'xdg-base-directory home-environment-variables-service-type
284      %xdg-base-directory-env-vars)
285    (simple-service 'modprobed-db home-shepherd-service-type
286      (list (shepherd-timer '(update-modprobed-db)
287              #~(calendar-event #:minutes '(0))
288              #~(#$(file-append modprobed-db "/bin/modprobed-db") "storesilent"))))
289    (service home-fish-service-type)
290    (service home-fish-plugin-atuin-service-type)
291    (service home-fish-plugin-direnv-service-type)
292    (service home-fish-plugin-zoxide-service-type)
293    (simple-service 'fish-emacs-eat home-fish-service-type
294      (home-fish-extension
295        (config
296         (list (plain-file "emacs-eat.fish" "\
297    if test -n \"$EAT_SHELL_INTEGRATION_DIR\"
298        source $EAT_SHELL_INTEGRATION_DIR/fish
299    end")))))
300    (service home-gpg-agent-service-type
301      (home-gpg-agent-configuration
302        (pinentry-program (file-append pinentry-qt "/bin/pinentry-qt"))
303        (ssh-support? #t)))
304    (service home-niri-service-type
305      (home-niri-configuration
306        (config
307         (computed-substitution-with-inputs "niri.kdl"
308           (local-file "files/niri.kdl")
309           (list wezterm xwayland-satellite)))))
310    (service home-noctalia-shell-service-type)
311    (service home-polkit-gnome-service-type)
312    (service home-theme-service-type
313      (home-theme-configuration
314        (packages (list qogir-icon-theme))
315        (icon-theme "Qogir")
316        (cursor-theme "Qogir")))
317    (simple-service 'extend-fontconfig home-fontconfig-service-type
318      (let ((sans  "SF Pro Text")
319            (serif "New York Medium")
320            (mono  "Victor Mono")
321            (emoji "Noto Color Emoji"))
322        `((alias
323           (family "sans-serif")
324           (prefer
325            (family ,sans)
326            (family "Chiron Hei HK VF")
327            (family ,emoji)))
328          (alias
329           (family "serif")
330           (prefer
331            (family ,serif)
332            (family "Chiron Sung HK VF")
333            (family ,emoji)))
334          (alias
335           (family "monospace")
336           (prefer
337            (family ,mono)
338            (family "Chiron Sung HK VF")
339            (family ,emoji)))
340  
341          ,@(map (lambda (name)
342                   `(alias
343                     (family ,name)
344                     (prefer
345                      (family ,sans)
346                      (family "sans-serif"))))
347                 '("BlinkMacSystemFont"
348                   "-apple-system"
349                   "system-ui"
350                   "ui-sans-serif"))
351          (alias
352           (family "ui-serif")
353           (prefer
354            (family ,serif)
355            (family "serif")))
356          (alias
357           (family "ui-monospace")
358           (prefer
359            (family ,mono)
360            (family "monospace"))))))
361    (service home-fcitx5-service-type
362      (home-fcitx5-configuration
363        (themes (list fcitx5-material-color-theme))
364        (input-method-editors (list fcitx5-rime))
365        (gtk-im-module? #t)
366        (qt-im-module? #t)))
367  (service home-radicle-service-type)
368    (simple-service 'mpv-mpris home-xdg-configuration-files-service-type
369      `(("mpv/scripts/mpris.so"
370         ,(file-append mpv-mpris "/lib/mpris.so"))))
371    (simple-service 'emacs-environment home-environment-variables-service-type
372      `(("EDITOR" . "emacsclient")
373        ("VISUAL" . "$EDITOR")
374        ("SSL_CERT_DIR" . "/etc/ssl/certs/")
375        ("SSL_CERT_FILE" . "/etc/ssl/certs/ca-certificates.crt")
376        ("GIT_SSL_CAINFO" . "$SSL_CERT_FILE")
377        ("ESHELL" . ,(file-append fish "/bin/fish"))))
378    (simple-service 'emacs home-shepherd-service-type
379      (list (shepherd-service
380              (provision '(emacs-daemon))
381              (start #~(make-forkexec-constructor '("emacs" "--fg-daemon")))
382              (stop #~(make-kill-destructor)))))
383                           (service home-keyboard-service-type keyboard-layout)
384                           %rosenthal-desktop-home-services))))))
385    (simple-service 'extend-kernel-module-loader kernel-module-loader-service-type
386      '("sch_fq_pie" "tcp_bbr"))
387  
388    (simple-service 'extend-sysctl sysctl-service-type
389      '(("net.core.default_qdisc" . "fq_pie")
390        ("net.ipv4.tcp_congestion_control" . "bbr")
391        ;; https://github.com/quic-go/quic-go/wiki/UDP-Buffer-Sizes
392        ("net.core.rmem_max" . "7500000")
393        ("net.core.wmem_max" . "7500000")))
394    (service tlp-service-type)
395    (simple-service 'auto-power-off shepherd-root-service-type
396      (list (shepherd-timer '(auto-power-off)
397              #~(calendar-event #:minutes '(0 10 20 30 40 50))
398              #~(#$(program-file "auto-power-off"
399                     #~(begin
400                         (use-modules (ice-9 textual-ports))
401  
402                         (define %battery-capacity
403                           (call-with-input-file "/sys/class/power_supply/BAT1/capacity"
404                             (compose string->number get-line)))
405  
406                         (when (<= %battery-capacity 10)
407                           (system* "loginctl" "poweroff"))))))))
408    (udev-rules-service 'u2f libfido2 #:groups '("plugdev"))
409    (service containerd-service-type)
410    (service docker-service-type)
411    (simple-service 'niri-nvidia-profile etc-service-type
412      `(("nvidia/nvidia-application-profiles-rc.d/50-limit-free-buffer-pool-in-wayland-compositors.json"
413         ,(computed-file "50-limit-free-buffer-pool-in-wayland-compositors.json"
414            (with-extensions (list guile-json-4)
415              #~(begin
416                  (use-modules (json))
417                  (call-with-output-file #$output
418                    (lambda (port)
419                      (scm->json
420                       '(("profiles"
421                          . #((("settings"
422                                . #((("value" . 0)
423                                     ("key" . "GLVidHeapReuseRatio"))))
424                               ("name" . "Limit Free Buffer Pool On Wayland Compositors"))))
425                         ("rules"
426                          . #((("profile" . "Limit Free Buffer Pool On Wayland Compositors")
427                               ("pattern"
428                                ("matches" . "niri")
429                                ("feature" . "procname"))))))
430                       port
431                       #:pretty #t)))))))))
432    (service gnome-keyring-service-type)
433    (udev-rules-service 'steam-devices steam-devices-udev-rules)
434    (udev-rules-service 'controller   (udev-rule "60-controller-permission.rules" "\
435    KERNEL==\"event*\", ATTRS{idVendor}==\"045e\", ATTRS{idProduct}==\"028e\", \
436    MODE=\"0660\", GROUP=\"users\""))
437    (service syncthing-service-type
438      (syncthing-configuration
439        (user "akshit")))
440  
441                  ;(service guix-publish-service-type
442                  ;  (guix-publish-configuration
443                  ;    (port 49637)
444                  ;    (host "0.0.0.0")
445                  ;    (advertise? #t)))
446  
447                  (simple-service 'extend-guix guix-service-type
448                    (guix-extension
449                      (authorized-keys %guix-keys)
450                      (substitute-urls '("https://cache-cdn.guix.moe"))))
451  
452                  (simple-service 'guix-gc shepherd-root-service-type
453                    (list (shepherd-timer '(guix-gc)
454                            #~(calendar-event #:days-of-week '(sunday) #:hours '(12) #:minutes '(0))
455                            #~("/run/current-system/profile/bin/guix" "gc" "--delete-generations=1m")
456                            #:requirement '(user-processes guix-daemon))))
457  
458                  (modify-services %rosenthal-desktop-services/tuigreet
459                    (elogind-service-type
460                     config => (elogind-configuration
461                                 (inherit config)
462                                 (handle-suspend-key 'ignore)
463                                 (handle-hibernate-key 'ignore)
464                                 (handle-lid-switch 'ignore)
465                                 (handle-lid-switch-external-power 'ignore)))
466                    (guix-service-type
467                     config => (guix-configuration
468                                 (inherit config)
469                                 (discover? #t)
470                                 (extra-options '("--cores=16"))
471                                 (tmpdir "/var/tmp")))
472                    (network-manager-service-type
473                     config => (network-manager-configuration
474                                 (inherit config)
475                                 (extra-configuration-files
476                                  (list %network-manager-ipv6-privacy
477                                        %network-manager-random-mac-address)))))))
478          (name-service-switch %mdns-host-lookup-nss)))
479  
480  ((compose (nonguix-transformation-nvidia #:open-source-kernel-module? #t #:s0ix-power-management? #t)
481                                          ;(rosenthal-transformation-zfs #:boot? #t)
482    	      )
483   %os)