system-configuration/modules/home.scm

home.scm

1
;;; Tyreunom's system administration and configuration tools.
2
;;;
3
;;; Copyright © 2019 Julien Lepiller <julien@lepiller.eu>
4
;;;
5
;;; This program is free software: you can redistribute it and/or modify
6
;;; it under the terms of the GNU General Public License as published by
7
;;; the Free Software Foundation, either version 3 of the License, or
8
;;; (at your option) any later version.
9
;;;
10
;;; This program is distributed in the hope that it will be useful,
11
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
12
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
;;; GNU General Public License for more details.
14
;;;
15
;;; You should have received a copy of the GNU General Public License
16
;;; along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18
(define-module (home)
19
  #:use-module (guix build union)
20
  #:use-module (guix build utils)
21
  #:use-module (guix build-system trivial)
22
  #:use-module (guix gexp)
23
  #:use-module (guix licenses)
24
  #:use-module (guix packages)
25
  #:use-module (home build utils)
26
  #:export (home))
27
28
(define (home inputs)
29
  (define union
30
    (computed-file "home"
31
      #~(begin
32
          (use-modules (guix build union))
33
          (union-build #$output '#$inputs))
34
      #:options
35
      '(#:local-build? #t
36
        #:modules ((guix build union)))))
37
  (package
38
    (name "tyreunom-home")
39
    (version "0")
40
    (source #f)
41
    (build-system trivial-build-system)
42
    (arguments
43
     `(#:modules ((guix build utils) (home build utils))
44
       #:builder
45
       (begin
46
         (use-modules (guix build utils) (home build utils))
47
	 (mkdir-p (home-file %outputs ".config"))
48
         ;; TODO: manage profiles, plugins, etc through guix.
49
         (symlink "/data/tyreunom/.mozilla"
50
                  (home-file %outputs ".mozilla"))
51
         ;; For guix
52
         (symlink "/data/tyreunom/.config/guix"
53
                  (home-file %outputs ".config/guix"))
54
         (symlink "/data/tyreunom/.guix-profile"
55
                  (home-file %outputs ".guix-profile"))
56
         ;; symlink writeable directories
57
         (symlink "/data/tyreunom/.local"
58
                  (home-file %outputs ".local"))
59
         (symlink "/data/tyreunom/.cache"
60
                  (home-file %outputs ".cache"))
61
         ;; rest of the files
62
	 (with-directory-excursion (assoc-ref %build-inputs "union")
63
	 (for-each
64
	   (lambda (f)
65
	     (mkdir-p (home-file %outputs (dirname f)))
66
	     (symlink (string-append (assoc-ref %build-inputs "union") "/" f)
67
		      (home-file %outputs f)))
68
	   (find-files "." ".*"))))))
69
    (inputs
70
     `(("union" ,union)))
71
    (home-page "")
72
    (synopsis "")
73
    (description "")
74
    (license gpl3+)))
75