Example of udev-rules installation from local file

Good morning all,

I have some udev rules in a file which I want to install on my system - could any of you share an example of how you have achieved this?

This was my effort:

(define-module (paulj systems base)
  (use-module (gnu system)
  ;; ...
)

(define %probe-rs-udev-rules (local-file "../files/69-probe-rs.rules"))

(operating-system
  (services 
;; ...
    (udev-rules-service 'probe-rs-udev-rules
                          %probe-rs-udev-rules
                          #:groups '("plugdev"))
;; ...
))

This built OK, but the rules file is not in /etc/udev/rules.d/ after the build and a reboot. The plugdev group does seem to be created, and my user account is now in that group (I added it in the users record).

I am sure I am missing something quite basic here, and seeing how someone else has done it will help me resolve the problem!

Many thanks!

Paul

Not a Guix user, so please take all I write with a grain of salt.

That being said, the indentation of udev-rules-service and (services ... indicate that you only call udev-rules-service, but where do you append or cons that rule onto some other base rule? Could you show the complete list there?

Hi @Ashraz - thanks for your comment.

The full dotfiles repository is here: GitHub - paul-jewell/dotfiles: My dotfile configuration.
You can find the guix configuration under the paulj subdirectory - it’s pretty self explanatory, and follows the configuration as shared by David. The system in question has the hostname neptune, so the specifics are in paulj/systems/neptune.scm, and this uses base.scm for the system configuration.

Hopefully that gives you more to see in terms of what I have configured.

Ok, so I have realised one mistake - my definition of the udev-rule actually missed the udev-rule syntax:

It should be:

(define %probe-rs-udev-rules (udev-rule "69-probe-rs.rules" (local-file "../files/69-probe-rs.rules")))

Then it is included in the operating system record with:

      (udev-rules-service 'probe-rs-udev-rules
                          %probe-rs-udev-rules
                          #:groups '("plugdev"))

I think I am on the right track, but I now need to decipher this error message:

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern" #<<plain-file> name: "69-probe-rs.rules" content: #<<local-file> file: "../files/69-probe-rs.rules" absolute: #<promise #<procedure 7f73e0f24600 at paulj/systems/base.scm:23:60 ()>> name: "69-probe-rs.rules" recursive?: #f select?: #<procedure true (file stat)>> references: ()>)'.

I needed to se file->udev-rule in my definition:

(define %probe-rs-udev-rules (file->udev-rule "69-probe-rs.rules" (local-file "../files/69-probe-rs.rules")))

This builds, puts the file in the store and links to it in the right place (/etc/udev/rules.d).

I now need to go back and see what happens with cargo embed!

edit: cargo flash and cargo embed now work as expected.