From patchwork Thu Aug 5 05:47:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Tropin X-Patchwork-Id: 31836 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 73AB227BC6B; Thu, 5 Aug 2021 06:49:11 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,T_DKIM_INVALID, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 35A9627BC78 for ; Thu, 5 Aug 2021 06:49:11 +0100 (BST) Received: from localhost ([::1]:46368 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mBWFi-0001nK-8L for patchwork@mira.cbaines.net; Thu, 05 Aug 2021 01:49:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36736) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mBWFb-0001lB-LO for guix-patches@gnu.org; Thu, 05 Aug 2021 01:49:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:34108) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mBWFb-0001BE-F6 for guix-patches@gnu.org; Thu, 05 Aug 2021 01:49:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mBWFb-0006oA-Dk for guix-patches@gnu.org; Thu, 05 Aug 2021 01:49:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49419] [PATCH v4 4/4] home-services: Add fold-home-service-types function Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 05 Aug 2021 05:49:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 49419 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49419@debbugs.gnu.org Received: via spool by 49419-submit@debbugs.gnu.org id=B49419.162814251126087 (code B ref 49419); Thu, 05 Aug 2021 05:49:03 +0000 Received: (at 49419) by debbugs.gnu.org; 5 Aug 2021 05:48:31 +0000 Received: from localhost ([127.0.0.1]:45647 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBWF5-0006mh-Hp for submit@debbugs.gnu.org; Thu, 05 Aug 2021 01:48:31 -0400 Received: from mail-lj1-f172.google.com ([209.85.208.172]:35573) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mBWF4-0006mJ-MA for 49419@debbugs.gnu.org; Thu, 05 Aug 2021 01:48:31 -0400 Received: by mail-lj1-f172.google.com with SMTP id x9so3562683ljj.2 for <49419@debbugs.gnu.org>; Wed, 04 Aug 2021 22:48:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=trop-in.20150623.gappssmtp.com; s=20150623; h=from:to:subject:in-reply-to:references:date:message-id:mime-version; bh=8S15RKfEMo4F0g5qCAJ7N/QpXm9mgOVxmPG0QA0WzY0=; b=SFaXmQaeOCe3sbAh57shejRH3nJfDvnUAunBzzwyZM3AvGHRn0pJu4HdxM1/5TKSks tqewJWKgGZreOKIqnMaR6q2uF5MmtLnSlJJP/ftxdjDNV6GtBheNigJhTID9lyS4ZF0L 5t5iD82FfmRNHHNIZGY7M0N2kyQBJ+78VRUYgKmQy7BQa9YZF04nqk+Tcw0pWpuEgrd+ XAEq+tOsM7g8w8r+R/EctfNoFxZ6c1+IKv9yAPWMBMdsbo6MSdpRsMEGGeRj4H4EoUzJ dBftxAWxY2D/WQ638fRdyyacVDJ3Xoeat10OGsbGWIWzFDfpyXWLSpmD66mdVTJDnxKs KZBQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:in-reply-to:references:date :message-id:mime-version; bh=8S15RKfEMo4F0g5qCAJ7N/QpXm9mgOVxmPG0QA0WzY0=; b=UtPxBCPEFzSQYxTBP+kLOIoolc8pW67bFTFZ/ONGnqnmBIK+PQtAS76fTiefMCKIUI TumwgruP/KpKkR/Dt1SS792JcoCwQxUhM8CcSeScT+8xRr7mApSInIV75zxm/TRFfrUI M8sBFkacxVkBDAw1zjCOscenpYMBheiKFo59Xm00KvE6TTCSZvlQh0YfUIqkSYwjkB6J GVmtGCuhk8km4cBsAgCCj+o/bsz1IeeXJ/lJb6/HiMF/p0QtZpymF22DK02otaOI34xJ U7OiDgKA6qdnJuKkLtVRGegihDNfI6rlxTgaW3yHAumt88oBq59ZO/5Fx2gMlG7As2bP 9MEA== X-Gm-Message-State: AOAM532PySDcgkZMAAfsOe+p6Sfp2U5aLYYOz/Y53+UwW71Avo1qNCYN qQ/dM7V0HtU+LYy0T2sl2G6B0hjz2RIwbn9u X-Google-Smtp-Source: ABdhPJzjQjzqVNb+5q9aNDSbtKXOEweo8MEl4DqrHJEISahC0V7nncidMChwdILr3t3VfEclruhnWQ== X-Received: by 2002:a2e:890a:: with SMTP id d10mr2086703lji.310.1628142504550; Wed, 04 Aug 2021 22:48:24 -0700 (PDT) Received: from localhost ([109.252.93.92]) by smtp.gmail.com with ESMTPSA id c13sm402663lfm.208.2021.08.04.22.48.23 for <49419@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 04 Aug 2021 22:48:24 -0700 (PDT) From: Andrew Tropin In-Reply-To: <87tuk4mors.fsf@trop.in> References: <87y2akhiz1.fsf@trop.in> <87tuk4mors.fsf@trop.in> Date: Thu, 05 Aug 2021 08:47:40 +0300 Message-ID: <87h7g4mohv.fsf@trop.in> 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.scm (parent-directory, %guix-home-root-directory, %service-type-path, all-home-service-modules, fold-home-service-types): New variables. --- gnu/home-services.scm | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/gnu/home-services.scm b/gnu/home-services.scm index d320d3a44d..16b9736d64 100644 --- a/gnu/home-services.scm +++ b/gnu/home-services.scm @@ -492,3 +492,29 @@ environment, and its configuration file, when available."))) (define sexp->home-provenance sexp->system-provenance) (define home-provenance system-provenance) + + +;;; +;;; Searching +;;; + +(define (parent-directory directory) + "Get the parent directory of DIRECTORY" + (string-join (drop-right (string-split directory #\/) 1) "/")) + +(define %guix-home-root-directory + ;; Absolute file name of the module hierarchy. + (parent-directory (dirname (search-path %load-path "gnu/home-services.scm")))) + +(define %service-type-path + ;; Search path for service types. + (make-parameter `((,%guix-home-root-directory . "gnu/home-services")))) + +(define (all-home-service-modules) + "Return the default set of home-service modules." + (cons (resolve-interface '(gnu home-services)) + (all-modules (%service-type-path) + #:warn warn-about-load-error))) + +(define* (fold-home-service-types proc seed) + (fold-service-types proc seed (all-home-service-modules)))