* [bug#53826] [PATCH 0/2] Improve Swap Space examples
@ 2022-02-06 21:18 Josselin Poiret via Guix-patches via
2022-02-06 21:20 ` [bug#53826] [PATCH 1/2] system: Add helper file-system-mount-point-predicate Josselin Poiret via Guix-patches via
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Josselin Poiret via Guix-patches via @ 2022-02-06 21:18 UTC (permalink / raw)
To: 53826; +Cc: Josselin Poiret
Hello,
These two patches should help making swap space dependencies more
manageable for people who aren't yet proficient enough in Guile.
The first patch adds a simple predicate which can be used in
conjunction with filter to select file systems with specific mount
points, and the second refactors the examples to be more readily copy
and pasted into the configuration file, also using the helper
predicate.
Best,
Josselin Poiret (2):
system: Add helper file-system-mount-point-predicate.
doc: Clarify the Swap Space examples, and include an helper example.
doc/guix.texi | 33 +++++++++++++++++++++++++--------
gnu/system/file-systems.scm | 7 +++++++
2 files changed, 32 insertions(+), 8 deletions(-)
--
2.34.0
^ permalink raw reply [flat|nested] 4+ messages in thread
* [bug#53826] [PATCH 1/2] system: Add helper file-system-mount-point-predicate.
2022-02-06 21:18 [bug#53826] [PATCH 0/2] Improve Swap Space examples Josselin Poiret via Guix-patches via
@ 2022-02-06 21:20 ` Josselin Poiret via Guix-patches via
2022-02-06 21:20 ` [bug#53826] [PATCH 2/2] doc: Clarify the Swap Space examples, and include an helper example Josselin Poiret via Guix-patches via
2022-02-15 9:15 ` bug#53826: [PATCH 0/2] Improve Swap Space examples Ludovic Courtès
2 siblings, 0 replies; 4+ messages in thread
From: Josselin Poiret via Guix-patches via @ 2022-02-06 21:20 UTC (permalink / raw)
To: 53826; +Cc: Josselin Poiret
* 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)))
+
\f
;;;
;;; Btrfs specific helpers.
--
2.34.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [bug#53826] [PATCH 2/2] doc: Clarify the Swap Space examples, and include an helper example.
2022-02-06 21:18 [bug#53826] [PATCH 0/2] Improve Swap Space examples Josselin Poiret via Guix-patches via
2022-02-06 21:20 ` [bug#53826] [PATCH 1/2] system: Add helper file-system-mount-point-predicate Josselin Poiret via Guix-patches via
@ 2022-02-06 21:20 ` Josselin Poiret via Guix-patches via
2022-02-15 9:15 ` bug#53826: [PATCH 0/2] Improve Swap Space examples Ludovic Courtès
2 siblings, 0 replies; 4+ messages in thread
From: Josselin Poiret via Guix-patches via @ 2022-02-06 21:20 UTC (permalink / raw)
To: 53826; +Cc: Josselin Poiret
* 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
--
2.34.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* bug#53826: [PATCH 0/2] Improve Swap Space examples
2022-02-06 21:18 [bug#53826] [PATCH 0/2] Improve Swap Space examples Josselin Poiret via Guix-patches via
2022-02-06 21:20 ` [bug#53826] [PATCH 1/2] system: Add helper file-system-mount-point-predicate Josselin Poiret via Guix-patches via
2022-02-06 21:20 ` [bug#53826] [PATCH 2/2] doc: Clarify the Swap Space examples, and include an helper example Josselin Poiret via Guix-patches via
@ 2022-02-15 9:15 ` Ludovic Courtès
2 siblings, 0 replies; 4+ messages in thread
From: Ludovic Courtès @ 2022-02-15 9:15 UTC (permalink / raw)
To: Josselin Poiret; +Cc: 53826-done
Hi Josselin,
Josselin Poiret <dev@jpoiret.xyz> skribis:
> These two patches should help making swap space dependencies more
> manageable for people who aren't yet proficient enough in Guile.
>
> The first patch adds a simple predicate which can be used in
> conjunction with filter to select file systems with specific mount
> points, and the second refactors the examples to be more readily copy
> and pasted into the configuration file, also using the helper
> predicate.
Nice.
> system: Add helper file-system-mount-point-predicate.
> doc: Clarify the Swap Space examples, and include an helper example.
Applied, thanks!
Ludo’.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-02-15 9:16 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-06 21:18 [bug#53826] [PATCH 0/2] Improve Swap Space examples Josselin Poiret via Guix-patches via
2022-02-06 21:20 ` [bug#53826] [PATCH 1/2] system: Add helper file-system-mount-point-predicate Josselin Poiret via Guix-patches via
2022-02-06 21:20 ` [bug#53826] [PATCH 2/2] doc: Clarify the Swap Space examples, and include an helper example Josselin Poiret via Guix-patches via
2022-02-15 9:15 ` bug#53826: [PATCH 0/2] Improve Swap Space examples Ludovic Courtès
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.