all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Maxim Cournoyer <maxim.cournoyer@gmail.com>
To: 45mg <45mg.writes@gmail.com>
Cc: "Ludovic Courtès" <ludo@gnu.org>, 74819@debbugs.gnu.org
Subject: [bug#74819] [PATCH v4] services: elogind: Support Hook Directories
Date: Sat, 28 Dec 2024 14:46:33 +0900	[thread overview]
Message-ID: <87frm8tl52.fsf@gmail.com> (raw)
In-Reply-To: <276103d4ae303592ff8ce4e83438e8c3d1c020bf.1735301702.git.45mg.writes@gmail.com> (45mg.writes@gmail.com's message of "Fri, 27 Dec 2024 07:15:02 -0500")

Hi,

45mg <45mg.writes@gmail.com> writes:

> Allow the user to specify scripts to be added into Elogind's hook
> directories. These scripts will be run before/after
> suspend/hibernate/poweroff/reboot.
>
> Also allow setting the associated config options.
>
> * gnu/services/desktop.scm (elogind-configuration): add
> `system-sleep-hook-files`, `system-shutdown-hook-files`,
> and 4 new config options.
> (elogind-configuration-file): Add entries for the new config options
> under the `[Sleep]` section.
> (/etc/elogind): New function, to generate /etc/elogind directory.
> (elogind-service-type): Extend `etc-service-type` using `/etc/elogind`.
> * doc/guix.texi: Document the new options.

Soods good.

[...]

> +(define (elogind-etc-directory config)
> +  "Return the /etc/elogind directory for CONFIG."
> +  (with-imported-modules (source-module-closure '((guix build utils)))
> +    (computed-file
> +     "etc-elogind"
> +
> +     #~(begin
> +         (use-modules (guix build utils))
> +
> +         (define sleep-directory (string-append #$output "/system-sleep/"))
> +         (define shutdown-directory (string-append #$output "/system-shutdown/"))
> +
> +         (define (copy-script file directory)
> +           "Copy FILE into DIRECTORY, giving rx (500) permissions."
> +           (let ((dest (string-append directory "/" (basename file))))
> +             (mkdir-p directory)
> +             (copy-file file dest)
> +             (chmod dest #o500)))
> +
> +         (mkdir-p #$output) ; in case neither directory gets created

Unimportant nitpick: please keep more than 2 spaces between the code and
a comment (I use M-; in Emacs to do so); also prefer to avoid the space
between ';' and the comment for in-line comment only (that's a 'may',
not a 'must' according to our referenced style guide [0] though).

[0]  https://mumble.net/~campbell/scheme/style.txt

> +         (for-each
> +          (lambda (f) (copy-script f sleep-directory))

I've move the copy-script on its own line under the lambda, which is
more conventional.

> +          '#$(elogind-system-sleep-hook-files config))j
> +         (for-each
> +          (lambda (f) (copy-script f shutdown-directory))

Likewise.

Other than these tiny cosmetic things, it LGTM:

Reviewed-by: Maxim Cournoyer <maxim.cournoyer@gmail>

-- 
Thanks,
Maxim




      reply	other threads:[~2024-12-28  5:48 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-12 11:33 [bug#74819] [PATCH] services: elogind: Support Hook Directories 45mg
2024-12-12 13:00 ` 45mg
2024-12-16  6:26 ` [bug#74819] [PATCH v2] " 45mg
2024-12-16  6:37   ` 45mg
2024-12-18 12:18 ` [bug#74819] [PATCH v3] " 45mg
2024-12-23 18:00   ` Ludovic Courtès
2024-12-27 12:15 ` [bug#74819] [PATCH v4] " 45mg
2024-12-28  5:46   ` Maxim Cournoyer [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87frm8tl52.fsf@gmail.com \
    --to=maxim.cournoyer@gmail.com \
    --cc=45mg.writes@gmail.com \
    --cc=74819@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.