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