summaryrefslogtreecommitdiff
path: root/home.scm
blob: 7f49514dcbeef8508da1222232ff1ec52e7a1fe9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
;; This "home-environment" file can be passed to 'guix home reconfigure'
;; to reproduce the content of your profile.  This is "symbolic": it only
;; specifies package names.  To reproduce the exact same profile, you also
;; need to capture the channels being used, as returned by "guix describe".
;; See the "Replicating Guix" section in the manual.

;;; Good reference
;;; https://git.sr.ht/~efraim/guix-config/tree/9009e110e16a8f153add7fb4d7f1512f6a543802/item/efraim-home.scm

(install-r7rs!)
(add-to-load-path (dirname (current-filename)))

(import (gnu home)
	(gnu home services)
	(gnu home services desktop)
	(gnu home services guix)
	(gnu home services shells)
	(gnu home services shepherd)
	(gnu home services sound)
	(gnu home services ssh)
	(gnu home services sway)
	(gnu home services symlink-manager)
        (gnu packages)
	(gnu services)

	;(gnu services syncthing)

	(guix packages)
	(gnu packages music)
	(gnu packages guile-xyz)

	(guix channels)
	(guix derivations)
	(guix monads)
	(guix modules)
	(guix store)
        (guix gexp)
	(guix transformations)

	(srfi 1)
	
	(config-generation sexp)

	(rename (config packages) (home home-packages))
	(rename (config sway) (sway-config rz/sway-config))
	(config foot)

	(ini))

(define secrets (load "secrets.scm"))

(define rz/terminal-emulator "foot")

;; (load "./gptel.scm")

