unofficial mirror of bug-guix@gnu.org 
 help / color / mirror / code / Atom feed
From: Leo Prikler <leo.prikler@student.tugraz.at>
To: 45836@debbugs.gnu.org
Subject: bug#45836: [PATCH] services: Let cups-service-type reuse base lp group.
Date: Thu, 14 Jan 2021 14:06:11 +0100	[thread overview]
Message-ID: <20210114130610.31936-1-leo.prikler@student.tugraz.at> (raw)
In-Reply-To: <a8a72caf989dc39752a4025c6035d82f346fe116.camel@student.tugraz.at>

* gnu/services/cups.scm (%cups-accounts): Try to use the lp group defined in
%base-groups.
* gnu/system/shadow.scm (account-activation): Delete duplicate (eq?) users
and groups before transforming them to specs and asserting, that names are
unique.
---
 gnu/services/cups.scm | 10 ++++++++--
 gnu/system/shadow.scm |  4 ++--
 2 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/gnu/services/cups.scm b/gnu/services/cups.scm
index f10615e59e..17ed04e58b 100644
--- a/gnu/services/cups.scm
+++ b/gnu/services/cups.scm
@@ -32,7 +32,7 @@
   #:use-module (guix records)
   #:use-module (guix gexp)
   #:use-module (ice-9 match)
-  #:use-module ((srfi srfi-1) #:select (append-map))
+  #:use-module ((srfi srfi-1) #:select (append-map find))
   #:export (cups-service-type
             cups-configuration
             opaque-cups-configuration
@@ -50,7 +50,13 @@
 ;;; Code:
 
 (define %cups-accounts
-  (list (user-group (name "lp") (system? #t))
+  (list (or
+         ;; The "lp" group should already exist; try to reuse it.
+         (find (lambda (group)
+                 (and (user-group? group)
+                      (string=? (user-group-name group) "lp")))
+               %base-groups)
+         (user-group (name "lp") (system? #t)))
         (user-group (name "lpadmin") (system? #t))
         (user-account
          (name "lp")
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index 0538fb1a24..7c57222716 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -321,13 +321,13 @@ of user '~a' is undeclared")
 <user-group> objects.  Raise an error if a user account refers to a undefined
 group."
   (define accounts
-    (filter user-account? accounts+groups))
+    (delete-duplicates (filter user-account? accounts+groups) eq?))
 
   (define user-specs
     (map user-account->gexp accounts))
 
   (define groups
-    (filter user-group? accounts+groups))
+    (delete-duplicates (filter user-group? accounts+groups) eq?))
 
   (define group-specs
     (map user-group->gexp groups))
-- 
2.30.0





  parent reply	other threads:[~2021-01-14 13:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-13  1:09 bug#45836: cups-service-type duplicates lp group Leo Prikler
2021-01-13 11:28 ` Ludovic Courtès
2021-01-13 12:06   ` Leo Prikler
2021-01-14 11:38     ` Ludovic Courtès
2021-01-14 13:06 ` Leo Prikler [this message]
2021-01-16 18:37   ` bug#45836: [PATCH] services: Let cups-service-type reuse base " Ludovic Courtès
2021-01-16 19:49     ` Leo Prikler
2021-01-18 14:47       ` Ludovic Courtès
2021-01-20  8:16         ` Leo Prikler

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

  List information: https://guix.gnu.org/

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

  git send-email \
    --in-reply-to=20210114130610.31936-1-leo.prikler@student.tugraz.at \
    --to=leo.prikler@student.tugraz.at \
    --cc=45836@debbugs.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 public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).