system-configuration/modules/config/os.scm

os.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
;;
19
;; OS template parts for different usages
20
;;
21
22
(define-module (config os)
23
  #:use-module (gnu packages admin)
24
  #:use-module (gnu packages android)
25
  #:use-module (gnu packages certs)
26
  #:use-module (gnu packages gnome)
27
  #:use-module (gnu packages linux)
28
  #:use-module (gnu packages openbox)
29
  #:use-module (gnu packages ssh)
30
  #:use-module (gnu packages tmux)
31
  #:use-module (gnu packages vim)
32
  #:use-module (gnu packages xdisorg)
33
  #:use-module (gnu packages xfce)
34
  #:use-module (gnu services)
35
  #:use-module (gnu services base)
36
  #:use-module (gnu services dbus)
37
  #:use-module (gnu services desktop)
38
  #:use-module (gnu services networking)
39
  #:use-module (gnu services ssh)
40
  #:use-module (gnu services virtualization)
41
  #:use-module (gnu services xorg)
42
  #:use-module (gnu system)
43
  #:use-module (gnu system accounts)
44
  #:use-module (gnu system file-systems)
45
  #:use-module (gnu system keyboard)
46
  #:use-module (gnu system locale)
47
  #:use-module (gnu system shadow)
48
  #:use-module (guix gexp)
49
  #:export (server-services
50
            desktop-services
51
            tyreunom-os
52
	    tyreunom-desktop-os))
53
54
(define (server-services host-name)
55
  (cons*
56
    (service ntp-service-type)
57
    (service openssh-service-type
58
	     (openssh-configuration
59
	       (authorized-keys
60
		 `(("tyreunom" ,(local-file "../../keys/tyreunom.pub"))))))
61
    (modify-services %base-services
62
      (login-service-type config =>
63
        (login-configuration
64
          (inherit config)
65
          (motd (local-file (string-append "motd/" host-name)))))
66
      (guix-service-type config =>
67
        (guix-configuration
68
          (inherit config)
69
          (substitute-urls '("https://berlin.guix.gnu.org")))))))
70
71
(define desktop-services
72
  (cons*
73
    (simple-service 'dconf dbus-root-service-type (list dconf))
74
    (service tor-service-type)
75
    (service qemu-binfmt-service-type
76
      (qemu-binfmt-configuration
77
	(platforms (lookup-qemu-platforms "arm" "aarch64" "i686" "ppc"))
78
	(guix-support? #t)))
79
    (modify-services %desktop-services
80
      (udev-service-type config =>
81
        (udev-configuration
82
	  (inherit config)
83
	  (rules (cons* android-udev-rules
84
			(udev-configuration-rules config)))))
85
      (gdm-service-type config =>
86
	(gdm-configuration
87
	  (inherit config)
88
	  (xorg-configuration
89
	    (xorg-configuration
90
	      (keyboard-layout (keyboard-layout "fr" "bepo"))))))
91
      (guix-service-type config =>
92
        (guix-configuration
93
          (inherit config)
94
          (substitute-urls '("https://berlin.guix.gnu.org")))))))
95
96
(define (tyreunom-os host-name)
97
  (operating-system
98
    (host-name host-name)
99
    (timezone "Europe/Paris")
100
    (locale "fr_FR.UTF-8")
101
    (keyboard-layout (keyboard-layout "fr" "bepo"))
102
    (bootloader #f)
103
    (file-systems %base-file-systems)
104
    (users (cons (user-account
105
                   (name "tyreunom")
106
                   (group "users")
107
                   (home-directory "/home/tyreunom"))
108
                 %base-user-accounts))
109
    (locale-definitions
110
      (cons (locale-definition
111
              (name "eo.utf8") (source "eo"))
112
            %default-locale-definitions))
113
    (hosts-file
114
      (plain-file "hosts"
115
        (string-append "127.0.0.1 lepiller.eu localhost " host-name "\n"
116
                       "::1       lepiller.eu localhost " host-name "\n"
117
                       %facebook-host-aliases)))
118
    (packages (cons* openssh tmux neovim nss-certs %base-packages))
119
    (services %base-services)))
120
121
(define (tyreunom-desktop-os host-name)
122
  (let ((system (tyreunom-os host-name)))
123
    (operating-system
124
      (inherit system)
125
      (users
126
	(map (lambda (user)
127
	       (if (equal? (user-account-name user) "tyreunom")
128
		   (user-account
129
		     (inherit user)
130
		     (supplementary-groups '("netdev" "adbusers" "audio" "video")))
131
		   user))
132
	     (operating-system-users system)))
133
      (groups (cons (user-group (system? #t) (name "adbusers"))
134
		    %base-groups))
135
      (hosts-file
136
        (plain-file "hosts"
137
          (string-append "127.0.0.1 " host-name ".lepiller.eu localhost " host-name "\n"
138
                         "::1       " host-name ".lepiller.eu localhost " host-name "\n"
139
                         %facebook-host-aliases)))
140
      (packages (cons* xlockmore wpa-supplicant gvfs openbox xfce4-terminal
141
		       (operating-system-packages system))))))
142