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