* [RFC] refactoring extra-special-file; an /etc/tmpfiles/ equivalent
@ 2023-01-21 15:29 Attila Lendvai
2023-02-10 12:05 ` Attila Lendvai
0 siblings, 1 reply; 3+ messages in thread
From: Attila Lendvai @ 2023-01-21 15:29 UTC (permalink / raw)
To: guix-devel
hello Guix,
context 1:
i want to write a string into a file at boot to disable wake-up by my keyboard (so that it doesn't immediately wake up my laptop after i suspend it). it requires doing this once per boot:
echo XHC >/proc/acpi/wakeup
the standard solution on systemd distros is to use a /etc/tmpfiles.d/disable-usb-wake.conf file, which systemd interprets (see e.g. https://forums.linuxmint.com/viewtopic.php?f=42&t=312953).
context 2:
i need to create an empty directory in an image created by `guix system vm ...` (for "reasons"; this is the simplest way i'm aware of to hack forward).
in Guix we have extra-special-file (what a strange name!) that in fact can do one thing: a (single shot?) shepherd service that can symlink something somewhere.
what i need is something like extra-special-file, but with a few more keyword arguments that would allow creating empty directories, and appending/overwriting files with content given as literals.
or something else that i'm not aware of?
solution 1:
i think i could backwards compatibly extend extra-special-file with the keyword args.
solution 2:
introduce a new abstraction (preferrably with a better name), and mark extra-special-file obsolete.
dear maintainers, any thoughts on which way i should start digging?
also, any suggestion for the API? the naming of the keyword args?
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“Angry people want you to see how powerful they are… loving people want you to see how powerful You are.”
— Chief Red Eagle
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] refactoring extra-special-file; an /etc/tmpfiles/ equivalent
2023-01-21 15:29 [RFC] refactoring extra-special-file; an /etc/tmpfiles/ equivalent Attila Lendvai
@ 2023-02-10 12:05 ` Attila Lendvai
2023-02-10 13:38 ` Attila Lendvai
0 siblings, 1 reply; 3+ messages in thread
From: Attila Lendvai @ 2023-02-10 12:05 UTC (permalink / raw)
To: Attila Lendvai; +Cc: guix-devel
> i want to write a string into a file at boot to disable wake-up by
> my keyboard (so that it doesn't immediately wake up my laptop after
> i suspend it). it requires doing this once per boot:
>
> echo XHC >/proc/acpi/wakeup
>
> the standard solution on systemd distros is to use a
> /etc/tmpfiles.d/disable-usb-wake.conf file, which systemd interprets
> (see e.g. https://forums.linuxmint.com/viewtopic.php?f=42&t=312953).
FTR, the "guixy way" currently is to add a service like this:
(simple-service 'disable-keyboard-wakeup activation-service-type
#~(begin
(use-modules (ice-9 regex))
(use-modules (ice-9 textual-ports))
(when (string-match "XHC\t S3\t\\*enabled"
(call-with-input-file "/proc/acpi/wakeup"
get-string-all))
(display "Turning off usb wakeup\n")
(with-output-to-file "/proc/acpi/wakeup"
(lambda _
(display "XHC"))))))
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
Censorship is telling a man he can't have a steak just because a baby can't chew it.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [RFC] refactoring extra-special-file; an /etc/tmpfiles/ equivalent
2023-02-10 12:05 ` Attila Lendvai
@ 2023-02-10 13:38 ` Attila Lendvai
0 siblings, 0 replies; 3+ messages in thread
From: Attila Lendvai @ 2023-02-10 13:38 UTC (permalink / raw)
To: Attila Lendvai; +Cc: guix-devel
> FTR, the "guixy way" currently is to add a service like this:
as mirai kindly instructed me on IRC, even though it's a somewhat widely spread solution, this has issues, as documented in: https://issues.guix.gnu.org/60657
instead, the proper way is to add a full-fledged one-shot shepherd service:
(simple-service
'disable-keyboard-wakeup
shepherd-root-service-type
(list
(shepherd-service
(requirement '(file-systems))
(provision '(disable-keyboard-wakeup))
(documentation "echo XHC >/proc/acpi/wakeup, so that my USB Kinesis keyboard doesn't wake up the laptop right after a suspend")
(one-shot? #t)
(start
#~(begin
(use-modules (ice-9 regex))
(use-modules (ice-9 textual-ports))
(lambda _
(when (string-match "XHC\t S3\t\\*enabled"
(call-with-input-file "/proc/acpi/wakeup"
get-string-all))
(display "Turning off usb wakeup\n")
(with-output-to-file "/proc/acpi/wakeup"
(lambda _
(display "XHC"))))))))))
and while we are at it, a newcomer feedback:
it's super confusing that there are 'guix services' and 'shepherd services', and they are rather different animals with very similar names, and they are present in a very confined context.
--
• attila lendvai
• PGP: 963F 5D5F 45C7 DFCD 0A39
--
“I will have to remember ‘I am here today to cross the swamp, not to fight all the alligators.’”
— Rosamund and Benjamin Zander, 'The Art of Possibility' (2002)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2023-02-10 13:39 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-21 15:29 [RFC] refactoring extra-special-file; an /etc/tmpfiles/ equivalent Attila Lendvai
2023-02-10 12:05 ` Attila Lendvai
2023-02-10 13:38 ` Attila Lendvai
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.