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