From patchwork Fri Sep 23 05:00:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Maxim Cournoyer X-Patchwork-Id: 42868 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 2F6CC27BBEA; Fri, 23 Sep 2022 06:05:47 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_INVALID,DKIM_SIGNED,FREEMAIL_FROM,MAILING_LIST_MULTI, SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 2C09827BBE9 for ; Fri, 23 Sep 2022 06:05:46 +0100 (BST) Received: from localhost ([::1]:49670 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1obasj-0005R8-BE for patchwork@mira.cbaines.net; Fri, 23 Sep 2022 01:05:45 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:34820) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1obapE-0003WA-El for guix-patches@gnu.org; Fri, 23 Sep 2022 01:02:09 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:39969) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1obapE-000292-6d for guix-patches@gnu.org; Fri, 23 Sep 2022 01:02:08 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1obapD-000568-Uf for guix-patches@gnu.org; Fri, 23 Sep 2022 01:02:07 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#58014] [PATCH 13/15] services: Add dconf-service-type. Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 23 Sep 2022 05:02:07 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 58014 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 58014@debbugs.gnu.org Cc: Maxim Cournoyer Received: via spool by 58014-submit@debbugs.gnu.org id=B58014.166390932719585 (code B ref 58014); Fri, 23 Sep 2022 05:02:07 +0000 Received: (at 58014) by debbugs.gnu.org; 23 Sep 2022 05:02:07 +0000 Received: from localhost ([127.0.0.1]:39044 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obapC-00055g-Ch for submit@debbugs.gnu.org; Fri, 23 Sep 2022 01:02:07 -0400 Received: from mail-qk1-f172.google.com ([209.85.222.172]:43787) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1obap7-000542-3H for 58014@debbugs.gnu.org; Fri, 23 Sep 2022 01:02:04 -0400 Received: by mail-qk1-f172.google.com with SMTP id o7so7595290qkj.10 for <58014@debbugs.gnu.org>; Thu, 22 Sep 2022 22:02:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date; bh=U1HkKxRdYtzaXlosQJop0EQ8TbtfcuxI0l5QCODE6Ps=; b=a7ZfjfYwIPVVEonuIm45c9oN403tziBQgrjROFMMgO2WhDU5tgVYKcLkAKnnt2yQWP zx9TH/CB5sF7/B2DQG0dQQvLoOc0GFdy4GLgVadXbn0zCJYQdy6teU4cjO0iEAv0LbQ5 jlC6+ifsIQS9CCN1GBeGgU3fhYNhpbHRwpLIjp6JO/XF3Yp7HKdtwfFvDh9JOxOsGusz oXRUTKi0I8B/eDz45f8z061jKnl2ph4dUgHo3QqbFTWJiLpCMv2KyORWq177UpFmKoDq cGEfrZFF9epBjAoES9p7jtEVz233kWFBXlKV9rfA4Ezm5k2AqUWaO0lbuXgEMkya85dH t4GQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date; bh=U1HkKxRdYtzaXlosQJop0EQ8TbtfcuxI0l5QCODE6Ps=; b=CJWEnqx+QkUJecAer1LKt/NvmL/QDl/wgFQGeMZac/gpMsG63ASRA4TxLqcGO2LMtt J85kyDa6zzLEKU7UcOM/Pia6+npJ58248E8Ym9gVR8Tt6Ya0hiBcqylIMZHF/0fvniOR H0S1+8M+luliXvMhLqvMvCsnqsvQsk7XZyNlFWnT106Cwcm3drz7ZiELCOq5ylRI4Zqj /tidgjE2yJakIyljWWpU4mMguFpUo6qRCx15wCKFTSqR+VJQtuBLtTQAG0llMx9PCVL8 HuCgFiopfGBTYWSHeKOas4rVOrYHdluvcJBcJr5aOh799/Sel3r3W1slLTHs1anOcvrT sehw== X-Gm-Message-State: ACrzQf1oIl1KbJJWliwZ1LVmgvBbJfLIjb6TGLtpFP+qqemVq9K2LLbM 1lrPcl8Vc/C9klWrH4rVq9IhZyjCEHA= X-Google-Smtp-Source: AMsMyM4mS3TC346fbRtkwXiUFwecEo36btwyT6MhPsrJIimAMQtSqB4QUgnU2SmZLwuxI3I2WsR+/w== X-Received: by 2002:a05:620a:240f:b0:6ce:9ac3:5f92 with SMTP id d15-20020a05620a240f00b006ce9ac35f92mr4599781qkn.707.1663909315478; Thu, 22 Sep 2022 22:01:55 -0700 (PDT) Received: from localhost.localdomain ([2607:fad8:4:3::1001]) by smtp.gmail.com with ESMTPSA id de4-20020a05620a370400b006bbb07ebd83sm5263534qkb.108.2022.09.22.22.01.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Sep 2022 22:01:55 -0700 (PDT) From: Maxim Cournoyer Date: Fri, 23 Sep 2022 01:00:40 -0400 Message-Id: <20220923050042.29893-13-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220923050042.29893-1-maxim.cournoyer@gmail.com> References: <20220923050042.29893-1-maxim.cournoyer@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches This allows the dconf profile directive "system-db:" to look up profiles by name from under /etc/dconf/db/. * gnu/services/xorg.scm (dconf-keyfile, dconf-profile): New procedures. (dconf-profiles?): New predicate. (dconf-configuration): New procedure. (dconf-profile->profile-file): Likewise. (dconf-profile->db-keyfile): Likewise. (dconf-profile->db-keyfile-dir): Likewise. (dconf-profile->db): Likewise. (dconf-profile->files): Likewise. (dconf-service-type): New service type. --- gnu/services/xorg.scm | 109 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 109 insertions(+) diff --git a/gnu/services/xorg.scm b/gnu/services/xorg.scm index eb77822741..9205c6f9f4 100644 --- a/gnu/services/xorg.scm +++ b/gnu/services/xorg.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2021 Oleg Pykhalov ;;; Copyright © 2021 Josselin Poiret ;;; Copyright © 2022 Chris Marusich +;;; Copyright © 2022 Maxim Cournoyer ;;; ;;; This file is part of GNU Guix. ;;; @@ -32,6 +33,7 @@ (define-module (gnu services xorg) #:autoload (gnu services sddm) (sddm-service-type) #:use-module (gnu artwork) #:use-module (gnu services) + #:use-module (gnu services configuration) #:use-module (gnu services shepherd) #:use-module (gnu system pam) #:use-module (gnu system setuid) @@ -114,6 +116,13 @@ (define-module (gnu services xorg) localed-configuration? localed-service-type + dconf-keyfile + dconf-profile + dconf-profile-name + dconf-profile-content + dconf-profile-keyfile + dconf-service-type + gdm-configuration gdm-service-type @@ -803,6 +812,106 @@ (define localed-service-type the GNOME desktop environment.") (default-value (localed-configuration))))) + +;;; +;;; Dconf. +;;; + +(define-maybe text-config) + +(define-configuration/no-serialization dconf-keyfile + (name string + "The file name of the associated keyfile, e.g. \"00-login-screen\".") + (content text-config "The content of the associated keyfile.")) + +(define-configuration/no-serialization dconf-profile + (name string "The file name of the dconf system profile, which should match +the name of a user for which the profile is to be used with. To have the +profile used, the environment variable \"DCONF_PROFILE\" should be set to the +profile file, e.g.: +@example + export DCONF_PROFILE=/etc/dconf/profile/gdm +@end example") + (content maybe-text-config "The content of the Dconf profile. Unless +provided, it defaults to include the user database (\"user-db:NAME\") as well +as the system database (\"system-db:NAME\"), which corresponds to the +generated database, @file{/etc/dconf/db/NAME}.") + (keyfile dconf-keyfile "The keyfile associated with the profile")) + +(define dconf-profiles? + (list-of dconf-profile?)) + +(define-configuration/no-serialization dconf-configuration + (profiles dconf-profiles "The list of objects to populate.")) + +(define (dconf-profile->profile-file profile) + "Given PROFILE, a object, return a dconf profile file." + (let ((name (dconf-profile-name profile)) + (content (dconf-profile-content profile))) + (apply mixed-text-file + name + (if (maybe-value-set? content) + (interpose content "\n" 'suffix) + (interpose (list (string-append "user-db:" name) + (string-append "system-db:" name)) + "\n" 'suffix))))) + +(define (dconf-profile->db-keyfile profile) + "Given PROFILE, a object, return a dconf profile file." + (let ((keyfile (dconf-profile-keyfile profile))) + (apply mixed-text-file (dconf-keyfile-name keyfile) + (interpose (dconf-keyfile-content keyfile) "\n" 'suffix)))) + +(define (dconf-profile->db-keyfile-dir profile) + "Wrap the keyfile in a directory, to satisfy 'dconf compile'." + (let ((name (dconf-profile-name profile)) + (keyfile-name (dconf-keyfile-name (dconf-profile-keyfile profile)))) + (computed-file name + #~(begin + (mkdir #$output) + (symlink #$(dconf-profile->db-keyfile profile) + (string-append #$output "/" #$keyfile-name)))))) + +(define (dconf-profile->db profile) + "Compile the a object into a GVariant Database file." + (let ((name (dconf-profile-name profile))) + (computed-file + name + (with-imported-modules '((guix build utils)) + #~(begin + (use-modules (guix build utils)) + (setenv "DCONF_PROFILE" #$(dconf-profile->profile-file profile)) + (invoke #$(file-append dconf "/bin/dconf") "compile" + #$output #$(dconf-profile->db-keyfile-dir profile))))))) + +(define (dconf-profile->files profile) + "Given PROFILE, a object, return a dconf directory +containing the associated profile, keyfile and database files to be assembled +under /etc." + (let ((name (dconf-profile-name profile)) + (keyfile-name (dconf-keyfile-name (dconf-profile-keyfile profile)))) + (list (list (string-append "dconf/profile/" name) + (dconf-profile->profile-file profile)) + (list (string-append "dconf/db/" name ".d/" keyfile-name) + (dconf-profile->db-keyfile profile)) + (list (string-append "dconf/db/" name) + (dconf-profile->db profile))))) + +(define dconf-service-type + (service-type + (name 'dconf-profile) + (extensions + (list (service-extension etc-service-type + (lambda (dconf-profiles) + (append-map dconf-profile->files + dconf-profiles))))) + (compose concatenate) + (extend append) + (default-value '()) + (description "Extend the @code{etc-service-type} to populate the file +hierarchy under @file{/etc/dconf} with the objects provided as +argument."))) + ;;; ;;; GNOME Desktop Manager.