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