diff mbox series

[bug#56699] gnu: greetd-service-type: Add greeter-extra-groups config field.

Message ID 20220722114501.5273-1-mail@muradm.net
State Accepted
Headers show
Series [bug#56699] gnu: greetd-service-type: Add greeter-extra-groups config field. | expand

Checks

Context Check Description
cbaines/comparison success View comparision
cbaines/git-branch success View Git branch
cbaines/applying patch success View Laminar job
cbaines/issue success View issue

Commit Message

muradm July 22, 2022, 11:45 a.m. UTC
* gnu/services/base.scm (greetd-service-type): Added configurable groups.
[extensions]: Switching accounts-service-type from const to function.
(<greetd-configuration>): Added greeter-extra-groups field of type list.
(greetd-accounts-service): New variable, function returning list necessary
accounts for accounts-service-type, including the greeter-extra-groups.
(%greetd-accounts): Removed.
* doc/guix.texi: Mention greeter-extra-groups field with example.
---
 doc/guix.texi         |  8 ++++++++
 gnu/services/base.scm | 28 +++++++++++++++-------------
 2 files changed, 23 insertions(+), 13 deletions(-)

Comments

\( July 24, 2022, 4:31 p.m. UTC | #1
On Fri Jul 22, 2022 at 12:45 PM BST, muradm wrote:
> +         ;; video group is required for graphical greeters.
> +         (supplementary-groups
> +          (append
> +           '("video")
> +           (greetd-greeter-extra-groups config)))
Change to (cons "video" (greetd-greeter-extra-groups config)) or maybe
use cons* if you think there's a possibility that more groups will later
need to be added.

Otherwise SGTM :)

    -- (
muradm Aug. 5, 2022, 6:44 a.m. UTC | #2
supplimentary-groups receiving a list, so I find it more 
informative
when adding apples with apples. And yes with high enough chance
more groups could be added to the list of defaults.

Is there any preference on using cons* in favour of more readable
append?

thanks in advance,
muradm

"(" <paren@disroot.org> writes:

> On Fri Jul 22, 2022 at 12:45 PM BST, muradm wrote:
>> +         ;; video group is required for graphical greeters.
>> +         (supplementary-groups
>> +          (append
>> +           '("video")
>> +           (greetd-greeter-extra-groups config)))
> Change to (cons "video" (greetd-greeter-extra-groups config)) or 
> maybe
> use cons* if you think there's a possibility that more groups 
> will later
> need to be added.
>
> Otherwise SGTM :)
>
>     -- (
Liliana Marie Prikler Aug. 5, 2022, 7:54 a.m. UTC | #3
Am Freitag, dem 05.08.2022 um 09:44 +0300 schrieb muradm:
> supplimentary-groups receiving a list, so I find it more 
> informative when adding apples with apples. And yes with high enough
> chance more groups could be added to the list of defaults.
What are "the defaults" here, though?  A sequence of hard-coded values
known at compile time.  There is no need to make that sequence a list.

> Is there any preference on using cons* in favour of more readable
> append?
Use of cons or cons* signals that you are only expecting user-supplied
groups to be a list and everything else known values.  Use of append on
the other hand signals that you are expecting multiple lists, which
even if you did are not currently present.

Cheers
muradm Aug. 7, 2022, 9:42 p.m. UTC | #4
Correct, no defaults are given. Attached is v2. Defaults
non existent, append/cons* irrelevant.



thanks in advance,
muradm

Liliana Marie Prikler <liliana.prikler@ist.tugraz.at> writes:

> Am Freitag, dem 05.08.2022 um 09:44 +0300 schrieb muradm:
>> supplimentary-groups receiving a list, so I find it more
>> informative when adding apples with apples. And yes with high 
>> enough
>> chance more groups could be added to the list of defaults.
> What are "the defaults" here, though?  A sequence of hard-coded 
> values
> known at compile time.  There is no need to make that sequence a 
> list.
>
>> Is there any preference on using cons* in favour of more 
>> readable
>> append?
> Use of cons or cons* signals that you are only expecting 
> user-supplied
> groups to be a list and everything else known values.  Use of 
> append on
> the other hand signals that you are expecting multiple lists, 
> which
> even if you did are not currently present.
>
> Cheers
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 3c5864ec1a..51678b7f19 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -18493,6 +18493,14 @@  the 'root' account has just been created.
 @item @code{terminals} (default: @code{'()})
 List of @code{greetd-terminal-configuration} per terminal for which
 @code{greetd} should be started.
+
+@item @code{greeter-extra-groups} (default: @code{'()})
+List of groups which should be added to @code{greeter} user. For instance:
+@lisp
+(greeter-extra-groups '("seat"))
+@end lisp
+Note that, however it will fail if @code{seatd-service-type} is not present,
+or to be more specific, @code{seat} group is not present.
 @end table
 @end deftp
 
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 27eae75c46..94c8dcac2a 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -2918,17 +2918,6 @@  (define (make-greetd-terminal-configuration-file config)
      "user = " default-session-user "\n"
      "command = " default-session-command "\n")))
 
-(define %greetd-accounts
-  (list (user-account
-         (name "greeter")
-         (group "greeter")
-         ;; video group is required for graphical greeters.
-         (supplementary-groups '("video"))
-         (system? #t))
-        (user-group
-         (name "greeter")
-         (system? #t))))
-
 (define %greetd-file-systems
   (list (file-system
           (device "none")
@@ -2956,7 +2945,20 @@  (define-record-type* <greetd-configuration>
   greetd-configuration?
   (motd greetd-motd (default %default-motd))
   (allow-empty-passwords? greetd-allow-empty-passwords? (default #t))
-  (terminals greetd-terminals (default '())))
+  (terminals greetd-terminals (default '()))
+  (greeter-extra-groups greetd-greeter-extra-groups (default '())))
+
+(define (greetd-accounts-service config)
+  (list (user-group (name "greeter") (system? #t))
+        (user-account
+         (name "greeter")
+         (group "greeter")
+         ;; video group is required for graphical greeters.
+         (supplementary-groups
+          (append
+           '("video")
+           (greetd-greeter-extra-groups config)))
+         (system? #t))))
 
 (define (make-greetd-pam-mount-conf-file config)
   (computed-file
@@ -3033,7 +3035,7 @@  (define greetd-service-type
 login manager daemon.")
    (extensions
     (list
-     (service-extension account-service-type (const %greetd-accounts))
+     (service-extension account-service-type greetd-accounts-service)
      (service-extension file-system-service-type (const %greetd-file-systems))
      (service-extension etc-service-type greetd-etc-service)
      (service-extension pam-root-service-type greetd-pam-service)