(define emacs-config
  (string-append
   ";; See /home/robby/.config/guix-home/home-configuration.scm\n"
   (scm->string
    ;; Load the secrets file
    `((when (not (load "/home/robby/.config/emacs/secrets.el"))
	(message "could not load secrets!"))

      ;; Load the Nord theme when launching an emacsclient GUI
      (if (daemonp)
	  (add-hook 'after-make-frame-functions
		    (lambda (frame)
		      (with-selected-frame
		       frame
		       (load-theme 'nord t))))
	  (load-theme 'nord t))

      ;; Safe variables
      (custom-set-variables
       ;; custom-set-variables was added by Custom.
       ;; If you edit it by hand, you could mess it up, so be careful.
       ;; Your init file should contain only one such instance.
       ;; If there is more than one, they won't work right.
       '(safe-local-variable-values
	 '((auto-save-default)
	   (org-download-image-dir . "~/org/pictures")
	   (eval progn
		 (require 'lisp-mode)
		 (defun emacs27-lisp-fill-paragraph
		   (&optional justify)
		   (interactive "P")
		   (or
		    (fill-comment-paragraph justify)
		    (let
			((paragraph-start
			  (concat paragraph-start "\\|\\s-*\\([(;\"]\\|\\s-:\\|`(\\|#'(\\)"))
			 (paragraph-separate
			  (concat paragraph-separate "\\|\\s-*\".*[,\\.]$"))
			 (fill-column
			  (if
			   (and
			    (integerp emacs-lisp-docstring-fill-column)
			    (derived-mode-p 'emacs-lisp-mode))
			   emacs-lisp-docstring-fill-column fill-column)))
		      (fill-paragraph justify))
		    t))
		 (setq-local fill-paragraph-function
			     (syntax emacs27-lisp-fill-paragraph)))
	   (eval modify-syntax-entry 43 "'")
	   (eval modify-syntax-entry 36 "'")
	   (eval modify-syntax-entry 126 "'")
	   (eval let
		 ((root-dir-unexpanded
		   (locate-dominating-file default-directory ".dir-locals.el")))
		 (when root-dir-unexpanded
		   (let*
		       ((root-dir
			 (file-local-name
			  (expand-file-name root-dir-unexpanded)))
			(root-dir*
			 (directory-file-name root-dir)))
		     (unless
			 (boundp 'geiser-guile-load-path)
		       (defvar geiser-guile-load-path 'nil))
		     (make-local-variable 'geiser-guile-load-path)
		     (require 'cl-lib)
		     (cl-pushnew root-dir* geiser-guile-load-path :test
				 (syntax string-equal)))))
	   (eval with-eval-after-load 'yasnippet
		 (let
		     ((guix-yasnippets
		       (expand-file-name "etc/snippets/yas"
					 (locate-dominating-file default-directory ".dir-locals.el"))))
		   (unless
		       (member guix-yasnippets yas-snippet-dirs)
		     (add-to-list 'yas-snippet-dirs guix-yasnippets)
		     (yas-reload-all))))
	   (eval setq-local guix-directory
		 (locate-dominating-file default-directory ".dir-locals.el"))
	   (eval add-to-list 'completion-ignored-extensions ".go"))))

      ;; Do not open windows in the same Emacs frame.
      ;; (setq pop-up-frames 'graphic-only)
      
      (setq inferior-lisp-program "/home/robby/.guix-home/profile/bin/sbcl")

      ;; Enable which-key mode
      (which-key-mode)

      ;; Automatically create closing pairs
      (electric-pair-mode 1)

      ;; Show matching parenthesis
      (show-paren-mode 1)
      (setq show-paren-delay 0)

      ;; Hide the tool bar
      (tool-bar-mode -1)
      
      ;; Hide the menu bar
      (menu-bar-mode -1)

      ;; Hide the scroll bar
      (scroll-bar-mode -1)

      ;; Highlight the current line
      (global-hl-line-mode 1)

      ;; Enable line numbers
      (global-display-line-numbers-mode)
      (setq display-line-numbers-type 'relative)

      ;; Disable line numbers for certain modes
      (add-hook 'eshell-mode-hook (lambda () (display-line-numbers-mode -1)))

      ;; Show the column number
      (setq column-number-mode t)

      ;; Add e as an alias for find-file. Useful for eshell.
      (defalias 'e (function find-file))

      ;; Eshell visual commands
      (setq eshell-visual-subcommands '(("guix" "search")
					("pipe-viewer")
					("keepassxc-cli" "open")))

      ;; Open init file
      (defun open-init-file ()
	"Open the init file."
	(interactive)
	(find-file "~/src/guix-dotfiles/home.scm"))

      (global-set-key (kbd "C-x i") 'open-init-file)

      ;; Function to create a new eshell. Used for Sway binding.
      (defvar next-eshell -1)
      (defun new-eshell ()
	(setq next-eshell (+ 1 next-eshell))
	(eshell next-eshell))

      ;; Power
      (defun eshell/poweroff ()
	"Shutdown the computer."
	(call-process "loginctl" null-device nil nil "poweroff"))

      (defun eshell/reboot ()
	"Reboot the computer."
	(call-process "loginctl" null-device nil nil "reboot"))

      ;; For using tramp guix->guix
      (require 'tramp)
      ;; (setq tramp-remote-path
      ;;       (append tramp-remote-path
      ;;               '(tramp-own-remote-path)))
      
      ;; Scheme extra file extensions
      (setq auto-mode-alist (append '(("\\.sld\\'" . scheme-mode)) auto-mode-alist))

      ;; Code folding
      ;; (require 'origami)
      ;; Add mode hooks
      ;; (dolist (mode '(nxml-mode-hook csharp-mode-hook c-mode-hook scheme-mode-hook emacs-lisp-mode-hook))
      ;; 	      (add-hook mode 'origami-mode))
      ;; Specify extra parsers
      ;; (dolist (parser-pair '((scheme-mode . origami-elisp-parser) (csharp-mode . origami-c-style-parser)))
      ;; 	      (add-to-list 'origami-parser-alist parser-pair))
      ;; (define-key origami-mode-map (kbd "<C-tab>") 'origami-recursively-toggle-node)

   ;;; Org mode config
      (require 'org-download)
      (setq org-startup-with-inline-images t)
      (add-hook 'org-mode-hook 'org-indent-mode)
      (add-hook 'org-mode-hook 'toc-org-mode)
      
      ;; Org bullets
      (require 'org-bullets)
      (add-hook 'org-mode-hook (lambda () (org-bullets-mode 1)))

      ;; Org babel language support
      (org-babel-do-load-languages
       'org-babel-load-languages
       '((emacs-lisp . t)
	 (eshell . t)
	 (C . t)
	 (scheme . t)))

      ;; Org link abbreviations
      (setq org-link-abbrev-alist
	    '(("wikipedia" . "https://en.wikipedia.org/wiki/")
	      ("wiki" . "https://wiki.zambito.xyz/index.php?title=")
	      ("gh" . "https://github.com/")
	      ("guix" . "elisp:(guix-packages-by-name \"%s\")")
	      ("isbn" . "https://www.bookfinder.com/isbn/")
	      ("man" . "elisp:(man \"%s\")")))

      ;; Org roam
      (require 'org-roam)
      (setq org-roam-directory "~/org"
	    org-roam-capture-templates '(("d" "default" plain
					  "%?"
					  :target (file+head "%<%Y%m%d%H%M%S>-${slug}.org" "#+title: ${title}")
					  :unnarrowed t)
					 ("p" "person" plain
					  (file "~/org/templates/person.org") 
					  :target (file "%<%Y%m%d%H%M%S>-${slug}.org")
					  :unnarrowed t)
					 ("b" "book" plain
					  (file "~/org/templates/book.org") 
					  :target (file "%<%Y%m%d%H%M%S>-${slug}.org")
					  :unnarrowed t))
	    org-roam-dailies-capture-templates '(("d" "default" entry "* %?"
						  :target (file+head "%<%Y-%m-%d>.org"
								     "#+title: %<%Y-%m-%d>\n"))
						 ("v" "Value" entry "* %?"
						  :target (file+head+olp "%<%Y-%m-%d>.org"
									 "#+title: %<%Y-%m-%d>\n"
									 ("What do I value?")))
						 ("t" "Trajectory" entry "* %?"
						  :target (file+head+olp "%<%Y-%m-%d>.org"
									 "#+title: %<%Y-%m-%d>\n"
									 ("What is my trajectory today?")))))
      (add-to-list 'org-roam-file-exclude-regexp "par/")
      (org-roam-db-autosync-enable)
      (global-set-key (kbd "C-c n i") 'org-roam-node-insert)
      (global-set-key (kbd "C-c n f") 'org-roam-node-find)
      (global-set-key (kbd "C-c n r") 'org-roam-node-random)
      (global-set-key (kbd "C-c n t") 'org-roam-buffer-toggle)
      (global-set-key (kbd "C-c d c t") 'org-roam-dailies-capture-today)
      (global-set-key (kbd "C-c d c n") 'org-roam-dailies-capture-tomorrow)
      (global-set-key (kbd "C-c d c p") 'org-roam-dailies-capture-yesterday)
      (global-set-key (kbd "C-c d c d") 'org-roam-dailies-capture-date)
      (global-set-key (kbd "C-c d f t") 'org-roam-dailies-goto-today)
      (global-set-key (kbd "C-c d f n") 'org-roam-dailies-goto-next-note)
      (global-set-key (kbd "C-c d f p") 'org-roam-dailies-goto-previous-note)
      (global-set-key (kbd "C-c d f d") 'org-roam-dailies-goto-date)

      (add-to-list 'load-path "~/src/org-roam-ui/")
      (require 'org-roam-ui)
      (setq org-roam-ui-sync-theme t
            org-roam-ui-follow t
            org-roam-ui-update-on-save t
            org-roam-ui-open-on-start nil)
      (org-roam-ui-mode 1)

      ;; Emojify
      (global-emojify-mode 1)
      
      ;; ERC
      ;; See: https://gist.github.com/chumpage/1243771
      (require 'erc-services)
      (erc-services-mode 1)

      (setq erc-server "irc.libera.chat"
	    erc-nick "Zambyte"
	    erc-port 6697
	    erc-prompt-for-nickserv-password nil
	    erc-prompt-for-password t
	    erc-nickserv-passwords (list (list 'Libera.Chat (list (cons "Zambyte" (cdr (assoc 'libera secrets))))))
	    erc-autojoin-channels-alist '((Libera.Chat "#archlinux"
						       "#c"
						       "#emacs"
						       "#fsf"
						       "#gnu"
						       "#guile"
						       "#guix"
						       "#hurd"
						       "#lisp"
						       "#mastodon"
						       "#pleroma"
						       "#pleroma-dev"
						       "#scheme"
						       "#sway"
						       "#minetest"
						       "#lojban"
						       "#ckule"
						       "#jbosnu"
						       "#proga"
						       "#lowellmakes")))
      
      ;; Email
      (require 'mu4e)
      (setq mu4e-get-mail-command "SSL_CERT_DIR=/home/robby/.guix-profile/etc/ssl/certs mbsync personal")
      (setq user-full-name "Robby Zambito"
	    user-mail-address "contact@robbyzambito.me"
	    send-mail-function (function smtpmail-send-it)
	    smtpmail-smtp-server "mail.gandi.net"
	    smtpmail-stream-type 'starttls
	    smtpmail-smtp-service 587)
      (global-set-key (kbd "C-x C-m") 'mu4e)

      ;; Music
      (emms-all)
      (setq emms-player-list '(emms-player-mpv)
	    emms-info-functions '(emms-info-native)
	    ;; emms-player-mpv-parameters '("--ao=pipewire")
	    )

      ;; RSS
      (require 'elfeed)
      (require 'elfeed-show)
      (require 'elfeed-org)
      (elfeed-org)
      (setq rmh-elfeed-org-files (list "~/org/20230517231456-elfeed.org")
	    elfeed-search-filter "@6-months-ago +unread -reddit -hn -politics")

      ;; TODO: this doesn't work
      ;; Fixed? TODO: Check if it works
      (add-hook 'elfeed-mode-hook
		(lambda ()
		  (define-key elfeed-mode-map "C-c C-u"
		    'elfeed-update)))

      ;; Source  https://github.com/skeeto/elfeed/issues/267
      (defun elfeed-play-with-mpv ()
	"Play entry link with mpv."
	(interactive)
	(let ((entry (if (eq major-mode 'elfeed-show-mode) elfeed-show-entry (elfeed-search-selected :single)))
              (quality-arg "")
              (quality-val (completing-read "Max height resolution (0 for unlimited): " '("0" "480" "720") nil nil)))
	  (setq quality-val (string-to-number quality-val))
	  (message "Opening %s with height≤%s with mpv..." (elfeed-entry-link entry) quality-val)
	  (when (< 0 quality-val)
	    (setq quality-arg (format "--ytdl-format=[height<=?%s]" quality-val)))
	  (start-process "elfeed-mpv" nil "mpv" quality-arg (elfeed-entry-link entry))))

      (defun elfeed-open-with-eww ()
	"Open in eww with `eww-readable'."
	(interactive)
	(let ((entry (if (eq major-mode 'elfeed-show-mode) elfeed-show-entry (elfeed-search-selected :single))))
	  (eww (elfeed-entry-link entry))
	  (add-hook 'eww-after-render-hook 'eww-readable nil t)))

      (defvar elfeed-visit-patterns
	'(("youtu\\.?be" . elfeed-play-with-mpv)
	  ("v\\.redd\\.it" . elfeed-play-with-mpv)
	  ("reddit" . elfeed-play-with-mpv)
	  ("phoronix" . elfeed-open-with-eww)
	  ("jcs\\.org" . elfeed-play-with-mpv))
	"List of (regexps . function) to match against elfeed entry link to know
whether how to visit the link.")
      
      (defun elfeed-visit-maybe-external ()
	"Visit with external function if entry link matches `elfeed-visit-patterns',
visit otherwise."
	(interactive)
	(let ((entry (if (eq major-mode 'elfeed-show-mode)
			 elfeed-show-entry
			 (elfeed-search-selected :single)))
              (patterns elfeed-visit-patterns))
	  (while (and patterns (not (string-match (caar patterns) (elfeed-entry-link entry))))
	    (setq patterns (cdr patterns)))
	  (cond
	   (patterns
	    (elfeed-untag entry 'unread)
	    (elfeed-search-update-entry entry)
	    (funcall (cdar patterns)))
	   ((eq major-mode 'elfeed-search-mode)
	    (call-interactively 'elfeed-search-show-entry))
	   (t (elfeed-show-visit)))))

      ;; https://github.com/skeeto/elfeed/issues/317 and
      ;; https://github.com/skeeto/elfeed/pull/448#issuecomment-1120336279
      ;; Speeds up getting elfeed feeds
      (setq flycheck-global-modes '(not . (elfeed-search-mode)))

      (define-key elfeed-show-mode-map (kbd "<C-return>") 'elfeed-visit-maybe-external)
      (define-key elfeed-search-mode-map (kbd "<C-return>") 'elfeed-visit-maybe-external)
      (global-set-key (kbd "C-x w") 'elfeed)

      ;; Pleroma
      (add-to-list 'load-path "/home/robby/src/mastodon.el/lisp/")
      (require 'mastodon)
      (setq mastodon-instance-url "https://zoinks.one"
            mastodon-active-user "robby")

      ;; Programming

      ;; https://www.youtube.com/watch?v=Vx0bSKF4y78
      ;; https://github.com/minad/corfu
      ;; (require 'corfu)
      ;; (setq corfu-cycle t
      ;; 	    corfu-auto t
      ;; 	    corfu-auto-delay 0
      ;; 	    corfu-quit-no-match 'separator
      ;; 	    corfu-echo-documentation 0.25
      ;; 	    corfu-preselect-first nil)
      ;; (global-corfu-mode)
      ;; (corfu-history-mode)

      ;; ;; https://github.com/minad/cape
      ;; (require 'cape)
      ;; (add-to-list 'completion-at-point-functions (function cape-dabbrev))
      ;; (add-to-list 'completion-at-point-functions (function cape-file))
    
    ;; (("C-c p p" . completion-at-point) ;; capf
    ;;   ("C-c p t" . complete-tag)        ;; etags
    ;;   ("C-c p d" . cape-dabbrev)        ;; or dabbrev-completion
    ;;   ("C-c p h" . cape-history)
    ;;   ("C-c p f" . cape-file)
    ;;   ("C-c p k" . cape-keyword)
    ;;   ("C-c p s" . cape-symbol)
    ;;   ("C-c p a" . cape-abbrev)
    ;;   ("C-c p i" . cape-ispell)
    ;;   ("C-c p l" . cape-line)
    ;;   ("C-c p w" . cape-dict)
    ;;   ("C-c p \\" . cape-tex)
    ;;   ("C-c p _" . cape-tex)
    ;;   ("C-c p ^" . cape-tex)
    ;;   ("C-c p &" . cape-sgml)
    ;;   ("C-c p r" . cape-rfc1345))

      ;; (require 'gptel)
      ;; (setq gptel-default-mode 'org-mode)
      ;; (setq gptel-default-mode 'text-mode) ; I cannot use org-mode, as there is a bug: https://github.com/karthink/gptel/issues/81
      ;; (define-key gptel-mode-map (kbd "C-c RET") 'gptel-send)
      ;; (define-key gptel-mode-map (kbd "C-c C-<return>") 'gptel-send)
      ;; (define-key gptel-mode-map (kbd "C-c C-m") 'gptel-menu)

    ))))

(define wofi-config
  (with-extensions
   (list guile-ini guile-smc guile-lib)
   #~(begin
       (import (ini))
       (with-output-to-file #$output
	 (lambda ()
	   (scm->ini
	    '((#f
	       ("stylesheet" . #$(local-file "wofi/style.css"))
	       ("xoffset" . 0)
	       ("yoffset" . 0)
	       ("hide_scroll" . "true")
	       ("show" . "drun")
	       ("width" . "600px")
	       ("lines" . 10)
	       ("line_wrap" . "word")
	       ("term" . #$rz/terminal-emulator)
	       ("allow_markup" . "true")
	       ("always_parse_args" . "true")
	       ("show_all" . "true")
	       ("print_command" . "true")
	       ("layer" . "overlay")
	       ("allow_images" . "true")
	       ("insensitivity" . "true")
	       ("prompt" . "Hey, you should type something!")
	       ("image_size" . 25)
	       ("display_generic" . "true")
	       ("key_expand" . "Tab")))))))))

(define git-config
  (with-output-to-string
    (lambda ()
      (scm->ini
       `((init
	  ("defaultBranch" . "master"))
	 (core
	  ("editor" . "emacsclient -c"))
	 (user
	  ("email" . "contact@robbyzambito.me")
	  ("name" . "Robby Zambito"))
	 ;; see push.autoSetupRemote in git help config
	 (push
	  ("autoSetupRemote" . "true"))
	 ("url \"rad://\""
	  ("insteadOf" . "https://rad.go/")))))))

(define guix-gaming-config (cdr (assq 'guix-gaming-config secrets)))

(define rz/user-dirs
  (string-append "XDG_DESKTOP_DIR=\"$HOME/desktop\"\n"
		 "XDG_DOWNLOAD_DIR=\"$HOME/downloads\"\n"
		 "XDG_TEMPLATES_DIR=\"$HOME/templates\"\n"
		 "XDG_PUBLICSHARE_DIR=\"$HOME/public\"\n"
		 "XDG_DOCUMENTS_DIR=\"$HOME/documents\"\n"
		 "XDG_MUSIC_DIR=\"$HOME/music\"\n"
		 "XDG_PICTURES_DIR=\"$HOME/pictures\"\n"
		 "XDG_VIDEOS_DIR=\"$HOME/videos\"\n"
		 "XDG_DATA_DIRS=\"/var/lib/flatpak/exports/share:$XDG_DATA_HOME/flatpak/exports/share:$XDG_DATA_DIRS\"\n"))

(define log-dir (or (getenv "XDG_LOG_HOME") "/home/robby/.local/var/log"))

(define (generate-openssh-hosts num-vces num-vms-per-vce)
  ;; Generate all VCE numbers from 1 to num-vces
  (let ((vce-numbers (iota num-vces 1))
        (vm-numbers (iota num-vms-per-vce 1)))
    ;; For each VCE, generate configurations for all VMs
    (append-map
     (lambda (vce-num)
       ;; For each VM number, create a configuration
       (map
        (lambda (vm-num)
          (openssh-host (name (string-append "rt-vce" (number->string vce-num) 
                                             "-kali" (number->string vm-num)))
                        (user "redteam")
                        (host-name (string-append "172.18.6." (number->string (+ 60 vm-num))))
                        (identity-file "/home/robby/.ssh/redteam_key")
                        (proxy (list
                                (proxy-jump (host-name (string-append "vce" (number->string vce-num))))))
                        (extra-content
                         (string-append "  DynamicForward 8888\n"
                                        "  StrictHostKeyChecking no\n"
                                        "  UserKnownHostsFile=/dev/null"))))
        vm-numbers))
     vce-numbers)))

(define redteam-kali-vms (generate-openssh-hosts 2 10))

(home-environment
 ;; Below is the list of packages that will show up in your
 ;; Home profile, under ~/.guix-home/profile.
 (packages home-packages)

 ;; Below is the list of Home services.  To search for available
 ;; services, run 'guix home search KEYWORD' in a terminal.
 (services
  (list (service home-bash-service-type
                 (home-bash-configuration
                  (aliases '(("grep" . "grep --color=auto")
			     ("ll" . "ls -l")
                             ("ls" . "ls -p --color=auto")
			     ("cp" . "cp --preserve=timestamps")
			     ("reboot" . "loginctl reboot")
			     ("poweroff" . "loginctl poweroff")
			     ("hibernate" . "loginctl hibernate")
			     ("p1" . "ping 1.1.1.1")
			     ("p8" . "ping 8.8.8.8")))
                  (bashrc (list (local-file "home.bashrc"
					    "bashrc")))
                  (bash-profile (list (local-file
                                       "home.bash_profile"
                                       "bash_profile")))))
	(service home-dbus-service-type)
	(service home-xdg-configuration-files-service-type
		 `(("user-dirs.dirs" ,(plain-file "user-dirs" rz/user-dirs))
		   ;; ("sway/config" ,(plain-file "sway-config" rz/sway-config))
		   ("emacs/init.el" ,(plain-file "init.el" emacs-config))
		   ("foot/foot.ini" ,(plain-file "foot.ini" foot-config))
		   ("wofi/config" ,(computed-file "wofi-config" wofi-config))
		   ("git/config" ,(plain-file "git-config" git-config))
		   ("guix-gaming-channels/games.scm" ,(plain-file "guix-gaming-config" guix-gaming-config))))
	(service home-files-service-type
		 `((".mbsyncrc" ,(local-file "mbsyncrc"))
		   (".nmprc" ,(plain-file "npmrc" "prefix=/home/robby/.vnode"))))
	(service home-sway-service-type
		 (sway-configuration
		  (variables
		   (append %sway-default-variables
			   `((menu . "wofi -c ~/.config/wofi/config -I"))))
		  (extra-content (list rz/sway-config))))
	(service home-shepherd-service-type
		 (home-shepherd-configuration
		  (services
		   (list
		    ;; (shepherd-service
		    ;;  (documentation "SwayWM")
		    ;;  (provision '(sway))
		    ;;  (requirement '(dbus))
		    ;;  (respawn? #f)
		    ;;  (auto-start? #f)
		    ;;  (start #~(make-forkexec-constructor
		    ;; 	       (list #$(file-append (specification->package "dbus") "/bin/dbus-run-session") "sway")
		    ;; 	       #:log-file (string-append #$log-dir "/swaywm.log")))
		    ;;  (stop #~(make-system-destructor
		    ;; 	      (string-join (list #$(file-append (specification->package "sway") "/bin/swaymsg")
		    ;; 				 "exit")))))
		    
		    (shepherd-service
		     (documentation "Emacs Server")
		     (provision '(emacs))
		     (start #~(make-system-constructor "emacs --daemon"))
		     (stop #~(make-system-destructor "emacsclient --eval \"(kill-emacs)\"")))
		    ;(shepherd-service
		     ;(documentation "Run `syncthing' without calling the browser")
		     ;(provision '(syncthing))
		     ;(start #~(make-forkexec-constructor
			       ;(list #$(file-append (specification->package "syncthing") "/bin/syncthing")
				     ;"-no-browser")
			       ;#:log-file (string-append #$log-dir "/syncthing.log")))
		     ;(stop #~(make-kill-destructor))
		     ;(respawn? #t))
		    (shepherd-service
		     (documentation "Run a Radicle node")
		     (provision '(rad))
		     (start #~(make-forkexec-constructor
			       (list "/home/robby/.cargo/bin/rad" "node" "start" "--path" "/home/robby/.cargo/bin/radicle-node" "--foreground")
			       #:log-file (string-append #$log-dir "/rad-node.log")))
		     (stop #~(make-system-destructor "/home/robby/.cargo/bin/rad node stop"))
		     (respawn? #t))
		    (shepherd-service
		     (documentation "Run the Radicle web API")
		     (provision '(rad-web))
		     (start #~(make-forkexec-constructor
			       (list "/home/robby/.cargo/bin/rad-web" "--no-open")
			       #:log-file (string-append #$log-dir "/rad-web.log")))
		     (stop #~(make-kill-destructor))
		     (respawn? #t))))))
	(service home-pipewire-service-type)
	(simple-service 'some-useful-env-vars-service
          		home-environment-variables-service-type
          		`(("LESSHISTFILE" . "$XDG_CACHE_HOME/.lesshst")
			  ("XDG_DATA_DIRS" . "$XDG_DATA_DIRS:/var/lib/flatpak/exports/share:/home/robby/.local/share/flatpak/exports/share")
			  ("EDITOR" . "emacsclient -n -a emacs")
			  ("EMACSLOADPATH" . "$HOME/.guix-home/profile/share/emacs/site-lisp/")))
	(service home-openssh-service-type
		 (home-openssh-configuration
		  (hosts
		   (append (list (openssh-host (name "not-a-pi")
					       (host-name "10.69.0.1"))
				 (openssh-host (name "zoinks")
					       (host-name "zoinks.one"))
				 (openssh-host (name "lowell-makes")
					       (host-name "96.81.79.90")
					       (port 1122))
				 (openssh-host (name "lowell-makes-cameo2")
					       (host-name "cameo2")
					       (port 22)
					       (proxy (list
						       (proxy-jump (host-name "lowell-makes")))))
				 (openssh-host (name "lowell-makes-cameo")
					       (host-name "cameo")
					       (port 22)
					       (proxy (list
						       (proxy-jump (host-name "lowell-makes")))))
				 (openssh-host (name "lowell-makes-mogan")
					       (host-name "mogan")
					       (port 22)
					       (proxy (list
						       (proxy-jump (host-name "lowell-makes")))))
				 (openssh-host (name "bustelo")
					       (host-name "10.5.10.187")
					       (port 22)
					       (proxy (list
						       (proxy-jump (host-name "lowell-makes")))))
				 (openssh-host (name "moja")
					       (host-name "45.77.97.44"))
				 (openssh-host (name "babel")
					       (host-name "10.80.80.162"))
				 (openssh-host (name "alpha.apex")
					       (host-name "149.28.47.99"))
				 (openssh-host (name "cnyhackathon-jump")
					       (host-name "vce.cnyhackathon.org")
					       (user "rz")
					       (port 2210)
					       (extra-content
						 (string-append " DynamicForward 8888\n")))
				(openssh-host (name "kali")
                        (user "redteam")
                        (host-name (string-append "172.18.6." (number->string (+ 60 7))))
                        (identity-file "/home/robby/.ssh/redteam_key")
                        (proxy (list
                                (proxy-jump (host-name "cnyhackathon-jump"))))
                        (extra-content
                         (string-append "  DynamicForward 8888\n"
                                        "  StrictHostKeyChecking no\n"
                                        "  UserKnownHostsFile=/dev/null")))
				 (openssh-host (name "vce1")
					       (host-name "vce1.ncaecybergames.org")
					       (user "rz")
					       (port 2210)
					       (extra-content
						(string-append "  DynamicForward 8888\n")))
				 (openssh-host (name "vce2")
					       (host-name "vce2.ncaecybergames.org")
					       (user "rz")
					       (port 2210)
					       (extra-content
						(string-append "  DynamicForward 8888\n"))))
			   redteam-kali-vms))
		  (authorized-keys (cdr (assq 'ssh-authorized-keys secrets)))))
	;; (simple-service 'variant-packages-service
	;; 		home-channels-service-type
	;; 		(cons*
	;; 	  ;; (channel
	;; 	  ;;  (name 'nonguix)
	;; 	  ;;  (url "https://git.robbyzambito.me/mirror/nonguix.git")
	;; 	  ;;  (branch "steam-no-pulse"))
	;; 	  (channel
	;; 	   (name 'nonguix)
	;; 	   (url "https://gitlab.com/nonguix/nonguix")
	;; 	   ;; Enable signature verification:
	;; 	   (introduction
	;; 	    (make-channel-introduction
	;; 	     "897c1a470da759236cc11798f4e0a5f7d4d59fbc"
	;; 	     (openpgp-fingerprint
	;; 	      "2A39 3FFF 68F4 EF7A 3D29  12AF 6F51 20A0 22FB B2D5"))))
	;; 	  (channel
	;; 	   (name 'guix-gaming-games)
	;; 	   (url "https://gitlab.com/guix-gaming-channels/games.git")
	;; 	   ;; Enable signature verification:
	;; 	   (introduction
	;; 	    (make-channel-introduction
	;; 	     "c23d64f1b8cc086659f8781b27ab6c7314c5cca5"
	;; 	     (openpgp-fingerprint
	;; 	      "50F3 3E2E 5B0C 3D90 0424  ABE8 9BDC F497 A4BB CC7F"))))
	;; 	  (channel
	;; 	   (name 'guix)
	;; 	   (url "https://codeberg.org/guix/guix.git")
	;; 	   (branch "master"))
	;; 	  ;; (channel
	;; 	  ;;   (name 'guix)
	;; 	  ;;   (url "https://codeberg.org/guix/guix.git")
	;; 	  ;;   (branch "master")
	;; 	  ;;   (introduction
	;; 	  ;;    (make-channel-introduction
	;; 	  ;;     "9edb3f66fd807b096b48283debdcddccfea34bad"
	;; 	  ;;     (openpgp-fingerprint
	;; 	  ;;      "BBB0 2DDF 2CEA F6A8 0D1D  E643 A2A0 6DF2 A33A 54FA"))))
	;; 	  '()
	;; 	  ;; %default-channels
	;; 	  ))
)))