aboutsummaryrefslogtreecommitdiff
path: root/etc/guix/home.scm
blob: 6835efc9a3ac58ef903644a081d03cdd1df6e5f9 (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
(use-modules
  ((ice-9 textual-ports) #:prefix textual-ports:)
  ((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 build-system trivial)
  (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)
         #~(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-extra
  (mixed-text-file
   "gitconfig-extra"
   "[sendemail]\n  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 config-files
  `(("gnupg/gpg-agent.conf" ,gpg-agent.conf)
    ("git/config-extra" ,gitconfig-extra)))

(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 (s1:first t))
                 (s1:second t)))
         config-files)))


(define (slurp name)
  (string-trim-both
   (call-with-input-file
    name
    textual-ports:get-string-all)))

(define (script name content)
  (package
    (name name)
    (version "latest")
    (source #f)
    (build-system trivial-build-system)
    (arguments
      `(#:modules ((guix build utils))
        #:builder
        (begin
          (use-modules (guix build utils))
          (let* ((bin (string-append %output "/bin"))
                 (prog (string-append bin "/" ,name)))
            (mkdir-p bin)
            (call-with-output-file prog
              (lambda (port)
                (format port "~a" ,content)))
            (chmod prog #o755)))))
    (home-page "")
    (synopsis "")
    (description "")
    (license #f)))

(define cronjobs
  (list
   #~(job "0  0   * * *" "cronjob msmtp-queue -r")
   #~(job "0  0   * * *" "cronjob check")
   #~(job "5  */6 * * *" "cronjob m")
   #~(job "30 0   * * *" "cronjob backup -q cron")))


(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
            git-lfs
            mercurial
            fossil
            darcs
            subversion
            cvs
            rcs
            cssc
            quilt

            gnupg
            rsync
            tree
            diffoscope
            mailutils
            entr
            pulseaudio
            password-store
            playerctl
            pinentry-gtk2
            bmake
            make
            tup
            autoconf
            automake
            libtool
            pcre
            pcre2
            avahi
            libgcrypt
            qbe
            cproc
            doxygen
            gperf
            readline
            gmp
            help2man
            libtomcrypt
            libtommath
            lz4
            lokke
            meson
            ninja
            sparse
            ant
            mpc
            maven
            libgcrypt
            pkg-config
            fzf
            ranger
            blueman
            pavucontrol
            ledger
            curl
            curl:doc
            xclip
            cloc
            strace
            file
            urlscan
            rlwrap
            direnv
            borg
            khal
            khard
            libfaketime
            qrencode
            feh
            sox
            xset
            graphviz
            moreutils
            shellcheck
            gettext
            lilypond
            groff
            ghostscript
            texlive
            jq
            recutils
            units
            ncurses
            trash-cli
            lsof
            autojump
            unzip
            powertop
            md4c
            timidity++
            cmark
            cmake
            makefile2graph
            po4a-text
            mdpo-patched

            cryptsetup
            btrfs-progs

            flatpak

            dunst

            sqlite
            clojure
            clojure-tools
            openjdk
            perl
            perl-dbi
            perl-dbd-sqlite
            perl-critic
            perl-json
            perl-mojolicious
            perl-regexp-grammars
            perl-commonmark
            perl-aliased
            perl-uri-escape
            ruby
            python
            python-slixmpp
            python-unidecode
            python-yubikey-manager
            python-coverage
            python-pytest
            python-requests
            python-beautifulsoup4
            python-docx
            python-telegram-bot
            python-docutils
            python-mkdocs
            valgrind
            flex
            bison
            gcc-toolchain
            clang-toolchain
            tcc
            fuse
            node
            quickjs
            m4
            go
            xrandr
            arandr
            openssl

            st
            i3status
            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
            guile-heredoc-latest
            gzip
            xz
            bzip2
            lzip
            which
            libxml2
            psmisc
            less
            nano
            patch
            youtube-dl

            poezio
            freetalk
            mcabber
            profanity
            newsboat
            mpv-mpris
            vlc

            poweralertd
            keepassxc

            xbacklight

            zathura
            zathura-djvu
            zathura-pdf-poppler
            zathura-ps
            dino
            poedit
            transmission
            transmission:gui
            audacity
            inkscape
            frescobaldi
            libreoffice
            rhythmbox
            quodlibet
            calibre
            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
           (script "cronjob" (slurp (string-append (getenv "XDG_CONFIG_HOME")
                                                   "/sh/cronjob.sh"))))))
  (services
    (list
     (simple-service 'my-shell-profile home-shell-profile-service-type
       (list (plain-file "my-profile" ". ~/.usr/etc/sh/rc")))
     (simple-service 'config-files home-files-service-type dot-config)
     (simple-service 'home-cron    home-mcron-service-type cronjobs))))