aboutsummaryrefslogtreecommitdiff
path: root/etc/guix/home.scm
blob: 2fca54de0efef2739a72218cfbf64cc46d9f874a (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
(use-modules
  ((xyz euandreh heredoc) #:prefix heredoc:)
  (gnu home)
  (gnu home services)
  (gnu home services mcron)
  (gnu home services shells)
  (gnu packages)
  (gnu packages gnupg)
  (gnu packages mail)
  (gnu packages music)
  (gnu packages wget)
  (gnu packages lisp)
  (gnu packages ssh)
  (gnu packages texinfo)
  (gnu packages tmux)
  (gnu packages version-control)
  (gnu packages video)
  (gnu services)
  (guix gexp)
  (guix modules)
  (guix packages)
  (guix utils)
  ((srfi srfi-1) #:prefix s1:))
(heredoc:enable-syntax)

(define msmtp-non-hardcoded
  (package
    (inherit msmtp)
    (name "msmtp-non-hardcoded")
    (arguments
      (substitute-keyword-arguments (package-arguments msmtp)
        ((#:phases phases '%standard-phases)
         `(modify-phases ,phases
            (add-after 'install-additional-files 'patch-hardcoded-paths
              (lambda* (#:key outputs #:allow-other-keys)
                (let* ((out (assoc-ref outputs "out")))
                  (substitute* (string-append out "/bin/msmtpq")
                    (("^LOG=.*$") "LOG=$XDG_LOG_HOME/msmtpq.log\n")
                    (("^Q=.*$")   "Q=$XDG_DATA_HOME/msmtp/queue\n")
                    (("mkdir -m 0700 \"\\$Q\"")   "mkdir -p -m 0700 \"$Q\"")))))))))))

(define (with-options pkg bin opts)
  (package
    (inherit pkg)
    (arguments
      (substitute-keyword-arguments (package-arguments pkg)
        ((#:phases phases '%standard-phases)
         `(modify-phases ,phases
            (add-after 'install 'wrap-with-flags
              (lambda* (#:key outputs #:allow-other-keys)
                (define (wrap-options prog options)
                  (let ((wrapped-file (string-append (dirname prog) "/." (basename prog) "-orig")))
                    (rename-file prog wrapped-file)
                    (call-with-output-file prog
                      (lambda (port)
                        (format port
                                "#!/bin/sh~%~%exec \"~a\" ~a \"$@\"~%"
                                (canonicalize-path wrapped-file)
                                options)))
                    (chmod prog #o755)))
                (wrap-options (string-append (assoc-ref outputs "out")
                                             "/bin/"
                                             ,bin)
                                             ,opts)))))))))

(define isync-with-options
  (with-options isync "mbsync" "--config=\"$XDG_CONFIG_HOME\"/mbsync/config"))

(define wget-with-options
  (with-options wget "wget" "--hsts-file=\"$XDG_STATE_HOME\"/wget-hsts"))

(define sbcl-with-options
  (with-options sbcl "sbcl" "--userinit \"$XDG_CONFIG_HOME\"/sbcl/sbclrc.lisp"))

(define tmux-with-options
  (with-options tmux "tmux" "-f \"$XDG_CONFIG_HOME\"/tmux/tmux.conf"))

(define myrepos-with-options
  (with-options myrepos "mr" "-c \"$XDG_CONFIG_HOME\"/myrepos/config"))

(define texinfo-with-options
  (with-options texinfo "info" "--init-file \"$XDG_CONFIG_HOME\"/info/infokey"))

(define mpv-with-options
  (with-options mpv "mpv" (string-append "--script="
                                         (getenv "HOME")
                                         "/.guix-home/profile/lib/mpris.so")))

(define openssh-with-options
  (with-options openssh "ssh" "-F \"$XDG_CONFIG_HOME\"/ssh/config"))

(define (xdg-config-home s)
  (string-append (getenv "XDG_CONFIG_HOME") "/" s))

(define gitconfig
  (mixed-text-file "gitconfig" #"-
    [user]
      email = eu@euandre.org
      name = EuAndreh
      signingkey = 81F90EC3CD356060
    [transfer]
      fsckobjects = true
    [push]
      default = current
    [commit]
      gpgsign = true
      verbose = true
    [init]
      defaultBranch = main
    [sendemail]
      assume8bitEncoding = UTF-8
      smtpserveroption = -a
      smtpserveroption = euandreh
      annotate = yes
      confirm = never
      smtpserver = "# msmtp-non-hardcoded "/bin/msmtpq\n"))

(define gpg-agent.conf
  (mixed-text-file "gpg-agent.conf" #"-
    default-cache-ttl 172800
    default-cache-ttl-ssh 172800
    max-cache-ttl 604800
    max-cache-ttl-ssh 604800
    enable-ssh-support
    pinentry-program "# pinentry-gtk2 "/bin/pinentry-gtk-2\n"))

(define ssh.conf
  (plain-file "ssh.conf"
    (string-replace-substring #"-
       Host *
         UserKnownHostsFile @XDG_CONFIG_HOME@/ssh/known_hosts

       Include ~/dev/libre/servers/src/infrastructure/ssh.conf
       Include ~/dev/others/lawtech/src/infrastructure/ssh.conf
       "#
     "@XDG_CONFIG_HOME@"
     (getenv "XDG_CONFIG_HOME"))))

(define config-files
  `(("gnupg/gpg-agent.conf" ,gpg-agent.conf)
    ("git/config" ,gitconfig)
    ("ssh/config" ,ssh.conf)))

(define dot-config
  (let ((prefix-with-config
         (lambda (s)
           (string-append (substring (getenv "XDG_CONFIG_HOME")
                                     (+ 1 (string-length (getenv "HOME"))))
                          "/"
                          s))))
    (map (lambda (t)
           (list (prefix-with-config (first t))
                 (second t)))
         config-files)))


(define cronjobs
  '()
  #;
  (list
   ;; FIXME
   #~(job "* * * * *" "echo foi > ~/foi")
   #~(job "* * * * *" "backup -h 2>&1 > ~/bk")
   #~(job "* * * * *" "which backup -h 2>&1 > ~/which-bk")
   #~(job "* * * * *" "echo $PATH 2>&1 > ~/path")
   #~(job "* * * * *" "echo 123")
   #~(job "* * * * *" "echo 123 > k")
   #~(job "* * * * *" "date > ~/job")))

(home-environment
  (packages
    (append
     (map (compose list specification->package+output symbol->string)
          '(nss-certs
            bash
            coreutils
            findutils
            diffutils
            grep
            sed
            tar
            gawk
            bc
            nvi

            man-pages
            posix-man-pages

            bash-completion

            git
            git:send-email
            git:gui
            git-open
            git-remote-gcrypt
            mercurial
            fossil
            subversion
            cvs

            gnupg
            rsync
            tree
            diffoscope
            mailutils
            entr
            pulseaudio
            password-store
            playerctl
            pinentry-gtk2
            bmake
            make
            fzf
            ranger
            blueman
            pavucontrol
            ledger
            curl
            xclip
            cloc
            strace
            file
            urlscan
            rlwrap
            direnv
            borg
            khal
            khard
            libfaketime
            qrencode
            feh
            sox
            xset
            graphviz
            moreutils
            shellcheck
            gettext
            lilypond
            groff
            jq
            recutils
            units
            ncurses
            trash-cli
            lsof
            autojump
            unzip
            powertop
            md4c
            timidity++

            flatpak

            dunst

            sqlite
            clojure
            openjdk
            perl
            perl-mojolicious
            python
            python-slixmpp
            valgrind
            gcc-toolchain
            clang
            tcc
            node
            quickjs
            m4
            go
            xrandr
            arandr

            st
            i3status
            xmobar
            ghc
            ghc-xmonad-contrib
            xmonad
            xmessage
            dmenu
            clipmenu

            weechat
            alot
            notmuch
            w3m
            afew
            qtox
            telescope
            imagemagick
            ffmpeg
            pandoc
            ;; mktorrent-latest
            jekyll
            flac
            mediainfo
            libnotify
            espeak-ng
            procps
            zenity
            util-linux
            guile
            gzip
            xz
            bzip2
            lzip
            which
            libxml2
            psmisc
            less
            nano
            patch

            poezio
            freetalk
            mcabber
            profanity
            newsboat
            mpv-mpris

            poweralertd
            keepassxc

            xbacklight

            zathura
            zathura-djvu
            zathura-pdf-poppler
            zathura-ps
            dino
            poedit
            transmission
            transmission:gui
            audacity
            inkscape
            frescobaldi
            libreoffice
            rhythmbox
            ungoogled-chromium
            firefox))
     (list msmtp-non-hardcoded
           isync-with-options
           wget-with-options
           sbcl-with-options
           tmux-with-options
           myrepos-with-options
           texinfo-with-options
           mpv-with-options
           openssh-with-options)))
  (services
    (list
     (simple-service 'my-shell-profile home-shell-profile-service-type
       (list (plain-file "my-profile" ". ~/.usr/etc/bash/rc")))
     (simple-service 'config-files home-files-service-type dot-config)
     (simple-service 'home-cron    home-mcron-service-type cronjobs))))