From patchwork Wed Sep 15 23:36:38 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thiago Jung Bauermann X-Patchwork-Id: 32884 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 0425327BBE3; Thu, 16 Sep 2021 00:47:24 +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 BC4CE27BBE1 for ; Thu, 16 Sep 2021 00:47:22 +0100 (BST) Received: from localhost ([::1]:49220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQecb-0005ay-NJ for patchwork@mira.cbaines.net; Wed, 15 Sep 2021 19:47:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33030) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQecI-0005ac-V8 for guix-patches@gnu.org; Wed, 15 Sep 2021 19:47:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:41896) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mQecI-0001oj-Mk for guix-patches@gnu.org; Wed, 15 Sep 2021 19:47:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mQecI-000631-CS for guix-patches@gnu.org; Wed, 15 Sep 2021 19:47:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#50610] [PATCH] etc: Add systemd files for running =?utf-8?b?4oCYZ3VpeCBnY+KAmQ==?= periodically Resent-From: Thiago Jung Bauermann Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 15 Sep 2021 23:47:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 50610 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 50610@debbugs.gnu.org Cc: Thiago Jung Bauermann X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.163174958523198 (code B ref -1); Wed, 15 Sep 2021 23:47:02 +0000 Received: (at submit) by debbugs.gnu.org; 15 Sep 2021 23:46:25 +0000 Received: from localhost ([127.0.0.1]:53442 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQeba-000620-Pt for submit@debbugs.gnu.org; Wed, 15 Sep 2021 19:46:25 -0400 Received: from lists.gnu.org ([209.51.188.17]:52614) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mQebY-00061s-Ia for submit@debbugs.gnu.org; Wed, 15 Sep 2021 19:46:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:33004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQebY-0005Tt-4V for guix-patches@gnu.org; Wed, 15 Sep 2021 19:46:16 -0400 Received: from mx.kolabnow.com ([95.128.36.42]:16414 helo=ext-mx-out001.mykolab.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mQebV-0001Cr-KG for guix-patches@gnu.org; Wed, 15 Sep 2021 19:46:15 -0400 Received: from localhost (unknown [127.0.0.1]) by ext-mx-out001.mykolab.com (Postfix) with ESMTP id 16FE3A25 for ; Thu, 16 Sep 2021 01:46:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kolabnow.com; h= content-transfer-encoding:content-type:content-type:mime-version :message-id:date:date:subject:subject:from:from:received :received:received; s=dkim20160331; t=1631749568; x=1633563969; bh=z8kb+v9RiHX7N/VOvxv+tDyRL4Bz7n07+sYHixwE+ic=; b=evfBBkwuqrkn jT3qpnHO6CWnNAGl/cvemFCnf80fk5CYam3A/OuQA/AvXYXZx9MjudfIXFwLEfU0 q0u4vqLx/hnoMkaxgBueFlnW/u0edyaQaYGl0W+rfl1kATK4TxmszW3gtiNbBNRN jSv976TbwXaLFZh8bAxb7TUrPeAjQCeI0kW4P0ST7e8cumIl2inb5A5qrbBizfs3 XmhzK9trHGdLn244IeIyaWigcbjdPPML09RZJYj6lIvxnK7ugqkvzwc89PI/hrHF jgYZuowFZBbCWs3O1bGmbCJ1FCp8NH6RfuuMpsgsyjqWbNQInmY8DqpiZRShDYby BvJBznbgcm9HWLgsDyzp0yucHVAWo/waMYJyRdSeMD+z3T54D6G7rhttErmGvz8B f04vCxcMjCaRl5qGF5aoUM05E+edFmUjnnValPBzG19a2UQ9PQqOUCOr2mkLW9xV 8pFPEU4j22A+9hEDXHc4ulzn9e2TRvmUH+tmG6szk10enfyjXb2qDg80K0B7D0HD opVmvF9Eg9X4uDv5j4/93Q06YpciHFsOFNyvaBVi2kk9hGSz5yP0cDXxuE+qubmA yI06g89a66gBulwDpyBLTlLwyVidOdJ5ibtMZ+2OUm9rmZ5rDEX3kOOE8D9ImMRr AtSYcoJoCAREAoDq7J+ag4GkuCLT2QQ= X-Virus-Scanned: amavisd-new at mykolab.com Received: from ext-mx-out001.mykolab.com ([127.0.0.1]) by localhost (ext-mx-out001.mykolab.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 2PNOO_U-Zqvr for ; Thu, 16 Sep 2021 01:46:08 +0200 (CEST) Received: from int-mx003.mykolab.com (unknown [10.9.13.3]) by ext-mx-out001.mykolab.com (Postfix) with ESMTPS id 23E18702 for ; Thu, 16 Sep 2021 01:46:08 +0200 (CEST) Received: from ext-subm001.mykolab.com (unknown [10.9.6.1]) by int-mx003.mykolab.com (Postfix) with ESMTPS id F06E43AF0; Thu, 16 Sep 2021 01:36:59 +0200 (CEST) Date: Wed, 15 Sep 2021 20:36:38 -0300 Message-Id: <20210915233638.67470-1-bauermann@kolabnow.com> MIME-Version: 1.0 Received-SPF: pass client-ip=95.128.36.42; envelope-from=bauermann@kolabnow.com; helo=ext-mx-out001.mykolab.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham 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" Reply-to: Thiago Jung Bauermann X-ACL-Warn: , Thiago Jung Bauermann via Guix-patches X-Patchwork-Original-From: Thiago Jung Bauermann via Guix-patches via From: Thiago Jung Bauermann X-getmail-retrieved-from-mailbox: Patches * etc/guix-gc.service.in: New file. * etc/guix-gc.timer: Likewise. * .gitignore: Ignore generated ‘guix-gc.service’. * nix/local.mk (nodist_systemdservice_DATA): Add ‘guix-gc.service’ and ‘guix-gc.timer’. (EXTRA_DIST): Add ‘guix-gc.service.in’ and ‘guix-gc.timer’. * doc/guix.texi (Binary Installation): Mention the new systemd files. --- Hello, I recently added a systemd timer to run ‘guix gc’ once a day on the guixp9 CI machine. This patch adds files similar to the ones I used there, and documents them. The only differences are that on guixp9 the command-line used is “guix gc -F 50G” and the timer is set to fire daily rather than weekly. Thanks, Thiago .gitignore | 1 + doc/guix.texi | 12 ++++++++++++ etc/guix-gc.service.in | 20 ++++++++++++++++++++ etc/guix-gc.timer | 15 +++++++++++++++ nix/local.mk | 6 +++++- 5 files changed, 53 insertions(+), 1 deletion(-) create mode 100644 etc/guix-gc.service.in create mode 100644 etc/guix-gc.timer diff --git a/.gitignore b/.gitignore index 88fe24586db0..59e1460fefc8 100644 --- a/.gitignore +++ b/.gitignore @@ -74,6 +74,7 @@ /etc/guix-daemon.service /etc/guix-publish.conf /etc/guix-publish.service +/etc/guix-gc.service /etc/init.d/guix-daemon /etc/openrc/guix-daemon /guix-* diff --git a/doc/guix.texi b/doc/guix.texi index 2fc96879106b..e1e353e57e50 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -743,6 +743,18 @@ with these commands: # systemctl enable --now gnu-store.mount guix-daemon @end example +You may also want to arrange for @command{guix gc} to run periodically: + +@example +# cp ~root/.config/guix/current/lib/systemd/system/guix-gc.service \ + ~root/.config/guix/current/lib/systemd/system/guix-gc.timer \ + /etc/systemd/system/ +# systemctl enable --now guix-gc.timer +@end example + +You may want to edit @file{guix-gc.service} to adjust the command line +options to fit your needs (@pxref{Invoking guix gc}). + If your host distro uses the Upstart init system: @example diff --git a/etc/guix-gc.service.in b/etc/guix-gc.service.in new file mode 100644 index 000000000000..2f1ca6584bbc --- /dev/null +++ b/etc/guix-gc.service.in @@ -0,0 +1,20 @@ +# This is a "service unit file" for the systemd init system to perform a +# one-shot 'guix gc' operation. It is meant to be triggered by a timer. +# Drop it in /etc/systemd/system or similar together with 'guix-gc.timer' +# to set it up. + +[Unit] +Description=Discard unused Guix store items + +[Service] +Type=oneshot +# Customize the 'guix gc' arguments to fit your needs. +ExecStart=@localstatedir@/guix/profiles/per-user/root/current-guix/bin/guix gc -d 1m -F 10G +PrivateDevices=yes +PrivateNetwork=yes +PrivateUsers=no +ProtectKernelTunables=yes +ProtectKernelModules=yes +ProtectControlGroups=yes +MemoryDenyWriteExecute=yes +SystemCallFilter=@default @file-system @basic-io @system-service diff --git a/etc/guix-gc.timer b/etc/guix-gc.timer new file mode 100644 index 000000000000..192132fbda51 --- /dev/null +++ b/etc/guix-gc.timer @@ -0,0 +1,15 @@ +# This is a "timer unit file" for the systemd init system to trigger +# 'guix-gc.service' periodically. Drop it in /etc/systemd/system or similar +# together with 'guix-gc.service' to set it up. + +[Unit] +Description=Discard unused Guix store items + +[Timer] +OnCalendar=weekly +AccuracySec=1h +Persistent=true +RandomizedDelaySec=6000 + +[Install] +WantedBy=timers.target diff --git a/nix/local.mk b/nix/local.mk index 7c438ea78c5b..d6b4d7faeb66 100644 --- a/nix/local.mk +++ b/nix/local.mk @@ -153,7 +153,9 @@ systemdservicedir = $(libdir)/systemd/system nodist_systemdservice_DATA = \ etc/gnu-store.mount \ etc/guix-daemon.service \ - etc/guix-publish.service + etc/guix-publish.service \ + etc/guix-gc.service \ + etc/guix-gc.timer etc/%.mount: etc/%.mount.in \ $(top_builddir)/config.status @@ -216,6 +218,8 @@ EXTRA_DIST += \ etc/guix-daemon.conf.in \ etc/guix-publish.service.in \ etc/guix-publish.conf.in \ + etc/guix-gc.service.in \ + etc/guix-gc.timer \ etc/init.d/guix-daemon.in \ etc/openrc/guix-daemon.in