From patchwork Sun Feb 6 21:20:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josselin Poiret X-Patchwork-Id: 37030 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 030EE27BBEA; Sun, 6 Feb 2022 21:23:39 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id BE0D027BBE9 for ; Sun, 6 Feb 2022 21:23:38 +0000 (GMT) Received: from localhost ([::1]:56036 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGp0T-0001sD-W6 for patchwork@mira.cbaines.net; Sun, 06 Feb 2022 16:23:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:51124) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGoyw-0008RP-OG for guix-patches@gnu.org; Sun, 06 Feb 2022 16:22:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:46068) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGoyw-0003Vn-EX for guix-patches@gnu.org; Sun, 06 Feb 2022 16:22:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nGoyw-0005lH-CW for guix-patches@gnu.org; Sun, 06 Feb 2022 16:22:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53826] [PATCH 1/2] system: Add helper file-system-mount-point-predicate. Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 06 Feb 2022 21:22:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53826 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53826@debbugs.gnu.org Cc: Josselin Poiret Received: via spool by 53826-submit@debbugs.gnu.org id=B53826.164418246722074 (code B ref 53826); Sun, 06 Feb 2022 21:22:02 +0000 Received: (at 53826) by debbugs.gnu.org; 6 Feb 2022 21:21:07 +0000 Received: from localhost ([127.0.0.1]:39965 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGoy3-0005jx-Cc for submit@debbugs.gnu.org; Sun, 06 Feb 2022 16:21:07 -0500 Received: from jpoiret.xyz ([206.189.101.64]:50556) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGoxn-0005id-J8 for 53826@debbugs.gnu.org; Sun, 06 Feb 2022 16:21:06 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 2B48E1851ED; Sun, 6 Feb 2022 21:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1644182450; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=7eEwvNL9L9HIwiUL6+wUqNSJ0L3vbgZMP1ZQvIkh94Y=; b=JjJJVdx/Z7O7bqpbfdlKp1SFbUTY3Wovas8QiXAPsTlPWh8pVBm/KY/sMrsEVvIGIxgrMD Y13515k+TOItM5cb7qKf98U2d4ErVDjxFRJEhBlTJKDmErlpa47PlT5JK3m9Op2Qx7FK+S 7PQbBHPpzijib/R3ZmRlB+XOZFASn1pm3cI06/swrkmMGDsHikad2+0aenXGR/g63i9bXa bGRcOBX/fp2CBmi8MtrIwTLB31u/mHvpflHkdyh5GHb7mIHtS53K2HRpiZkXGfEfx+096G SxZIIawecvl/K4Hk0h8mxu/TBpbji7esWKW2bsr2tseR87+mjVu7uQs4mg7SXQ== Date: Sun, 6 Feb 2022 22:20:44 +0100 Message-Id: <20220206212045.19257-1-dev@jpoiret.xyz> In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / 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: Josselin Poiret X-ACL-Warn: , Josselin Poiret via Guix-patches X-Patchwork-Original-From: Josselin Poiret via Guix-patches via From: Josselin Poiret X-getmail-retrieved-from-mailbox: Patches * gnu/system/file-systems.scm (file-system-mount-point-predicate): Add it. --- gnu/system/file-systems.scm | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index e1d1fb72cc..437f8da898 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -60,6 +60,7 @@ (define-module (gnu system file-systems) file-system-location file-system-type-predicate + file-system-mount-point-predicate btrfs-subvolume? btrfs-store-subvolume-file-name @@ -671,6 +672,12 @@ (define (file-system-type-predicate type) (lambda (fs) (string=? (file-system-type fs) type))) +(define (file-system-mount-point-predicate mount-point) + "Return a predicate that, when passed a file system, returns #t if that file +system has the given MOUNT-POINT." + (lambda (fs) + (string=? (file-system-mount-point fs) mount-point))) + ;;; ;;; Btrfs specific helpers. From patchwork Sun Feb 6 21:20:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Josselin Poiret X-Patchwork-Id: 37029 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 E75BF27BBEA; Sun, 6 Feb 2022 21:21:39 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,FROM_SUSPICIOUS_NTLD,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, SPF_HELO_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id B0EBF27BBE9 for ; Sun, 6 Feb 2022 21:21:39 +0000 (GMT) Received: from localhost ([::1]:52632 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nGoyY-0007mA-Ra for patchwork@mira.cbaines.net; Sun, 06 Feb 2022 16:21:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:50818) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nGoxy-0007l4-Dy for guix-patches@gnu.org; Sun, 06 Feb 2022 16:21:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:46065) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nGoxy-0003LE-4F for guix-patches@gnu.org; Sun, 06 Feb 2022 16:21:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nGoxx-0005jU-V2 for guix-patches@gnu.org; Sun, 06 Feb 2022 16:21:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#53826] [PATCH 2/2] doc: Clarify the Swap Space examples, and include an helper example. Resent-From: Josselin Poiret Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 06 Feb 2022 21:21:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 53826 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 53826@debbugs.gnu.org Cc: Josselin Poiret Received: via spool by 53826-submit@debbugs.gnu.org id=B53826.164418245422001 (code B ref 53826); Sun, 06 Feb 2022 21:21:01 +0000 Received: (at 53826) by debbugs.gnu.org; 6 Feb 2022 21:20:54 +0000 Received: from localhost ([127.0.0.1]:39962 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGoxq-0005in-4K for submit@debbugs.gnu.org; Sun, 06 Feb 2022 16:20:54 -0500 Received: from jpoiret.xyz ([206.189.101.64]:50604) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nGoxn-0005if-Q9 for 53826@debbugs.gnu.org; Sun, 06 Feb 2022 16:20:53 -0500 Received: from authenticated-user (jpoiret.xyz [206.189.101.64]) by jpoiret.xyz (Postfix) with ESMTPA id 11A871851EE; Sun, 6 Feb 2022 21:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=jpoiret.xyz; s=dkim; t=1644182451; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=OjLwQpJxisc+vy1rv9f+xgxrq9q6LL4i0E+89vQUVD8=; b=uBY2sgrEqzsJEpJjWiPskrh63fhdFZaBl6Pw5Ky9llYcHEKVfBoBeeGJQspPWbo/gwfPCH BF62UDIXXPbneEX47BEzFZnp8bZAVVmWZOL+Srm0qFz+MVaglJPSriHZrSB3XoIceqM/fj RTTBaEb9dR1htZ+b0nHKUoletmb81AEdVfd9h7e5DN062O3IbHi/ll5ERCLTURz/G94XMz xvd2J1sV0eqWKb98+ULuDwCKkAYTv7vQWI5/S7Jt6knpdnmLLpw9OE3rmMMYXf47ljJKtH t2ozOQlk1vf6x7LQkdatwdvLOmPRSlLw4lXBMYUmg5/XlGnLuFmrQXNciLSVRQ== Date: Sun, 6 Feb 2022 22:20:45 +0100 Message-Id: <20220206212045.19257-2-dev@jpoiret.xyz> In-Reply-To: References: MIME-Version: 1.0 Authentication-Results: jpoiret.xyz; auth=pass smtp.auth=jpoiret@jpoiret.xyz smtp.mailfrom=dev@jpoiret.xyz X-Spamd-Bar: / 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: Josselin Poiret X-ACL-Warn: , Josselin Poiret via Guix-patches X-Patchwork-Original-From: Josselin Poiret via Guix-patches via From: Josselin Poiret X-getmail-retrieved-from-mailbox: Patches * doc/guix.texi (Swap Space): The examples referred to variables defined outside of the snippets, and so were not very informative for people without much Guile knowledge. Instead, refer to mapped-devices for the first, and use the new helper file-systme-mount-point-predicate for the second. --- doc/guix.texi | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 0cf865a672..49bc8d55e6 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -15737,22 +15737,39 @@ Linux swap partition by running @command{swaplabel @var{device}}, where @lisp (swap-space (target (file-system-label "swap")) - (dependencies (list lvm-device))) + (dependencies mapped-devices)) @end lisp -Use the partition with label @code{swap}, which can be found after the -@var{lvm-device} mapped device has been opened. Again, the +Use the partition with label @code{swap}, which can be found after all +the @var{mapped-devices} mapped devices have been opened. Again, the @command{swaplabel} command allows you to view and change the label of a Linux swap partition. +Here's a more involved example with the corresponding @code{file-systems} part +of an @code{operating-system} declaration. + @lisp -(swap-space - (target "/btrfs/swapfile") - (dependencies (list btrfs-fs))) +(file-systems + (list (file-system + (device (file-system-label "root")) + (mount-point "/") + (type "ext4")) + (file-system + (device (file-system-label "btrfs")) + (mount-point "/btrfs") + (type "btrfs")))) + +(swap-devices + (list + (swap-space + (target "/btrfs/swapfile") + (dependencies (filter (file-system-mount-point-predicate "/btrfs") + file-systems))))) @end lisp -Use the file @file{/btrfs/swapfile} as swap space, which is present on the -@var{btrfs-fs} filesystem. +Use the file @file{/btrfs/swapfile} as swap space, which depends on the +file system mounted at @file{/btrfs}. Note how we use Guile's filter to +select the file system in an elegant fashion! @node User Accounts @section User Accounts