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