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