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 freedesktop)
27
  #:use-module (gnu packages gnome)
28
  #:use-module (gnu packages ibus)
29
  #:use-module (gnu packages linux)
30
  #:use-module (gnu packages openbox)
31
  #:use-module (gnu packages ssh)
32
  #:use-module (gnu packages tmux)
33
  #:use-module (gnu packages vim)
34
  #:use-module (gnu packages wm)
35
  #:use-module (gnu packages xdisorg)
36
  #:use-module (gnu packages xfce)
37
  #:use-module (gnu services)
38
  #:use-module (gnu services admin)
39
  #:use-module (gnu services base)
40
  #:use-module (gnu services dbus)
41
  #:use-module (gnu services desktop)
42
  #:use-module (gnu services networking)
43
  #:use-module (gnu services ssh)
44
  #:use-module (gnu services virtualization)
45
  #:use-module (gnu services xorg)
46
  #:use-module (gnu system)
47
  #:use-module (gnu system accounts)
48
  #:use-module (gnu system file-systems)
49
  #:use-module (gnu system keyboard)
50
  #:use-module (gnu system locale)
51
  #:use-module (gnu system shadow)
52
  #:use-module (guix gexp)
53
  #:use-module (config rotation)
54
  #:export (server-services
55
            desktop-services
56
            tyreunom-os
57
            tyreunom-desktop-os))
58
59
(define (server-services host-name)
60
  (cons*
61
    (service ntp-service-type)
62
    (service openssh-service-type
63
             (openssh-configuration
64
               (authorized-keys
65
                 `(("tyreunom" ,(local-file "../../keys/tyreunom.pub"))))))
66
    (simple-service 'motd-service etc-service-type
67
      `(("motd" ,(local-file (string-append "motd/" host-name)))))
68
    (modify-services %base-services
69
      (rottlog-service-type config =>
70
        server-rotation-service-config)
71
      (login-service-type config =>
72
        (login-configuration
73
          (inherit config)
74
          (motd (local-file (string-append "motd/" host-name)))))
75
      (guix-service-type config =>
76
        (guix-configuration
77
          (inherit config)
78
          (substitute-urls '("https://ci.guix.gnu.org"
79
                             "https://bordeaux.guix.gnu.org")))))))
80
81
(define (desktop-services)
82
  (cons*
83
    (simple-service 'dconf dbus-root-service-type (list dconf))
84
    (service tor-service-type)
85
    (service qemu-binfmt-service-type
86
      (qemu-binfmt-configuration
87
        (platforms (lookup-qemu-platforms "arm" "aarch64" "i686" "ppc"))))
88
    (udev-rules-service 'android android-udev-rules #:groups '("adbusers"))
89
    (modify-services %desktop-services
90
      (rottlog-service-type config =>
91
        desktop-rotation-service-config)
92
      (gdm-service-type config =>
93
       (gdm-configuration
94
         (inherit config)
95
         (xorg-configuration
96
           (xorg-configuration
97
             (keyboard-layout (keyboard-layout "fr" "bepo"))))))
98
      (guix-service-type config =>
99
        (guix-configuration
100
          (inherit config)
101
          (substitute-urls '("https://ci.guix.gnu.org"
102
                             "https://bordeaux.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
    (packages (cons* openssh tmux neovim %base-packages))
122
    (services (cons* (service block-facebook-hosts-service-type)
123
		     %base-services))))
124
125
(define (tyreunom-desktop-os host-name)
126
  (let ((system (tyreunom-os host-name)))
127
    (operating-system
128
      (inherit system)
129
      (users
130
        (map (lambda (user)
131
               (if (equal? (user-account-name user) "tyreunom")
132
                   (user-account
133
                     (inherit user)
134
                     (supplementary-groups '("netdev" "adbusers" "audio" "video" "kvm")))
135
                   user))
136
             (operating-system-users system)))
137
      (groups %base-groups)
138
      (packages (cons* ibus ibus-anthy xdg-utils
139
                       swaylock wpa-supplicant gvfs openbox xfce4-terminal
140
                       (operating-system-packages system))))))
141