guix-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Export udev-configuration functions.


From: Ludovic Courtès
Subject: Re: [PATCH] Export udev-configuration functions.
Date: Wed, 18 Nov 2015 18:57:03 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux)

Ricardo Wurmus <address@hidden> skribis:

> In my system configuration I first created the new udev rule (that’s all
> a bit verbose, unfortunately), which is almost identical to the
> ‘kvm-udev-rule’:
>
> ~~~~~~~~~~~~~~~~
> (define (avrispmkii-udev-rule)
>   "Return a directory with a udev rule that sets the group owner and
> group write permissions on the node matching the AVRISPmkII
> microcontroller programming device."
>   (computed-file "avrispmkii-rules"
>                  #~(begin
>                      (use-modules (guix build utils))
>
>                      (define rules.d
>                        (string-append #$output "/lib/udev/rules.d"))
>
>                      (mkdir-p rules.d)
>                      (call-with-output-file
>                          (string-append rules.d "/90-avrispmkii.rules")
>                        (lambda (port)
>                          (display "\
> SUBSYSTEM!=\"usb\", ACTION!=\"add\", GOTO=\"avrisp_end\"
>
> # Atmel Corp. JTAG ICE mkII
> ATTR{idVendor}==\"03eb\", ATTR{idProduct}==\"2103\", MODE=\"660\", 
> GROUP=\"dialout\"
> # Atmel Corp. AVRISP mkII
> ATTR{idVendor}==\"03eb\", ATTR{idProduct}==\"2104\", MODE=\"660\", 
> GROUP=\"dialout\"
> # Atmel Corp. Dragon
> ATTR{idVendor}==\"03eb\", ATTR{idProduct}==\"2107\", MODE=\"660\", 
> GROUP=\"dialout\"
>
> LABEL=\"avrisp_end\"\n" port))))
>                  #:modules '((guix build utils))))
> ~~~~~~~~~~~~~~~~

We should factorize this so one can write:

  (udev-rule "90-avrispmkii.rules"
             "SUBSYSTEM != …")

Because here it’s arguably sufficiently verbose to discourage newcomers.
:-)

> Then I replaced %desktop-services to amend the service of
> ‘udev-service-type’:
>
> ~~~~~~~~~~~~~~~~
> (modify-services %desktop-services
>   (udev-service-type config =>
>                      (udev-configuration
>                       (inherit config)
>                       (rules (append (udev-configuration-rules config)
>                                      (list (avrispmkii-udev-rule)))))))
> ~~~~~~~~~~~~~~~~

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?)

> From 46091d6045443a1bedbd1ca37e8ac31c1399d551 Mon Sep 17 00:00:00 2001
> From: Ricardo Wurmus <address@hidden>
> 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!

Ludo’.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]