From 8a1bb6706be11cd9c1e683e6d242accad0346d6b Mon Sep 17 00:00:00 2001 From: Tim Gesthuizen Date: Sat, 5 Jan 2019 23:28:18 +0100 Subject: [PATCH 6/7] gnu: Add inputattach service Add a service that runs inputattach as a daemon to translate events from serial ports. * gnu/local.mk: Add gnu/services/hardware.scm * gnu/services/hardware.scm (): New record type * gnu/services/hardware.scm (inputattach-service-type): New service type * gnu/services/hardware.scm (inputattach-service): New function squash --- gnu/local.mk | 1 + gnu/services/hardware.scm | 71 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) create mode 100644 gnu/services/hardware.scm diff --git a/gnu/local.mk b/gnu/local.mk index 7c319b727..d9e06bd17 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -486,6 +486,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/docker.scm \ %D%/services/authentication.scm \ %D%/services/games.scm \ + %D%/services/hardware.scm \ %D%/services/kerberos.scm \ %D%/services/lirc.scm \ %D%/services/virtualization.scm \ diff --git a/gnu/services/hardware.scm b/gnu/services/hardware.scm new file mode 100644 index 000000000..f924fb34d --- /dev/null +++ b/gnu/services/hardware.scm @@ -0,0 +1,71 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2019 Tim Gesthuizen +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu services hardware) + #:use-module (gnu services) + #:use-module (gnu services shepherd) + #:use-module (gnu packages admin) + #:use-module (gnu packages firmware) + #:use-module (guix records) + #:use-module (guix gexp) + #:use-module (ice-9 match) + #:export (inputattach-configuration + inputattach-configuration? + inputattach-service-type + inputattach-service)) + +(define-record-type* + inputattach-configuration + make-inputattach-configuration + inputattach-configuration? + (devicetype inputattach-configuration-devicetype + (default "wacom")) + (device inputattach-configuration-device + (default "/dev/ttyS0")) + (log-file inputattach-configuration-log-file + (default #f))) + +(define inputattach-shepherd-service + (match-lambda + (($ type device log-file) + (list (shepherd-service + (provision '(inputattach)) + (requirement '(udev)) + (documentation "inputattach daemon") + (start #~(make-forkexec-constructor + (list (string-append #$inputattach + "/bin/inputattach") + (string-append "--" #$type) + #$device) + #:log-file #$log-file)) + (stop #~(make-kill-destructor))))))) + +(define inputattach-service-type + (service-type + (name 'inputattach) + (extensions + (list (service-extension shepherd-root-service-type + inputattach-shepherd-service))) + (default-value (inputattach-configuration)))) + +(define* (inputattach-service #:key (type "wacom") (device "/dev/ttyS0") (log-file #f)) + (service inputattach-service-type + (inputattach-configuration + (devicetype type) + (device device) + (log-file log-file)))) -- 2.20.1