Subject: bug#39505: Adding filesystem utilities based on file-systems

From: Ludovic Courtès <[email-masked]>
Date: Mon, 10 Feb 2020 23:06:55 +0100

Hi Leo,

Leo Famulari <[email-masked]> skribis:

> As discussed in #39332 [0], it would be great if filesystem utility
> packages were added to the system profile if a file-systems entry uses
> that filesystem type.
>
> For example, btrfs-progs could be added if a btrfs filesystem was listed
> in file-systems.

This could be done with something like:

diff --git a/gnu/system.scm b/gnu/system.scm
index 01baa248a2..3ff3073017 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -203,7 +203,11 @@
          (default %default-issue))
 
   (packages operating-system-packages             ; list of (PACKAGE OUTPUT...)
-            (default %base-packages))             ; or just PACKAGE
+            (thunked)                             ; or just PACKAGE
+            (default (append (file-system-packages
+                              (operating-system-file-systems
+                               this-operating-system))
+                             %base-packages)))
 
   (timezone operating-system-timezone)            ; string
   (locale   operating-system-locale               ; string

However, this would only work for the default values of ‘packages’.  In
other cases, users would have to add (file-system-packages …) explicitly
by themselves, which is not great.

Alternately, we could turn ‘%base-packages’ into a macro that expands
to something like:

  (gimme-the-base-packages this-operating-system)

but that wouldn’t be great because now you’d be unable to refer to
‘%base-packages’ like a regular variable, outside the lexical context of
an ‘operating-system’ form.

Thoughts?

Ludo’.