From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id I7zUBg2GQmENUAAAgWs5BA (envelope-from ) for ; Thu, 16 Sep 2021 01:47:25 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id WJnfAQ2GQmGKHwAAB5/wlQ (envelope-from ) for ; Wed, 15 Sep 2021 23:47:25 +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 20C8519183 for ; Thu, 16 Sep 2021 01:47:24 +0200 (CEST) Received: from localhost ([::1]:49220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mQecd-0005ay-1P for larch@yhetil.org; Wed, 15 Sep 2021 19:47:23 -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?Q?=E2=80=98guix_?= =?UTF-8?Q?gc=E2=80=99?= 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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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+larch=yhetil.org@gnu.org Sender: "Guix-patches" Reply-to: Thiago Jung Bauermann X-ACL-Warn: , Thiago Jung Bauermann via Guix-patches From: Thiago Jung Bauermann via Guix-patches via X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1631749644; h=from:from:sender:sender:reply-to: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:list-id:list-help: list-unsubscribe:list-subscribe:list-post:dkim-signature; bh=z8kb+v9RiHX7N/VOvxv+tDyRL4Bz7n07+sYHixwE+ic=; b=FnqK4Byhd727yq29cY0ARoG8Z1dEnWXNkiSNufisTO4EaMPWIfs9OCLJTNf2df90obNwM3 xbwbiUqjRm0Lk71QB38ZVjpYWck+tR3y4DRRkaw/sUXWYVsW5KrieqidOl4xUnS7z6Pa1e ev1A3LlGP33qVxYwPU36LPlbRZyDqbr+IEoNtMSkuQR2/C41IKegTKJUXxOAlfn7cZJXnM NESm+628wKxx7vp3LAFms7BbRwKb3QvfMomlWvCqHiRCJkyko2zbfqLDmANaW3XpmNjR1n Ldo2y92lUNja7QxFfJdQM/vrUprUKGUGpa7d7AzoNJHDkHjpFMihNqb0ZHvqLA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1631749644; a=rsa-sha256; cv=none; b=tNFT2sz1wIjUlNfMh5MJ9bRMLMgzXLg6Ckgrii/1hA7uzbaftjTr1+qVM8TzNad+VZHk9/ aiNcUQOFMqLGovm6A+URDjeLcLMvLUPmlZzelb2v30j5Ia9saDdVcECM8Fk+2Bvwe1YB4r 5Il2lM6uWxqgnQuKUzuPQT+x1PqG6Rl8NDOHWK5hem76e7sPGvbXACkb9LhXSXOcndMiE7 hGmExNuhoekh94XG/2JADo3Umn7WVWeEIuIMGFT0Qs+iq+TcC+/F5JYlSXaqJN0v0rO1Lz c4314YIjqlIXyfZrtKFSHVB50BTVRujOZCQKVXWMdwA4007xL/dlXtLVqk+U3Q== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=kolabnow.com header.s=dkim20160331 header.b=evfBBkwu; dmarc=pass (policy=none) header.from=gnu.org; 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: -2.90 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=kolabnow.com header.s=dkim20160331 header.b=evfBBkwu; dmarc=pass (policy=none) header.from=gnu.org; 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: 20C8519183 X-Spam-Score: -2.90 X-Migadu-Scanner: scn0.migadu.com X-TUID: LpJcRXi8tIzj * 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