From patchwork Fri Mar 11 21:34:16 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 37754 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 F23F227BBE9; Fri, 11 Mar 2022 21:35:29 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED 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 53D7827BBE9 for ; Fri, 11 Mar 2022 21:35:29 +0000 (GMT) Received: from localhost ([::1]:58708 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSmv1-0006bO-WF for patchwork@mira.cbaines.net; Fri, 11 Mar 2022 16:35:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48566) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSmud-0006at-Cj for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44629) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSmud-0000zG-4m for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nSmud-00043v-0G for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#54344] [PATCH 1/3] graph: Factorize 'lookup-backend'. References: <20220311213233.12415-1-ludo@gnu.org> In-Reply-To: <20220311213233.12415-1-ludo@gnu.org> Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 11 Mar 2022 21:35:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54344 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54344@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 54344-submit@debbugs.gnu.org id=B54344.164703447315548 (code B ref 54344); Fri, 11 Mar 2022 21:35:02 +0000 Received: (at 54344) by debbugs.gnu.org; 11 Mar 2022 21:34:33 +0000 Received: from localhost ([127.0.0.1]:38519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSmu8-00042g-KJ for submit@debbugs.gnu.org; Fri, 11 Mar 2022 16:34:33 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42810) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSmu7-00042O-Ij for 54344@debbugs.gnu.org; Fri, 11 Mar 2022 16:34:32 -0500 Received: from [2001:470:142:3::e] (port=33216 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSmu2-0000ov-A7; Fri, 11 Mar 2022 16:34:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:Date:Subject:To:From:in-reply-to: references; bh=MXM8oyYtSLL9FSzjt0xCobYF969sfKjV50Q+9x4wJ2U=; b=dZQeVWSrR1gXt9 laOTTWUDiWMMCk1l69cxu5VKG+gdY44pTzHQgSvDYPuuAlVQv7HgYf40uI5JT8eRmr1j1dkTKVxot EsuDTOeGude5Dq1x7ECZqp2fJxLfU/elDkyjIxuER+uC70ydEcFMfjzgqkeyFTwF377v/oyEgWlVc W9dbNAP1EQvuX2jGfhUielB/xSVhiJ33EHZ4x0iuoZ8HRTRzKsBKxE29Wrg+ayUC9LAjC0KDtrwl3 lyvBGUaL4fh9rfmgGHg8aJ7J0XtDKMRUFc6p9k76KUZYxwIC1puM2i5HHqtAh/raFSqKS8UEZMjNQ R5X8zI8cJUmygmSFTBtg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:58671 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSmu1-0003hy-Pj; Fri, 11 Mar 2022 16:34:25 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 11 Mar 2022 22:34:16 +0100 Message-Id: <20220311213418.12472-1-ludo@gnu.org> X-Mailer: git-send-email 2.34.0 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 * guix/graph.scm (lookup-backend): New procedure. * guix/scripts/graph.scm (lookup-backend): Remove. * guix/scripts/system.scm (lookup-backend): Remove. * po/guix/POTFILES.in: Add 'guix/graph.scm'. --- guix/graph.scm | 14 +++++++++++++- guix/scripts/graph.scm | 9 +-------- guix/scripts/system.scm | 9 +-------- po/guix/POTFILES.in | 1 + 4 files changed, 16 insertions(+), 17 deletions(-) diff --git a/guix/graph.scm b/guix/graph.scm index 3a1cab244b..41219ab67d 100644 --- a/guix/graph.scm +++ b/guix/graph.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015, 2016, 2020, 2021 Ludovic Courtès +;;; Copyright © 2015-2016, 2020-2022 Ludovic Courtès ;;; Copyright © 2016 Ricardo Wurmus ;;; ;;; This file is part of GNU Guix. @@ -22,10 +22,13 @@ (define-module (guix graph) #:use-module (guix monads) #:use-module (guix records) #:use-module (guix sets) + #:autoload (guix diagnostics) (formatted-message) + #:autoload (guix i18n) (G_) #:use-module (rnrs io ports) #:use-module (srfi srfi-1) #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) + #:use-module (srfi srfi-34) #:use-module (ice-9 match) #:use-module (ice-9 vlist) #:export (node-type @@ -47,6 +50,8 @@ (define-module (guix graph) %graph-backends %d3js-backend %graphviz-backend + lookup-backend + graph-backend? graph-backend graph-backend-name @@ -335,6 +340,13 @@ (define %graph-backends %d3js-backend %cypher-backend)) +(define (lookup-backend name) + "Return the graph backend called NAME. Raise an error if it is not found." + (or (find (lambda (backend) + (string=? (graph-backend-name backend) name)) + %graph-backends) + (raise (formatted-message (G_ "~a: unknown graph backend") name)))) + (define* (export-graph sinks port #:key reverse-edges? node-type (max-depth +inf.0) diff --git a/guix/scripts/graph.scm b/guix/scripts/graph.scm index 8943e87099..535875c858 100644 --- a/guix/scripts/graph.scm +++ b/guix/scripts/graph.scm @@ -1,5 +1,5 @@ ;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020, 2021 Ludovic Courtès +;;; Copyright © 2015-2022 Ludovic Courtès ;;; Copyright © 2019 Simon Tournier ;;; ;;; This file is part of GNU Guix. @@ -429,13 +429,6 @@ (define (lookup-node-type name) %node-types) (leave (G_ "~a: unknown node type~%") name))) -(define (lookup-backend name) - "Return the graph backend called NAME. Raise an error if it is not found." - (or (find (lambda (backend) - (string=? (graph-backend-name backend) name)) - %graph-backends) - (leave (G_ "~a: unknown backend~%") name))) - (define (list-node-types) "Print the available node types along with their synopsis." (display (G_ "The available node types are:\n")) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index a6e717d52c..6f7dcd4643 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -51,7 +51,7 @@ (define-module (guix scripts system) delete-matching-generations) #:autoload (guix scripts pull) (channel-commit-hyperlink) #:autoload (guix graph) (export-graph node-type - graph-backend-name %graph-backends) + graph-backend-name lookup-backend) #:use-module (guix scripts graph) #:use-module (guix scripts system reconfigure) #:use-module (guix build utils) @@ -887,13 +887,6 @@ (define bootcfg (register-root* (list output) gc-root)) (return output))))))))) -(define (lookup-backend name) ;TODO: factorize - "Return the graph backend called NAME. Raise an error if it is not found." - (or (find (lambda (backend) - (string=? (graph-backend-name backend) name)) - %graph-backends) - (leave (G_ "~a: unknown backend~%") name))) - (define* (export-extension-graph os port #:key (backend (lookup-backend "graphviz"))) "Export the service extension graph of OS to PORT using BACKEND." diff --git a/po/guix/POTFILES.in b/po/guix/POTFILES.in index d97ba8c209..49a8edfef3 100644 --- a/po/guix/POTFILES.in +++ b/po/guix/POTFILES.in @@ -66,6 +66,7 @@ guix/ci.scm guix/cve.scm guix/git-authenticate.scm guix/gnupg.scm +guix/graph.scm guix/lint.scm guix/scripts/download.scm guix/scripts/package.scm From patchwork Fri Mar 11 21:34:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 37753 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 99A2F27BBEB; Fri, 11 Mar 2022 21:35:29 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED 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 5FE4F27BBEA for ; Fri, 11 Mar 2022 21:35:29 +0000 (GMT) Received: from localhost ([::1]:58724 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSmv2-0006cE-IL for patchwork@mira.cbaines.net; Fri, 11 Mar 2022 16:35:28 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48574) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSmud-0006b1-Og for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44630) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSmud-00012v-Gp for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nSmud-000442-Ec for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#54344] [PATCH 2/3] home: services: Export record type accessors. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 11 Mar 2022 21:35:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54344 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54344@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 54344-submit@debbugs.gnu.org id=B54344.164703447415562 (code B ref 54344); Fri, 11 Mar 2022 21:35:03 +0000 Received: (at 54344) by debbugs.gnu.org; 11 Mar 2022 21:34:34 +0000 Received: from localhost ([127.0.0.1]:38523 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSmuA-00042v-6R for submit@debbugs.gnu.org; Fri, 11 Mar 2022 16:34:34 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42814) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSmu8-00042P-1f for 54344@debbugs.gnu.org; Fri, 11 Mar 2022 16:34:32 -0500 Received: from [2001:470:142:3::e] (port=33218 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSmu2-0000p1-Pv; Fri, 11 Mar 2022 16:34:26 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=/n+C3j+yTt9wDUCrwygMxduJh0mPz8d1Qcu1JXTUqQU=; b=NEBxqgilZ2fGunWqDkXR fXPWdhkzLp4IbY8bFOB8zV0mJCa5uIR67ALWRABjqsWVFuUgXn7puy6/Z66Tqxrcr2IghetqATHkN 4Tp6Z+JsLQ0lQHjNm5rN/Y1McGKl/mLYHto+Tz8SsVRb4VpDGAXjFSK0Xdj2oeIWLlphAulwNLGbl Aqu3eBZpDBVuqCqTJT4VEZ35k6mhPMksR7EZxCS2d0LvzE9dOCHhmCORt4x8G71XRHowEB6IPLFdr AArsJ9VZTE/cAy12W+JOqzjA5uZMH2ovJ79jMZ4ZgY1wxNNy4pQAuf7BBSFZNRju+DRgWEnLN8HSm NKgVaYuW0oKOrg==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:58671 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSmu2-0003hy-CV; Fri, 11 Mar 2022 16:34:26 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 11 Mar 2022 22:34:17 +0100 Message-Id: <20220311213418.12472-2-ludo@gnu.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220311213418.12472-1-ludo@gnu.org> References: <20220311213418.12472-1-ludo@gnu.org> 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 * gnu/home/services/shepherd.scm: Export accessors. Re-export accessors. --- gnu/home/services/shepherd.scm | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/gnu/home/services/shepherd.scm b/gnu/home/services/shepherd.scm index 7a9cc064bb..feff130259 100644 --- a/gnu/home/services/shepherd.scm +++ b/gnu/home/services/shepherd.scm @@ -24,12 +24,27 @@ (define-module (gnu home services shepherd) #:use-module (guix sets) #:use-module (guix gexp) #:use-module (guix records) - #:use-module (srfi srfi-1) - #:export (home-shepherd-service-type - home-shepherd-configuration) + + home-shepherd-configuration + home-shepherd-configuration? + home-shepherd-configuration-shepherd + home-shepherd-configuration-auto-start? + home-shepherd-configuration-services) #:re-export (shepherd-service + shepherd-service? + shepherd-service-documentation + shepherd-service-provision + shepherd-service-canonical-name + shepherd-service-requirement + shepherd-service-one-shot? + shepherd-service-respawn? + shepherd-service-start + shepherd-service-stop + shepherd-service-auto-start? + shepherd-service-modules + shepherd-action)) (define-record-type* From patchwork Fri Mar 11 21:34:18 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ludovic_Court=C3=A8s?= X-Patchwork-Id: 37755 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 E20F027BBEB; Fri, 11 Mar 2022 21:35:31 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-3.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,URIBL_BLOCKED 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 1250327BBEA for ; Fri, 11 Mar 2022 21:35:31 +0000 (GMT) Received: from localhost ([::1]:58858 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nSmv4-0006hA-96 for patchwork@mira.cbaines.net; Fri, 11 Mar 2022 16:35:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:48576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSmue-0006bG-8V for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:04 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:44631) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSmue-000136-0U for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nSmud-000449-UM for guix-patches@gnu.org; Fri, 11 Mar 2022 16:35:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#54344] [PATCH 3/3] guix home: Implement the 'extension-graph' and 'shepherd-graph' actions. Resent-From: Ludovic =?utf-8?q?Court=C3=A8s?= Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Fri, 11 Mar 2022 21:35:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 54344 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 54344@debbugs.gnu.org Cc: Ludovic =?utf-8?q?Court=C3=A8s?= Received: via spool by 54344-submit@debbugs.gnu.org id=B54344.164703447815572 (code B ref 54344); Fri, 11 Mar 2022 21:35:03 +0000 Received: (at 54344) by debbugs.gnu.org; 11 Mar 2022 21:34:38 +0000 Received: from localhost ([127.0.0.1]:38525 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSmuA-00042x-Ea for submit@debbugs.gnu.org; Fri, 11 Mar 2022 16:34:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:42822) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nSmu8-00042R-KN for 54344@debbugs.gnu.org; Fri, 11 Mar 2022 16:34:33 -0500 Received: from [2001:470:142:3::e] (port=33220 helo=fencepost.gnu.org) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nSmu3-0000pJ-Cz; Fri, 11 Mar 2022 16:34:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=gnu.org; s=fencepost-gnu-org; h=MIME-Version:References:In-Reply-To:Date:Subject:To: From; bh=bgMN7RQwj2jm+2+WatcTQlSz40Kns5hXaSha/yMFkk4=; b=q9m0L1S3odorCFrnu4Fy fXrf9fvy5aLxjqoI5L72m38xXH0crsA0RnsJgK4Q4uPPNvwefVDjLS/ldb69cff2sPLToVRslclnn qh6+fr3BQU7BZODUACRZ3O37XJl0XcrsWFY3GfiS6o/IMr3lazJy+FmYt855lpixSFgeYS8Wwaukj v1EtE3w7RfAnopNVl+36+gbQYLrMsYSQWdY/8QbYMX0bLLK19S//p7XSt8gvm/ut6tu4uY95eQXSL A6/1Bkc5Yhsy6929q4RDpEdT0TkrKdNLnB3mSVTQRm8xlP16n7+AHKdpYfVe5pAiIY3QMcQK8byhh Tc+dT+TXPkS+LQ==; Received: from 91-160-117-201.subs.proxad.net ([91.160.117.201]:58671 helo=gnu.org) by fencepost.gnu.org with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nSmu2-0003hy-VY; Fri, 11 Mar 2022 16:34:27 -0500 From: Ludovic =?utf-8?q?Court=C3=A8s?= Date: Fri, 11 Mar 2022 22:34:18 +0100 Message-Id: <20220311213418.12472-3-ludo@gnu.org> X-Mailer: git-send-email 2.34.0 In-Reply-To: <20220311213418.12472-1-ludo@gnu.org> References: <20220311213418.12472-1-ludo@gnu.org> 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 Until now these two actions were silently ignored. * guix/scripts/home.scm (show-help, %options): Add "--graph-backend". (%default-options): Add 'graph-backend' key. (export-extension-graph, export-shepherd-graph): New procedures. (perform-action): Add #:graph-backend parameter. Add cases for the 'extension-graph' and 'shepherd-graph' actions. (process-action): Pass #:graph-backend to 'perform-action'. * guix/scripts/system.scm (service-node-type) (shepherd-service-node-type): Export * tests/guix-home.sh: Add tests. * doc/guix.texi (Invoking guix home): Document it. --- doc/guix.texi | 31 +++++++++++ guix/scripts/home.scm | 117 ++++++++++++++++++++++++++++++---------- guix/scripts/system.scm | 5 +- tests/guix-home.sh | 8 +++ 4 files changed, 131 insertions(+), 30 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 4b71fb7010..e7d862f5be 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -38848,7 +38848,38 @@ environment. Note that not every home service that exists is supported $ guix home import ~/guix-config guix home: '/home/alice/guix-config' populated with all the Home configuration files @end example +@end table +And there's more! @command{guix home} also provides the follow +sub-commands to visualize how the services of your home environment +relate to one another: + +@table @code +@cindex service extension graph, of a home environment +@item extension-graph +Emit to standard output the @dfn{service extension graph} of the home +environment defined in @var{file} (@pxref{Service Composition}, for more +information on service extensions). By default the output is in +Dot/Graphviz format, but you can choose a different format with +@option{--graph-backend}, as with @command{guix graph} (@pxref{Invoking +guix graph, @option{--backend}}): + +The command: + +@example +$ guix home extension-graph @var{file} | xdot - +@end example + +shows the extension relations among services. + +@cindex Shepherd dependency graph, for a home environment +@item shepherd-graph +Emit to standard output the @dfn{dependency graph} of shepherd services +of the home environment defined in @var{file}. @xref{Shepherd +Services}, for more information and for an example graph. + +Again, the default output format is Dot/Graphviz, but you can pass +@option{--graph-backend} to select a different one. @end table @var{options} can contain any of the common build options (@pxref{Common diff --git a/guix/scripts/home.scm b/guix/scripts/home.scm index 837fd96361..db98a1df48 100644 --- a/guix/scripts/home.scm +++ b/guix/scripts/home.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2021 Xinglu Chen ;;; Copyright © 2021 Pierre Langlois ;;; Copyright © 2021 Oleg Pykhalov +;;; Copyright © 2022 Ludovic Courtès ;;; ;;; This file is part of GNU Guix. ;;; @@ -25,6 +26,9 @@ (define-module (guix scripts home) #:use-module (gnu packages) #:use-module (gnu home) #:use-module (gnu home services) + #:autoload (gnu home services shepherd) (home-shepherd-service-type + home-shepherd-configuration-services + shepherd-service-requirement) #:use-module (guix channels) #:use-module (guix derivations) #:use-module (guix ui) @@ -33,13 +37,16 @@ (define-module (guix scripts home) #:use-module (guix profiles) #:use-module (guix store) #:use-module (guix utils) + #:autoload (guix graph) (lookup-backend export-graph) #:use-module (guix scripts) #:use-module (guix scripts package) #:use-module (guix scripts build) #:autoload (guix scripts system search) (service-type->recutils) #:use-module (guix scripts system reconfigure) #:autoload (guix scripts pull) (channel-commit-hyperlink) - #:use-module (guix scripts home import) + #:autoload (guix scripts system) (service-node-type + shepherd-service-node-type) + #:autoload (guix scripts home import) (import-manifest) #:use-module ((guix status) #:select (with-status-verbosity)) #:use-module ((guix build utils) #:select (mkdir-p)) #:use-module (guix gexp) @@ -87,6 +94,10 @@ (define (show-help) build build the home environment without installing anything\n")) (display (G_ "\ import generates a home environment definition from dotfiles\n")) + (display (G_ "\ + extension-graph emit the service extension graph\n")) + (display (G_ "\ + shepherd-graph emit the graph of shepherd services\n")) (show-build-options-help) (display (G_ " @@ -97,6 +108,9 @@ (define (show-help) channel revisions")) (display (G_ " -v, --verbosity=LEVEL use the given verbosity LEVEL")) + (display (G_ " + --graph-backend=BACKEND + use BACKEND for 'extension-graph' and 'shepherd-graph'")) (newline) (display (G_ " -h, --help display this help and exit")) @@ -136,6 +150,10 @@ (define %options (alist-cons 'validate-reconfigure warn-about-backward-reconfigure result))) + (option '("graph-backend") #t #f + (lambda (opt name arg result) + (alist-cons 'graph-backend arg result))) + %standard-build-options)) (define %default-options @@ -147,18 +165,49 @@ (define %default-options (multiplexed-build-output? . #t) (verbosity . #f) ;default (debug . 0) - (validate-reconfigure . ,ensure-forward-reconfigure))) + (validate-reconfigure . ,ensure-forward-reconfigure) + (graph-backend . "graphviz"))) ;;; ;;; Actions. ;;; +(define* (export-extension-graph home port + #:key (backend (lookup-backend "graphviz"))) + "Export the service extension graph of HOME to PORT using BACKEND." + (let* ((services (home-environment-services home)) + (home (find (lambda (service) + (eq? (service-kind service) home-service-type)) + services))) + (export-graph (list home) (current-output-port) + #:backend backend + #:node-type (service-node-type services) + #:reverse-edges? #t))) + +(define* (export-shepherd-graph home port + #:key (backend (lookup-backend "graphviz"))) + "Export the graph of shepherd services of HOME to PORT using BACKEND." + (let* ((services (home-environment-services home)) + (root (fold-services services + #:target-type home-shepherd-service-type)) + ;; Get the list of . + (shepherds (home-shepherd-configuration-services + (service-value root))) + (sinks (filter (lambda (service) + (null? (shepherd-service-requirement service))) + shepherds))) + (export-graph sinks (current-output-port) + #:backend backend + #:node-type (shepherd-service-node-type shepherds) + #:reverse-edges? #t))) + (define* (perform-action action he #:key dry-run? derivations-only? use-substitutes? + (graph-backend "graphviz") (validate-reconfigure ensure-forward-reconfigure)) "Perform ACTION for home environment. " @@ -169,35 +218,43 @@ (define println (check-forward-update validate-reconfigure #:current-channels (home-provenance %guix-home))) - (mlet* %store-monad - ((he-drv (home-environment-derivation he)) - (drvs (mapm/accumulate-builds lower-object (list he-drv))) - (% (if derivations-only? - (return - (for-each (compose println derivation-file-name) drvs)) - (built-derivations drvs))) + (case action + ((extension-graph) + (export-extension-graph he (current-output-port) + #:backend (lookup-backend graph-backend))) + ((shepherd-graph) + (export-shepherd-graph he (current-output-port) + #:backend (lookup-backend graph-backend))) + (else + (mlet* %store-monad + ((he-drv (home-environment-derivation he)) + (drvs (mapm/accumulate-builds lower-object (list he-drv))) + (% (if derivations-only? + (return + (for-each (compose println derivation-file-name) drvs)) + (built-derivations drvs))) - (he-out-path -> (derivation->output-path he-drv))) - (if (or dry-run? derivations-only?) - (return #f) - (begin - (for-each (compose println derivation->output-path) drvs) + (he-out-path -> (derivation->output-path he-drv))) + (if (or dry-run? derivations-only?) + (return #f) + (begin + (for-each (compose println derivation->output-path) drvs) - (case action - ((reconfigure) - (let* ((number (generation-number %guix-home)) - (generation (generation-file-name - %guix-home (+ 1 number)))) + (case action + ((reconfigure) + (let* ((number (generation-number %guix-home)) + (generation (generation-file-name + %guix-home (+ 1 number)))) - (switch-symlinks generation he-out-path) - (switch-symlinks %guix-home generation) - (setenv "GUIX_NEW_HOME" he-out-path) - (primitive-load (string-append he-out-path "/activate")) - (setenv "GUIX_NEW_HOME" #f) - (return he-out-path))) - (else - (newline) - (return he-out-path))))))) + (switch-symlinks generation he-out-path) + (switch-symlinks %guix-home generation) + (setenv "GUIX_NEW_HOME" he-out-path) + (primitive-load (string-append he-out-path "/activate")) + (setenv "GUIX_NEW_HOME" #f) + (return he-out-path))) + (else + (newline) + (return he-out-path))))))))) (define (process-action action args opts) "Process ACTION, a sub-command, with the arguments are listed in ARGS. @@ -256,7 +313,9 @@ (define (ensure-home-environment file-or-exp obj) #:derivations-only? (assoc-ref opts 'derivations-only?) #:use-substitutes? (assoc-ref opts 'substitutes?) #:validate-reconfigure - (assoc-ref opts 'validate-reconfigure)))))) + (assoc-ref opts 'validate-reconfigure) + #:graph-backend + (assoc-ref opts 'graph-backend)))))) (warn-about-disk-space))) diff --git a/guix/scripts/system.scm b/guix/scripts/system.scm index 6f7dcd4643..55e9b8ba30 100644 --- a/guix/scripts/system.scm +++ b/guix/scripts/system.scm @@ -88,7 +88,10 @@ (define-module (guix scripts system) #:use-module (ice-9 match) #:use-module (rnrs bytevectors) #:export (guix-system - read-operating-system)) + read-operating-system + + service-node-type + shepherd-service-node-type)) ;;; diff --git a/tests/guix-home.sh b/tests/guix-home.sh index f054d15172..48dbcbd28f 100644 --- a/tests/guix-home.sh +++ b/tests/guix-home.sh @@ -93,6 +93,14 @@ trap 'chmod -Rf +w "$test_directory"; rm -rf "$test_directory"' EXIT "# the content of bashrc-test-config.sh")))))))) EOF + # Check whether the graph commands work as expected. + guix home extension-graph "home.scm" | grep 'label = "home-activation"' + guix home extension-graph "home.scm" | grep 'label = "home-symlink-manager"' + guix home extension-graph "home.scm" | grep 'label = "home"' + + # There are no Shepherd services so the one below must fail. + ! guix home shepherd-graph "home.scm" + guix home reconfigure "${test_directory}/home.scm" test -d "${HOME}/.guix-home" test -h "${HOME}/.bash_profile"