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