* [Help] Adding file-system utils packages to system profile
@ 2020-04-06 17:07 Brice Waegeneire
2020-04-07 8:38 ` Brice Waegeneire
0 siblings, 1 reply; 2+ messages in thread
From: Brice Waegeneire @ 2020-04-06 17:07 UTC (permalink / raw)
To: guix-devel
[-- Attachment #1: Type: text/plain, Size: 1002 bytes --]
Hello Guix,
There was several discussions about adding file-system utils packages to
the system profile based on the types in the “file-systems” field.
I tried implementing this in the attached patch but I'm currently stuck
and
need some help. I've probably overlooked something basic but I can;t put
a
finger on it... Guix compile successfully with the patch and testing
“file-system-utils” in “guix repl” returns a list of packages as
expected.
But when I try building a system/vm the packages aren't added to the
system's profile as I expected. From what I understand, that function as
used in “file-system-service-type” should get as arguments the list of
file-systems defined in the operating-system and should return a list of
packages, themselves appended to the system's profile list of packages.
Halp! What am I missing?
I also welcome any suggestion UI wise, currently the only change is the
additions of the “utils?” filed in the “file-system” record.
- Brice
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-services-Add-file-system-utils-to-profile.patch --]
[-- Type: text/x-diff; name=0001-services-Add-file-system-utils-to-profile.patch, Size: 4862 bytes --]
From 57a6dc8c6ba2fb2b5ce97bffa26d61a430d2c16b Mon Sep 17 00:00:00 2001
From: Brice Waegeneire <brice@waegenei.re>
Date: Mon, 6 Apr 2020 18:00:11 +0200
Subject: [PATCH] services: Add file-system utils to profile.
---
gnu/services/base.scm | 42 +++++++++++++++++++++++++++++++++++--
gnu/system/file-systems.scm | 6 +++++-
2 files changed, 45 insertions(+), 3 deletions(-)
diff --git a/gnu/services/base.scm b/gnu/services/base.scm
index 070765ab83..16519b5a7b 100644
--- a/gnu/services/base.scm
+++ b/gnu/services/base.scm
@@ -44,13 +44,20 @@
#:select (file-system-packages))
#:use-module (gnu packages admin)
#:use-module ((gnu packages linux)
- #:select (alsa-utils crda eudev e2fsprogs fuse gpm kbd lvm2 rng-tools))
+ #:select (alsa-utils btrfs-progs crda eudev eudev/btrfs-fix
+ e2fsprogs f2fs-tools fuse gpm kbd lvm2 rng-tools
+ util-linux xfsprogs))
#:use-module (gnu packages bash)
#:use-module ((gnu packages base)
#:select (canonical-package coreutils glibc glibc-utf8-locales))
#:use-module (gnu packages package-management)
#:use-module ((gnu packages gnupg) #:select (guile-gcrypt))
- #:use-module (gnu packages linux)
+ #:use-module ((gnu packages disk)
+ #:select (dosfstools))
+ #:use-module ((gnu packages file-systems)
+ #:select (bcachefs-tools jfsutils zfs))
+ #:use-module ((gnu packages mtools)
+ #:select (exfat-utils))
#:use-module (gnu packages terminals)
#:use-module ((gnu build file-systems)
#:select (mount-flags->bit-mask))
@@ -59,8 +66,10 @@
#:use-module (guix modules)
#:use-module ((guix self) #:select (make-config.scm))
#:use-module (srfi srfi-1)
+ #:use-module (srfi srfi-2)
#:use-module (srfi srfi-26)
#:use-module (ice-9 match)
+ #:use-module (ice-9 regex)
#:use-module (ice-9 format)
#:export (fstab-service-type
root-file-system-service
@@ -535,6 +544,33 @@ FILE-SYSTEM."
(memq 'bind-mount (file-system-flags file-system))))
file-systems))
+(define (file-system-type->utils type)
+ "Return a utils package for file system TYPE."
+ (define pattern->utils
+ `(("ext[234]" . ,e2fsprogs)
+ ("btrfs" . ,btrfs-progs)
+ ("jfs" . ,jfsutils)
+ ("exfat" . ,exfat-utils)
+ ("bachefs" . ,bcachefs-tools)
+ ("xfs" . ,xfsprogs)
+ ("fat" . ,dosfstools)
+ ("f2fs" . ,f2fs-tools)
+ ("zfs" . ,zfs)))
+ (and-let* ((utils
+ (find (lambda (a) (string-match (car a) type)) pattern->utils)))
+ (cdr utils)))
+
+(define (file-system-utils file-systems)
+ "Return the list of file-system utils packages for FILE-SYSTEMS"
+ (fold (lambda (file-system prev)
+ (let ((utils? (file-system-utils? file-system))
+ (utils (file-system-type->utils (file-system-type file-system))))
+ (if (and utils? utils
+ (not (member utils prev)))
+ (cons* utils prev)
+ prev)))
+ '() file-systems))
+
(define file-system-service-type
(service-type (name 'file-systems)
(extensions
@@ -542,6 +578,8 @@ FILE-SYSTEM."
file-system-shepherd-services)
(service-extension fstab-service-type
file-system-fstab-entries)
+ (service-extension profile-service-type
+ file-system-utils)
;; Have 'user-processes' depend on 'file-systems'.
(service-extension user-processes-service-type
diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm
index 3b599efa8e..9bc1687696 100644
--- a/gnu/system/file-systems.scm
+++ b/gnu/system/file-systems.scm
@@ -1,5 +1,6 @@
;;; GNU Guix --- Functional package management for GNU
;;; Copyright © 2013, 2014, 2015, 2016, 2017, 2018, 2019 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2020 Brice Waegeneire <brice@waegenei.re>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -42,6 +43,7 @@
file-system-create-mount-point?
file-system-dependencies
file-system-location
+ file-system-utils?
file-system-type-predicate
@@ -111,7 +113,9 @@
(default '())) ; or <mapped-device>
(location file-system-location
(default (current-source-location))
- (innate)))
+ (innate))
+ (utils? file-system-utils? ; Boolean
+ (default #t)))
;; A file system label for use in the 'device' field.
(define-record-type <file-system-label>
--
2.26.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Help] Adding file-system utils packages to system profile
2020-04-06 17:07 [Help] Adding file-system utils packages to system profile Brice Waegeneire
@ 2020-04-07 8:38 ` Brice Waegeneire
0 siblings, 0 replies; 2+ messages in thread
From: Brice Waegeneire @ 2020-04-07 8:38 UTC (permalink / raw)
To: guix-devel; +Cc: Guix-devel
On 2020-04-06 17:07, Brice Waegeneire wrote:
> I tried implementing this in the attached patch but I'm currently stuck
> and
> need some help. I've probably overlooked something basic but I can;t
> put a
> finger on it... Guix compile successfully with the patch and testing
> “file-system-utils” in “guix repl” returns a list of packages as
> expected.
> But when I try building a system/vm the packages aren't added to the
> system's profile as I expected. From what I understand, that function
> as
> used in “file-system-service-type” should get as arguments the list of
> file-systems defined in the operating-system and should return a list
> of
> packages, themselves appended to the system's profile list of packages.
It turns out “file-system-service-type” doesn't get *all* the
file-systems,
just the one not need for boot.
With this issue fixed I have submitted it as patch #40480[0].
[0]: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=40480
- Brice
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2020-04-07 8:38 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-06 17:07 [Help] Adding file-system utils packages to system profile Brice Waegeneire
2020-04-07 8:38 ` Brice Waegeneire
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/guix.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).