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 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
    (simple-service 'my-rotations log-rotation-service-type
68
                     server-rotations)
69
    (modify-services %base-services
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
    (service plasma-desktop-service-type)
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
      (gdm-service-type config =>
90
       (gdm-configuration
91
         (inherit config)
92
         (xorg-configuration
93
           (xorg-configuration
94
             (keyboard-layout (keyboard-layout "fr" "bepo"))))))
95
      (guix-service-type config =>
96
        (guix-configuration
97
          (inherit config)
98
          (substitute-urls '("https://ci.guix.gnu.org"
99
                             "https://bordeaux.guix.gnu.org")))))))
100
101
(define (tyreunom-os host-name)
102
  (operating-system
103
    (host-name host-name)
104
    (timezone "Europe/Paris")
105
    (locale "fr_FR.UTF-8")
106
    (keyboard-layout (keyboard-layout "fr" "bepo"))
107
    (bootloader #f)
108
    (file-systems %base-file-systems)
109
    (users (cons (user-account
110
                   (name "tyreunom")
111
                   (group "users")
112
                   (home-directory "/home/tyreunom"))
113
                 %base-user-accounts))
114
    (locale-definitions
115
      (cons (locale-definition
116
              (name "eo.utf8") (source "eo"))
117
            %default-locale-definitions))
118
    (packages (cons* openssh tmux neovim %base-packages))
119
    (services (cons* (service block-facebook-hosts-service-type)
120
		     %base-services))))
121
122
(define (tyreunom-desktop-os host-name)
123
  (let ((system (tyreunom-os host-name)))
124
    (operating-system
125
      (inherit system)
126
      (users
127
        (map (lambda (user)
128
               (if (equal? (user-account-name user) "tyreunom")
129
                   (user-account
130
                     (inherit user)
131
                     (supplementary-groups '("netdev" "adbusers" "audio" "video" "kvm")))
132
                   user))
133
             (operating-system-users system)))
134
      (groups %base-groups)
135
      (packages (cons* ibus ibus-anthy xdg-utils
136
                       wpa-supplicant gvfs xfce4-terminal
137
                       (operating-system-packages system))))))
138