summaryrefslogtreecommitdiff
path: root/.config/guix/modules/services/base.scm
blob: 08b53f2316d2d2099c804424dd00db58c153839d (plain)
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
(define-module (services base)
  #:use-module (gnu)
  #:use-module (gnu home services)
  #:use-module (gnu home services dict)
  #:use-module (gnu home services gnupg)
  #:use-module (gnu home services mcron)
  #:use-module (gnu home services shells)
  #:use-module (gnu home services shepherd)
  #:use-module (gnu home services ssh)
  #:use-module (gnu home services xdg)
  #:use-module (gnu packages gnupg)
  #:use-module (ice-9 rdelim)
  #:use-module (gnu system)
  #:use-module (guix gexp)
  #:use-module (services emacs)
  #:export (bd-base-system-services
            bd-base-home-services))

(use-service-modules admin avahi base
                     dbus desktop file-sharing
                     networking ssh)

(define (read-hosts filename)
  (let ((port (open-input-file filename)))
    (let loop ((lines '()))
      (let ((line (read-line port)))
        (if (eof-object? line)
            (begin (close-input-port port)
                   lines)
            (loop (cons line lines)))))))

(define bd-base-system-services
  `(
    ;; so that non-root users in the wheel group can
    ;; perform administrative tasks (similar to "sudo").
    ,polkit-wheel-service
    ;; The global fontconfig cache directory can sometimes contain
    ;; stale entries, possibly referencing fonts that have been GC'd,
    ;; so mount it read-only.
    ,fontconfig-file-system-service

    ,(service network-manager-service-type)
    ,(service wpa-supplicant-service-type) ; needed by NetworkManager
    ,(service modem-manager-service-type)
    ,(service usb-modeswitch-service-type)

    ;; The D-Bus clique.
    ,(service avahi-service-type)
    ,(service udisks-service-type)
    ,(service upower-service-type)
    ,(service accountsservice-service-type)
    ,(service cups-pk-helper-service-type)
    ,(service colord-service-type)
    ,(service geoclue-service-type)
    ,(service polkit-service-type)
    ,(service elogind-service-type
              (elogind-configuration
               (handle-power-key 'hibernate)
               ))
    ,(service dbus-root-service-type)

    ,(service ntp-service-type)

    ,(service openssh-service-type
              (openssh-configuration
               (x11-forwarding? #t)
               (permit-root-login 'prohibit-password)
               (password-authentication? #f)))
    ,(service tor-service-type)
    ,(simple-service 'add-extra-hosts
                     hosts-service-type
                     (map
                      (lambda (x)
                        (host "0.0.0.0" x))
                      (read-hosts "/home/bdunahu/.config/guix/assets/blocklist.txt")))
    ,@%base-services))

(define bd-base-home-services
  (list
   (service bd-home-emacs-service-type)
   (service home-shepherd-service-type)

   (service home-dicod-service-type)

   (service home-gpg-agent-service-type
            (home-gpg-agent-configuration
             (pinentry-program
              (file-append pinentry-emacs "/bin/pinentry-emacs"))
             (ssh-support? #t)
             (default-cache-ttl 28800)
             (max-cache-ttl 28800)
             (default-cache-ttl-ssh 28800)
             (max-cache-ttl-ssh 28800)))

   (service home-bash-service-type
            (home-bash-configuration
             (aliases '(("auth" . "echo -e \"$PWD\n\" >> $HOME/.config/guix/shell-authorized-directories")
                        ("cp" . "cp -i")
                        ("grep" . "grep --color=auto")
                        ("guix-rcfg" . "sudo guix system -L ${HOME}/.config/guix/modules/ reconfigure ${HOME}/.config/guix/${HOSTNAME}.scm")
                        ("ll" . "ls -l")
                        ("ls" . "ls -p --color=auto")
                        ("mkd" . "mkdir -pv")
                        ("mv" . "mv -i")
                        ("rm" . "rm -i")
                        ("suspend" . "sudo loginctl suspend")
                        ("rig-shell" . "sudo screen /dev/ttyUSB0 115200")
                        ("vi" . "vim")
                        ("xeb" . "emacsclient -nce '(switch-to-buffer nil)'")
                        ("xet" . "emacsclient -nce '(shell)'")
                        ("ytta" . "yt-dlp --extract-audio --format bestaudio/best")
                        ("yttv" . "yt-dlp -f b")))


             (bashrc (list (plain-file "bashrc" "
# converts above aliases into eshell aliases automatically
alias | sed -E \"s/^alias ([^=]+)='(.*)'$/alias \\1 \\2 \\$*/g; s/'\\\\\\''/'/g;\" >~/.config/emacs/eshell/alias
")))
             (environment-variables
              '(
                ("BROWSER" . "librewolf")

                ("VISUAL" . "emacsclient")
                ("EDITOR" . "emacsclient")

                ("NETHACKOPTIONS" . "@$XDG_CONFIG_HOME/nethack/config")

                ("PATH" . "$HOME/.local/bin:$PATH")
                ("ZATHURA_PLUGINS_PATH" . "$HOME/.guix-home/profile/lib/zathura")
                ))))

   (simple-service 'gdbrc
                   home-files-service-type
                   `((".gdbinit"
                      ,(plain-file "gdbinit" "set disassembly-flavor intel"))
                     (".radare2rc"
                      ,(plain-file "radare2rc" "e bin.relocs.apply=true"))))

   (service home-mcron-service-type
            (home-mcron-configuration
             (jobs
              (list
               #~(job
                  ;; twenty minutes
                  (lambda (current-time) (+ current-time (* 20 60)))
                  "offlineimap")
               #~(job
                  (lambda (current-time) (+ current-time (* 5 60)))
                  "~/.local/bin/set-t1")))))

   (service home-openssh-service-type
            (home-openssh-configuration
             (hosts
              (list (openssh-host (name "garm")
                                  (host-name "localhost")
                                  (user "root"))
                    ;; (openssh-host (name "vali")
                    ;;               (host-name "192.168.1.136")
                    ;;               (user "bdunahu"))
                    (openssh-host (name "surt")
                                  (host-name "192.168.1.250")
                                  (user "root"))
                    (openssh-host (name "heimdallr")
                                  (host-name "operationnull.com")
                                  (user "root"))
                    (openssh-host (name "nott")
                                  (host-name "localhost")
                                  (user "bdunahu")
                                  (port 2222)
                                  (extra-content "UserKnownHostsFile=/dev/null\n  StrictHostKeyChecking=no"))))))

   (service home-xdg-user-directories-service-type
            (home-xdg-user-directories-configuration
             (desktop "$HOME/dl")
             (documents "$HOME/dc")
             (download "$HOME/dl")
             (music "$HOME/ik/music")
             (pictures "$HOME/md/ig")
             (publicshare "$HOME")
             (templates "$HOME")
             (videos "$HOME/md/vi")))

   (service home-xdg-mime-applications-service-type
            (home-xdg-mime-applications-configuration
             (default
               '((application/x-bittorrent . torrent.desktop)
                 (x-scheme-handler/magnet  . torrent.desktop)))
             (desktop-entries
              (list
               (xdg-desktop-entry
                (file "torrent")
                (name "Torrent")
                (type 'application)
                (config '((exec . "transmission-remote -a %u"))))))))))