From patchwork Mon Jul 5 15:41:45 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Tropin X-Patchwork-Id: 31504 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 96D7627BC78; Mon, 19 Jul 2021 18:16:18 +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_H4,RCVD_IN_MSPIKE_WL,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 65F0227BC6B for ; Mon, 19 Jul 2021 18:16:18 +0100 (BST) Received: from localhost ([::1]:50920 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m5WsL-0000Id-E8 for patchwork@mira.cbaines.net; Mon, 19 Jul 2021 13:16:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:42804) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m5WsC-0000FJ-0i for guix-patches@gnu.org; Mon, 19 Jul 2021 13:16:09 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:48674) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m5Ws7-0004be-HY for guix-patches@gnu.org; Mon, 19 Jul 2021 13:16:07 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m5Ws7-0000wb-EG for guix-patches@gnu.org; Mon, 19 Jul 2021 13:16:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49419] [PATCH v3 4/4] home-services: Add fold-home-service-types function References: <87y2akhiz1.fsf@trop.in> Resent-From: Andrew Tropin Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 19 Jul 2021 17:16: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.16267149472601 (code B ref 49419); Mon, 19 Jul 2021 17:16:03 +0000 Received: (at 49419) by debbugs.gnu.org; 19 Jul 2021 17:15:47 +0000 Received: from localhost ([127.0.0.1]:60216 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5Wrq-0000fb-PA for submit@debbugs.gnu.org; Mon, 19 Jul 2021 13:15:47 -0400 Received: from mail-lj1-f179.google.com ([209.85.208.179]:34735) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m5Wro-0000XA-M0 for 49419@debbugs.gnu.org; Mon, 19 Jul 2021 13:15:45 -0400 Received: by mail-lj1-f179.google.com with SMTP id y7so26961257ljm.1 for <49419@debbugs.gnu.org>; Mon, 19 Jul 2021 10:15:44 -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:date:message-id:mime-version; bh=E1FcXcmKek67yaPkdPAw2a7MKWy1GQT4CM0PuDuKADY=; b=dmZAXJBrYH8bT0hbf87mCXq4XWeKleg7otUefIXTEgomEZqg0aO9cIiJkc4UpyRtOU Z6fJgSp/mX2Qgo9TVpIDgIfBCfd5CWLWLg0a6Yg5VOVspxnjLBJ6otYuYic//MfA7UUD NWae1Zk5A+ZhKssG247S8/tnqQ8e+UudrJLwhUIZRy/KIHaYEjOdi+qp3IQl5SCpRG0m 8k139AoV7vnI0+mLYrMeZImDbQCd+Xo74HFxMGG7oxoBsiPNeB11ajoxjg6uZcXt8BjA 3zWcqoYEtN/9lHc7fc02rm/vHQGMSnkLC5ybPuesyV5JjavoYXavk3/rbQ7/YgMCGwa/ UkEA== 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:date:message-id :mime-version; bh=E1FcXcmKek67yaPkdPAw2a7MKWy1GQT4CM0PuDuKADY=; b=Ikbn5ILg4WGtBZCaENeyxPOBouO6tuHYt110z4KQt8V6bFy7GaPB4dsOCEAwpJD2qb A0KRuRFrYJQBDKOerLGLL+olRRq3xSsbO1jJEKL4XkcjcCttSNNHt57+JvUJIOfJ0/LD CMtnxrUoHwPWzhQtHWWVEP9hvvkspSMCs40y+kJ+SCnksUerMv3d70/InWnZV+fl2QKV OkcElX+2CKmqPZ/TrrIz5FsZOXaxcgDXo/ZJOZWNVRUDHroJuztGC7Kez4ygKA92gR/T S9GqWZJTnInH1qOK7cK8i7FpK7dHVzeVxOWIuzGXEsCReDYeze+qio8hO0TLKEqzKnvD HuTA== X-Gm-Message-State: AOAM531sDWmcFjTiox+/rilvMZxhGstPJb8Nvju+dLeWm8wW7zGQguD4 PkvPlJR00KPZCCfzydZMiHaDKvb/GwQnaQ== X-Google-Smtp-Source: ABdhPJxfTfiLY71FMRk6YgoXzhqqpDGHC+LZCfpHZkjtNaJGolWGCEbtgXmzIOxAK1IG+sdMEHYSag== X-Received: by 2002:a2e:3508:: with SMTP id z8mr23100604ljz.7.1626714938371; Mon, 19 Jul 2021 10:15:38 -0700 (PDT) Received: from localhost ([85.249.24.60]) by smtp.gmail.com with ESMTPSA id j15sm2156159lja.21.2021.07.19.10.15.37 for <49419@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Jul 2021 10:15:37 -0700 (PDT) From: Andrew Tropin In-Reply-To: <87v956g1g5.fsf@trop.in> Date: Mon, 5 Jul 2021 18:41:45 +0300 Message-ID: <87pmveg17l.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 8aa9adeaaf..9afb70f0a7 100644 --- a/gnu/home-services.scm +++ b/gnu/home-services.scm @@ -449,3 +449,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)))