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: 31383 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 D52C727BC6B; Tue, 13 Jul 2021 19:19:16 +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 A164527BC82 for ; Tue, 13 Jul 2021 19:19:16 +0100 (BST) Received: from localhost ([::1]:53520 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1m3Mzz-0004jy-LS for patchwork@mira.cbaines.net; Tue, 13 Jul 2021 14:19:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3Mzo-0004gu-AB for guix-patches@gnu.org; Tue, 13 Jul 2021 14:19:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:58657) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3Mzn-0007l3-UX for guix-patches@gnu.org; Tue, 13 Jul 2021 14:19:03 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1m3Mzn-0000W4-Rm for guix-patches@gnu.org; Tue, 13 Jul 2021 14:19:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49549] [PATCH v2 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: Tue, 13 Jul 2021 18:19:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49549 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49549@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.16262003071884 (code B ref -1); Tue, 13 Jul 2021 18:19:03 +0000 Received: (at submit) by debbugs.gnu.org; 13 Jul 2021 18:18:27 +0000 Received: from localhost ([127.0.0.1]:41964 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3MzD-0000UK-8B for submit@debbugs.gnu.org; Tue, 13 Jul 2021 14:18:27 -0400 Received: from lists.gnu.org ([209.51.188.17]:40890) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1m3MzA-0000U5-LA for submit@debbugs.gnu.org; Tue, 13 Jul 2021 14:18:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36720) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1m3MzA-0004OY-Fm for guix-patches@gnu.org; Tue, 13 Jul 2021 14:18:24 -0400 Received: from mail-lj1-x22e.google.com ([2a00:1450:4864:20::22e]:41664) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1m3Mz9-0007Ik-4W for guix-patches@gnu.org; Tue, 13 Jul 2021 14:18:24 -0400 Received: by mail-lj1-x22e.google.com with SMTP id e20so31326261ljn.8 for ; Tue, 13 Jul 2021 11:18:22 -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=yrAKTn9umLbx/fYv7ew4SyzS2m+ivTBR/NGZXsOMMRg=; b=vWxv2PrMkfPi8SzgAh3q979pD8VaJ0zvW+2iHrDiovUeuTYpayoiLvhZ86pkZuu0+8 6uVAthw3U5+VEJ2UpasxIN0t3Pa/yiahnXH1eRDSBuSAFP+wtA5RCDV804n7tTEhqKKX KDiv7dyraguy2Q7Tr0nEon3bWhhqzeimbl3WAln+zHS/io2vghBs9IhhSOD26Q18s9OB ipYsKmxtchzXTz04s9W6x/6Tb+L/P7beHxDAuJWM84H8YLj2obdbNKpJPuYWXnNRnSQg IPKBB49crFdElskuvu4iwCL4n18bFSq1suvyfy8ad8/cidch1l+v095JrYscYPv5Vhpi Z6Cw== 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=yrAKTn9umLbx/fYv7ew4SyzS2m+ivTBR/NGZXsOMMRg=; b=X3jWPxgU7M+IoCgSGNjPGdc4cA0PAaWSFqu+0Bp03tpIG3+NfXif841Q5Dwa5iMlsf UUS1KZ1IaW2kCsckUB8jQfICn0el/OdQWpDn/ds01ZHj/q2Zub9p7uiANIY9mxoh/o6N hXuz7w5iG5yhfL3WAPU/dpa1rnSkjna6no67SMG1y9rcLv4Z37jC89d5r4hF0JnVTKyu VT38eRBVApa/ZoRD04Ez47gRfQQUdVa0l+84ta/EUgbCLETSuInq5/99+sAOD9V5RcQe JxdXXvlb8XkDFFnK7PZHpQook46ozyvpyRgbzhGe4ThcI9963n2YBo0wl5jpmFKRhnF+ cpMg== X-Gm-Message-State: AOAM5314i5pNpUDSSs1okyWEaV1Hh2SeWPkTeTtv+TS3pSaNoo9+dWOh leQGOpqeR3zGz3vCYapKkjOKAA2HjkDtKg== X-Google-Smtp-Source: ABdhPJx9B0/fenFXkw54J6IAM8jhJXeuG7N+PAqmP05+nAHX0hFyp1U3WBTlsiDNVpWED+6a9VpECw== X-Received: by 2002:a2e:9090:: with SMTP id l16mr3185209ljg.275.1626200301397; Tue, 13 Jul 2021 11:18:21 -0700 (PDT) Received: from localhost (109-252-93-92.nat.spd-mgts.ru. [109.252.93.92]) by smtp.gmail.com with ESMTPSA id c9sm2001116ljb.22.2021.07.13.11.18.20 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jul 2021 11:18:21 -0700 (PDT) From: Andrew Tropin In-Reply-To: <87bl76m6b7.fsf@trop.in> Date: Mon, 5 Jul 2021 18:41:45 +0300 Message-ID: <87y2aakrly.fsf@trop.in> MIME-Version: 1.0 Received-SPF: none client-ip=2a00:1450:4864:20::22e; envelope-from=andrew@trop.in; helo=mail-lj1-x22e.google.com X-Spam_score_int: 15 X-Spam_score: 1.5 X-Spam_bar: + X-Spam_report: (1.5 / 5.0 requ) BAYES_00=-1.9, DATE_IN_PAST_96_XX=3.405, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=no autolearn_force=no X-Spam_action: no action 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 ffcee22bb8..78e5603edf 100644 --- a/gnu/home-services.scm +++ b/gnu/home-services.scm @@ -444,3 +444,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)))