From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ricardo Wurmus Subject: Re: [PATCH] Export udev-configuration functions. Date: Wed, 18 Nov 2015 22:03:48 +0100 Message-ID: <87bnarj9zf.fsf@elephly.net> References: <874mgjk0ip.fsf@elephly.net> <87610zp4wg.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:44761) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zz9tc-00019n-IE for guix-devel@gnu.org; Wed, 18 Nov 2015 16:04:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zz9tb-0003Dn-AI for guix-devel@gnu.org; Wed, 18 Nov 2015 16:04:04 -0500 In-reply-to: <87610zp4wg.fsf@gnu.org> List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org Sender: guix-devel-bounces+gcggd-guix-devel=m.gmane.org@gnu.org To: Ludovic =?utf-8?Q?Court=C3=A8s?= Cc: guix-devel --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Ludovic Courtès writes: > We should factorize this so one can write: > > (udev-rule "90-avrispmkii.rules" > "SUBSYSTEM != …") > > Because here it’s arguably sufficiently verbose to discourage newcomers. > :-) Patch attached. Is this okay? --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-services-Add-udev-rule-procedure.patch >From 77f22cb933a9740cccc62f6bac2d3f9381192eba Mon Sep 17 00:00:00 2001 From: Ricardo Wurmus Date: Wed, 18 Nov 2015 21:58:53 +0100 Subject: [PATCH] services: Add udev-rule procedure. * gnu/services/base.scm (udev-rule): New procedure. (kvm-udev-rule): Rewrite in terms of udev-rule. --- gnu/services/base.scm | 29 +++++++++++++++++------------ 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index bb5854d..1308065 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -57,6 +57,7 @@ udev-configuration-rules udev-service-type udev-service + udev-rule mingetty-configuration mingetty-configuration? @@ -956,12 +957,9 @@ item of @var{packages}." #:modules '((guix build union) (guix build utils)))) -(define* (kvm-udev-rule) - "Return a directory with a udev rule that changes the group of -@file{/dev/kvm} to \"kvm\" and makes it #o660." - ;; Apparently QEMU-KVM used to ship this rule, but now we have to add it by - ;; ourselves. - (computed-file "kvm-udev-rules" +(define (udev-rule filename contents) + "Return a directory with a udev rule file FILENAME containing CONTENTS." + (computed-file filename #~(begin (use-modules (guix build utils)) @@ -970,15 +968,22 @@ item of @var{packages}." (mkdir-p rules.d) (call-with-output-file - (string-append rules.d "/90-kvm.rules") + (string-append rules.d "/" #$filename) (lambda (port) - ;; Build users are part of the "kvm" group, so we - ;; can fearlessly make /dev/kvm 660 (see - ;; , for background.) - (display "\ -KERNEL==\"kvm\", GROUP=\"kvm\", MODE=\"0660\"\n" port)))) + (display #$contents port)))) #:modules '((guix build utils)))) +(define (kvm-udev-rule) + "Return a directory with a udev rule that changes the group of +@file{/dev/kvm} to \"kvm\" and makes it #o660." + ;; Apparently QEMU-KVM used to ship this rule, but now we have to add it by + ;; ourselves. + + ;; Build users are part of the "kvm" group, so we can fearlessly make + ;; /dev/kvm 660 (see , for background.) + (udev-rule "90-kvm.rules" + "KERNEL==\"kvm\", GROUP=\"kvm\", MODE=\"0660\"\n")) + (define udev-dmd-service ;; Return a for UDEV with RULES. (match-lambda -- 2.5.0 --=-=-= Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit > That’s one way do do it. > > Another one would be to write an avrispmkii service that would extend > ‘udev-service-type’ by passing it its rule (and maybe it could do other > useful things as well?) I did this first but then it seemed overly complicated when there already is a service that does almost exactly what I want. But in more complicated cases it may make sense to add a new service. I really like how straight forward this new service composition feature is! >> From 46091d6045443a1bedbd1ca37e8ac31c1399d551 Mon Sep 17 00:00:00 2001 >> From: Ricardo Wurmus >> Date: Wed, 18 Nov 2015 12:17:42 +0100 >> Subject: [PATCH] services: Export udev-configuration procedures. >> >> * gnu/services/base.scm (udev-configuration, udev-configuration?, >> udev-configuration-rules): Export. > > Good idea indeed. OK! Pushed! Thanks! ~~ Ricardo --=-=-=--