From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id YJ33FB1jWGHO/gAAgWs5BA (envelope-from ) for ; Sat, 02 Oct 2021 15:48:13 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id oJGuEB1jWGHbVgAA1q6Kng (envelope-from ) for ; Sat, 02 Oct 2021 13:48:13 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id C2AD530631 for ; Sat, 2 Oct 2021 15:48:12 +0200 (CEST) Received: from localhost ([::1]:52656 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mWfN6-0008Cp-02 for larch@yhetil.org; Sat, 02 Oct 2021 09:48:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:41194) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mWfMz-00087r-7a for guix-patches@gnu.org; Sat, 02 Oct 2021 09:48:05 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:46823) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mWfMz-0002pb-0M for guix-patches@gnu.org; Sat, 02 Oct 2021 09:48:05 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mWfMy-0002vV-VL for guix-patches@gnu.org; Sat, 02 Oct 2021 09:48:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50967] [PATCH 09/12] gnu: home-services: Move mcron to (gnu services). Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 02 Oct 2021 13:48:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50967 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50967@debbugs.gnu.org Cc: Oleg Pykhalov Received: via spool by 50967-submit@debbugs.gnu.org id=B50967.163318245611088 (code B ref 50967); Sat, 02 Oct 2021 13:48:04 +0000 Received: (at 50967) by debbugs.gnu.org; 2 Oct 2021 13:47:36 +0000 Received: from localhost ([127.0.0.1]:58354 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWfMU-0002sc-W4 for submit@debbugs.gnu.org; Sat, 02 Oct 2021 09:47:35 -0400 Received: from mail-lf1-f41.google.com ([209.85.167.41]:43833) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mWfMI-0002pR-E2 for 50967@debbugs.gnu.org; Sat, 02 Oct 2021 09:47:23 -0400 Received: by mail-lf1-f41.google.com with SMTP id e15so50340434lfr.10 for <50967@debbugs.gnu.org>; Sat, 02 Oct 2021 06:47:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=btGaGTJckl/MDRw0JM/AUiT3eq5XPTPBZEnryiNHkKE=; b=e0N+z8w0q3oXnQPX0fVLjx9zMzHmC6uxWBgERK8Bmm7Np7bPwadXkSsVrr3u12IiQ3 2+npX/o7SwxlxY0OMOX+i64kYRxFLGOxJxOGfroqkv8dqwJR6f6KjFSbEWxOxZCx1hJy +GMjFqJWN5iEI/Qvxw3VYIRjmtIvAoyc8h3FFQQ7ISuuzM5cgIipxtZuBF6ErQhXQfti 1HQOGFne4n4akQ3ly7fM7LKd/nzhnSRPFPJrRyXely99MwQDSoq3jHySm3gAJ79y1ObN G0bBG0ziH+o1Dwrce6qfQYvev2jqAErmMhLiOONkR8Ov7/bSTKwNXkT9y97oJFPJZiT9 TyNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=btGaGTJckl/MDRw0JM/AUiT3eq5XPTPBZEnryiNHkKE=; b=WI7zlSfq7drN7GvyOsJvo2w6cmGLnZ8WBSpiVAzE9ROvGWK8diQvMHNBat9QDxNHjZ IpqX5eRooshXxcj8LYy8tlM5EqT9w9IpHlXKNpgiFC7PxaO+DAsHqH3zRKAMddgLaqs6 bGMH73hBnzsLQRuvY1EedKBo7/Rzw6llCL9WPTd3X1+dBKlRV0rLpHRkmUp4t7CAttRh vwFAz1cRIiD1j5UITQwvNRI6cISqxEfZmOiO3OCNoaoyBaZ62BsOJ58X+4sZF1BrrDm7 tL/A6zo1qkSLldkNl1NuCZ2yXR9X2Z36HQ2F19RWp3UHAesCQwVhgbcbY/PkDpCCp4zv SW/g== X-Gm-Message-State: AOAM533qVlhyaCoOeMfnax90N0yGfCSMAGBXEQBF98d5VMArwfkXxaz0 f6tzFjd8FdIha5rNbtIKPg8pJZYJKUI= X-Google-Smtp-Source: ABdhPJyCIIdTlCw9+hezk8jt/mHsW46RxMkJETW5P79t0LCJz6Y/One9FiJtJ60fyD9bXqa+uR0jBg== X-Received: by 2002:a05:6512:10ca:: with SMTP id k10mr3831285lfg.327.1633182436297; Sat, 02 Oct 2021 06:47:16 -0700 (PDT) Received: from localhost.localdomain ([88.201.161.72]) by smtp.gmail.com with ESMTPSA id e5sm952648ljj.129.2021.10.02.06.47.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 Oct 2021 06:47:15 -0700 (PDT) From: Oleg Pykhalov Date: Sat, 2 Oct 2021 16:46:00 +0300 Message-Id: <20211002134603.6229-9-go.wigust@gmail.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211002134603.6229-1-go.wigust@gmail.com> References: <20211002134603.6229-1-go.wigust@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633182492; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=KdgjX8+wBci70ROaFueS6wnv4fRKKhxeXbApAmqqbHA=; b=FH8wUaiMAp4rpL9oJsSuNHMw42WZPvXJDB0Sy+UsCpoXE2NMZHLDS/A+iYtcCtx8RkJ23A c9DPXNJ7uCbSp8W6b3DZrmt7G244gwDURY7LeaJPe9jF20QkrbmL7D0XG4yD9ZUYXXXr7r yK2Q/Q7SNUa1Jm1/tDSvD/ZQLv9qAbxxWjtGY5G2ZG0QZCzzshXMge0NmZoaug+LrmS47m 6hLUBmP9rcQqBNFNXk/TEOZo0G2B06aZuabu1Lof5enHznso/5XAXTAdjDuft+WddMp1Iv tOn9zNV7XvK9bC+2emZ4NtvOBW27omUQeJBg6vh7ZVLvApIn6cyflsMhveYhQA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633182492; a=rsa-sha256; cv=none; b=WJJ7mJLs8uumdqMtobZJvJz4BfhuZdgNBxHiWwy8+VLmoK+o5cNQjsskcPWc69AkcfR+F5 Xa4V0zvPjXnVDqY17G1XpVH/gwO1/m6yKJBfgZaMTJtS9/g2LXITim8xWcmxQ3B5jQilhw TokzV0DlBRm9xo6DbjCh56HotNa7yVPY7c54xCpO8RNAcyqTKzLnSS77/U0SG6cgFnK03R eJE8nZiwDOkz2GP5bak/cPvJWkmrBIlDSOUnWHFjGcytAM0TqA2a5P6YSPUzAEjw+uopga VGPVGCOOme4COh3qkI9TF4ACsHcKs87S9S/r5BfWnanN/MUo6R8dH7iWYNmI0w== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=e0N+z8w0; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Spam-Score: -1.30 Authentication-Results: aspmx1.migadu.com; dkim=fail ("body hash did not verify") header.d=gmail.com header.s=20210112 header.b=e0N+z8w0; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); spf=pass (aspmx1.migadu.com: domain of guix-patches-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-patches-bounces@gnu.org X-Migadu-Queue-Id: C2AD530631 X-Spam-Score: -1.30 X-Migadu-Scanner: scn0.migadu.com X-TUID: UO3oNbCG7ZZF * gnu/home-services/mcron.scm: Move content without delete job-files and shepherd-schedule-action ... * gnu/services/mcron.scm: ... here. * gnu/local.mk: Delete gnu/home-services/mcron.scm. * doc/guix.texi: Replace (gnu home-services mcron) with (gnu services mcron). --- doc/guix.texi | 2 +- gnu/home-services/mcron.scm | 115 ------------------------------------ gnu/local.mk | 1 - gnu/services/mcron.scm | 89 +++++++++++++++++++++++++++- 4 files changed, 89 insertions(+), 118 deletions(-) delete mode 100644 gnu/home-services/mcron.scm diff --git a/doc/guix.texi b/doc/guix.texi index a72a726b54..d06590ab8c 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -35810,7 +35810,7 @@ for example). @cindex mcron @cindex scheduling jobs -The @code{(gnu home-services mcron)} module provides an interface to +The @code{(gnu services mcron)} module provides an interface to GNU@tie{}mcron, a daemon to run jobs at scheduled times (@pxref{Top,,, mcron, GNU@tie{}mcron}). The information about system's mcron is applicable here (@pxref{Scheduled Job Execution}), the only difference diff --git a/gnu/home-services/mcron.scm b/gnu/home-services/mcron.scm deleted file mode 100644 index a4e09f509c..0000000000 --- a/gnu/home-services/mcron.scm +++ /dev/null @@ -1,115 +0,0 @@ -;;; GNU Guix --- Functional package management for GNU -;;; Copyright © 2021 Andrew Tropin -;;; Copyright © 2021 Xinglu Chen -;;; -;;; This file is part of GNU Guix. -;;; -;;; GNU Guix is free software; you can redistribute it and/or modify it -;;; under the terms of the GNU General Public License as published by -;;; the Free Software Foundation; either version 3 of the License, or (at -;;; your option) any later version. -;;; -;;; GNU Guix is distributed in the hope that it will be useful, but -;;; WITHOUT ANY WARRANTY; without even the implied warranty of -;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -;;; GNU General Public License for more details. -;;; -;;; You should have received a copy of the GNU General Public License -;;; along with GNU Guix. If not, see . - -(define-module (gnu home-services mcron) - #:use-module (gnu packages guile-xyz) - #:use-module (gnu home-services) - #:use-module (gnu services shepherd) - #:use-module (gnu services shepherd) - #:use-module (guix records) - #:use-module (guix gexp) - #:use-module (srfi srfi-1) - #:use-module (ice-9 match) - - #:export (home-mcron-configuration - home-mcron-service-type)) - -;;; Commentary: -;; -;; Service for the GNU mcron cron job manager. -;; -;; Example configuration, the first job runs mbsync once every ten -;; minutes, the second one writes "Mcron service" to ~/mcron-file once -;; every minute. -;; -;; (service home-mcron-service-type -;; (home-mcron-configuration -;; (jobs (list #~(job '(next-minute -;; (range 0 60 10)) -;; (lambda () -;; (system* "mbsync" "--all"))) -;; #~(job next-minute-from -;; (lambda () -;; (call-with-output-file (string-append (getenv "HOME") -;; "/mcron-file") -;; (lambda (port) -;; (display "Mcron service" port))))))))) -;; -;;; Code: - -(define-record-type* home-mcron-configuration - make-home-mcron-configuration - home-mcron-configuration? - (package home-mcron-configuration-package ; package - (default mcron)) - (jobs home-mcron-configuration-jobs ; list of jobs - (default '()))) - -(define job-files (@@ (gnu services mcron) job-files)) -(define shepherd-schedule-action - (@@ (gnu services mcron) shepherd-schedule-action)) - -(define home-mcron-shepherd-services - (match-lambda - (($ mcron '()) ; no jobs to run - '()) - (($ mcron jobs) - (let ((files (job-files mcron jobs))) - (list (shepherd-service - (documentation "User cron jobs.") - (provision '(mcron)) - (modules `((srfi srfi-1) - (srfi srfi-26) - (ice-9 popen) ; for the 'schedule' action - (ice-9 rdelim) - (ice-9 match) - ,@%default-modules)) - (start #~(make-forkexec-constructor - (list #$(file-append mcron "/bin/mcron") #$@files) - #:log-file (string-append - (or (getenv "XDG_LOG_HOME") - (format #f "~a/.local/var/log" - (getenv "HOME"))) - "/mcron.log"))) - (stop #~(make-kill-destructor)) - (actions - (list (shepherd-schedule-action mcron files))))))))) - -(define home-mcron-profile (compose list home-mcron-configuration-package)) - -(define (home-mcron-extend config jobs) - (home-mcron-configuration - (inherit config) - (jobs (append (home-mcron-configuration-jobs config) - jobs)))) - -(define home-mcron-service-type - (service-type (name 'home-mcron) - (extensions - (list (service-extension - home-shepherd-service-type - home-mcron-shepherd-services) - (service-extension - home-profile-service-type - home-mcron-profile))) - (compose concatenate) - (extend home-mcron-extend) - (default-value (home-mcron-configuration)) - (description - "Install and configure the GNU mcron cron job manager."))) diff --git a/gnu/local.mk b/gnu/local.mk index fb60e6492e..ca4c15ba25 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -75,7 +75,6 @@ GNU_SYSTEM_MODULES = \ %D%/ci.scm \ %D%/home.scm \ %D%/home-services.scm \ - %D%/home-services/mcron.scm \ %D%/image.scm \ %D%/packages.scm \ %D%/packages/abduco.scm \ diff --git a/gnu/services/mcron.scm b/gnu/services/mcron.scm index 0e675607f3..79639caee4 100644 --- a/gnu/services/mcron.scm +++ b/gnu/services/mcron.scm @@ -1,5 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2016, 2017, 2018, 2019, 2020 Ludovic Courtès +;;; Copyright © 2021 Andrew Tropin +;;; Copyright © 2021 Xinglu Chen ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,6 +21,7 @@ (define-module (gnu services mcron) #:use-module (gnu services) #:use-module (gnu services shepherd) + #:use-module (gnu home-services) #:use-module (gnu packages guile-xyz) #:use-module (guix deprecation) #:use-module (guix records) @@ -31,7 +34,10 @@ mcron-configuration-mcron mcron-configuration-jobs - mcron-service-type)) + mcron-service-type + + home-mcron-configuration + home-mcron-service-type)) ;;; Commentary: ;;; @@ -172,4 +178,85 @@ files." jobs))))) (default-value (mcron-configuration)))) ;empty job list + +;;; +;;; Home services +;;; + +;; Service for the GNU mcron cron job manager. +;; +;; Example configuration, the first job runs mbsync once every ten +;; minutes, the second one writes "Mcron service" to ~/mcron-file once +;; every minute. +;; +;; (service home-mcron-service-type +;; (home-mcron-configuration +;; (jobs (list #~(job '(next-minute +;; (range 0 60 10)) +;; (lambda () +;; (system* "mbsync" "--all"))) +;; #~(job next-minute-from +;; (lambda () +;; (call-with-output-file (string-append (getenv "HOME") +;; "/mcron-file") +;; (lambda (port) +;; (display "Mcron service" port))))))))) + +(define-record-type* home-mcron-configuration + make-home-mcron-configuration + home-mcron-configuration? + (package home-mcron-configuration-package ; package + (default mcron)) + (jobs home-mcron-configuration-jobs ; list of jobs + (default '()))) + +(define home-mcron-shepherd-services + (match-lambda + (($ mcron '()) ; no jobs to run + '()) + (($ mcron jobs) + (let ((files (job-files mcron jobs))) + (list (shepherd-service + (documentation "User cron jobs.") + (provision '(mcron)) + (modules `((srfi srfi-1) + (srfi srfi-26) + (ice-9 popen) ; for the 'schedule' action + (ice-9 rdelim) + (ice-9 match) + ,@%default-modules)) + (start #~(make-forkexec-constructor + (list #$(file-append mcron "/bin/mcron") #$@files) + #:log-file (string-append + (or (getenv "XDG_LOG_HOME") + (format #f "~a/.local/var/log" + (getenv "HOME"))) + "/mcron.log"))) + (stop #~(make-kill-destructor)) + (actions + (list (shepherd-schedule-action mcron files))))))))) + +(define home-mcron-profile (compose list home-mcron-configuration-package)) + +(define (home-mcron-extend config jobs) + (home-mcron-configuration + (inherit config) + (jobs (append (home-mcron-configuration-jobs config) + jobs)))) + +(define home-mcron-service-type + (service-type (name 'home-mcron) + (extensions + (list (service-extension + home-shepherd-service-type + home-mcron-shepherd-services) + (service-extension + home-profile-service-type + home-mcron-profile))) + (compose concatenate) + (extend home-mcron-extend) + (default-value (home-mcron-configuration)) + (description + "Install and configure the GNU mcron cron job manager."))) + ;;; mcron.scm ends here -- 2.33.0