From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id EMtlNwAUz2AndQEAgWs5BA (envelope-from ) for ; Sun, 20 Jun 2021 12:10:08 +0200 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id SPsuMwAUz2CLBgAA1q6Kng (envelope-from ) for ; Sun, 20 Jun 2021 10:10:08 +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 F2BDC179A7 for ; Sun, 20 Jun 2021 12:10:07 +0200 (CEST) Received: from localhost ([::1]:60320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1luuP1-0004cp-1o for larch@yhetil.org; Sun, 20 Jun 2021 06:10:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45020) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luuOw-0004cg-QK for guix-patches@gnu.org; Sun, 20 Jun 2021 06:10:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:49795) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1luuOw-0003W2-Hz for guix-patches@gnu.org; Sun, 20 Jun 2021 06:10:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1luuOw-0005N3-A7 for guix-patches@gnu.org; Sun, 20 Jun 2021 06:10:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#49128] [PATCH] services: Add file system utilities to profile. Resent-From: Brice Waegeneire Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sun, 20 Jun 2021 10:10:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 49128 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 49128@debbugs.gnu.org X-Debbugs-Original-To: guix-patches@gnu.org Received: via spool by submit@debbugs.gnu.org id=B.162418379520625 (code B ref -1); Sun, 20 Jun 2021 10:10:02 +0000 Received: (at submit) by debbugs.gnu.org; 20 Jun 2021 10:09:55 +0000 Received: from localhost ([127.0.0.1]:33108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luuOp-0005Mb-BI for submit@debbugs.gnu.org; Sun, 20 Jun 2021 06:09:55 -0400 Received: from lists.gnu.org ([209.51.188.17]:47824) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1luuOo-0005MT-3j for submit@debbugs.gnu.org; Sun, 20 Jun 2021 06:09:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45010) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luuOn-0004cU-UL for guix-patches@gnu.org; Sun, 20 Jun 2021 06:09:53 -0400 Received: from relay7-d.mail.gandi.net ([217.70.183.200]:53579) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1luuOk-0003JV-Vu for guix-patches@gnu.org; Sun, 20 Jun 2021 06:09:53 -0400 Received: (Authenticated sender: brice@waegenei.re) by relay7-d.mail.gandi.net (Postfix) with ESMTPSA id B58DD20002 for ; Sun, 20 Jun 2021 10:09:47 +0000 (UTC) From: Brice Waegeneire Date: Sun, 20 Jun 2021 12:09:45 +0200 Message-Id: <20210620100945.15345-1-brice@waegenei.re> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=217.70.183.200; envelope-from=brice@waegenei.re; helo=relay7-d.mail.gandi.net X-Spam_score_int: -25 X-Spam_score: -2.6 X-Spam_bar: -- X-Spam_report: (-2.6 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, 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" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1624183808; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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; bh=NOuEPH1kuSoJWzMM/LT6GUEOyy9pqnletx3sEVaul6U=; b=nQakzXL8Hm9k9GV1iZpchCiTdBQX35Hnp1YutTRog170N2/n3jiCFnKuQd9t7ppIc19uUR SHChNr0yinqqN3GAy1tQSUtJlezcXbK7MTrZcngeBUCmTfEiPkKvsMBErWayVexDUCIjIe fJN0B7DL4UKwPOHV3UNb3Jwbbn/RywYdTPKkAlg+jJzWWGAY/gthgDmb1tb7fUT8lyWNsV e1U3X2vXakpfkZ9rppUzmifS7ZW93RSCY3diL+t5+6nnVx9gRfq2I3OHBSuC9AO3YVlpDS EOYYlf7ULOzhdYB4Z70BdC3Y5zS44l8wf6MMZpEgibX6q3liawZ2FmFSXA4rBA== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1624183808; a=rsa-sha256; cv=none; b=lIVH0bPC671/Ba+pDzOCImWWcnEQwfuRSkv/x2ls8W3E76pGTnR7v2J7SeJD7ZW/9sZYzu RdGSTz8eBqCsk6h3ePY6CPWIqwS+KarHIh541dD9ktGFyOfvjUM0BmusVtRaJYFmiTlv97 daCq6Z2qTlMkzO8cqiCOwK63V/SurvzKNJIPRcD4HaEHed/Qme1za+LeEs8DA5YNIeSunp 4DmVqtwAL6dvh7zveKN/r1cXXUlU6gBAE8u9Lu7uK9wPtJkDcuFZ6Am2r+Ge49EhXMmyOs aQbS7GeTw1ixl17wa6lt1q/TXiQsFFb0Peb/S4n5EUFEglzLNAIGVmzvnGnecQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; dmarc=none; 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: -1.43 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; 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: F2BDC179A7 X-Spam-Score: -1.43 X-Migadu-Scanner: scn0.migadu.com X-TUID: sw5y9lKQgLHO Fixes . * gnu/services/base.scm (file-system-type->utilities, file-system-utilities): New procedures. (file-system-service-type): Extend 'profile-service-type' with 'file-system-utilities'. * gnu/system.scm (boot-file-system-service): New procedure… (operating-system-default-essential-services): …use it. (%base-packages): Remove 'e2fsprogs'. * gnu/system/file-systems.scm (file-system): Add 'utilities?' field. * doc/guix.texi (File Systems): Document 'file-system-utilities?'. --- doc/guix.texi | 6 ++++++ gnu/services/base.scm | 40 +++++++++++++++++++++++++++++++++++-- gnu/system.scm | 28 ++++++++++++++++---------- gnu/system/file-systems.scm | 6 +++++- 4 files changed, 67 insertions(+), 13 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index efeb176e3d..3115dbed38 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14031,6 +14031,12 @@ a dependency of @file{/sys/fs/cgroup/cpu} and Another example is a file system that depends on a mapped device, for example for an encrypted partition (@pxref{Mapped Devices}). + +@item @code{utilities?} (default: @code{#t}) +When true, the filesystem utility package is added to the system +profile. Such as @code{e2fsprogs} for ext4 or @code{btrfs-progs} for +Btrfs partitions. + @end table @end deftp diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 3be2e984c3..9a05dd3c02 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -46,13 +46,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 + e2fsprogs f2fs-tools fuse gpm kbd lvm2 rng-tools + util-linux xfsprogs)) #:use-module (gnu packages bash) #:use-module ((gnu packages base) #:select (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)) @@ -69,6 +76,7 @@ #:export (fstab-service-type root-file-system-service file-system-service-type + file-system-utilities swap-service host-name-service %default-console-font @@ -422,6 +430,32 @@ FILE-SYSTEM." (memq 'bind-mount (file-system-flags file-system)))) file-systems)) +(define (file-system-type->utilities type) + "Return a package providing the utilities for file system TYPE, #f +otherwise." + (assoc-ref + `(("bcachefs" . ,bcachefs-tools) + ("btrfs" . ,btrfs-progs) + ("exfat" . ,exfat-utils) + ("ext2" . ,e2fsprogs) + ("ext3" . ,e2fsprogs) + ("ext4" . ,e2fsprogs) + ("fat" . ,dosfstools) + ("f2fs" . ,f2fs-tools) + ("jfs" . ,jfsutils) + ("vfat" . ,dosfstools) + ("xfs" . ,xfsprogs) + ("zfs" . ,zfs)) + type)) + +(define (file-system-utilities file-systems) + "Return a list of packages containing file system utilities for +FILE-SYSTEMS." + (filter-map (lambda (file-system) + (when (file-system-utilities? file-system) + (file-system-type->utilities (file-system-type file-system)))) + file-systems)) + (define file-system-service-type (service-type (name 'file-systems) (extensions @@ -429,6 +463,8 @@ FILE-SYSTEM." file-system-shepherd-services) (service-extension fstab-service-type file-system-fstab-entries) + (service-extension profile-service-type + file-system-utilities) ;; Have 'user-processes' depend on 'file-systems'. (service-extension user-processes-service-type diff --git a/gnu/system.scm b/gnu/system.scm index 8a3ae27d04..23b4b23c28 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -526,6 +526,14 @@ marked as 'needed-for-boot'." (service file-system-service-type (map add-dependencies file-systems))) +(define (boot-file-system-service os) + "Return a service which adds, to the system profile, packages providing the +utilites for the file systems marked as 'needed-for-boot' in OS." + (let ((file-systems (filter file-system-needed-for-boot? + (operating-system-file-systems os)))) + (simple-service 'boot-file-system-utilities profile-service-type + (file-system-utilities file-systems)))) + (define (mapped-device-users device file-systems) "Return the subset of FILE-SYSTEMS that use DEVICE." (let ((targets (map (cut string-append "/dev/mapper/" <>) @@ -637,13 +645,14 @@ bookkeeping." (define known-fs (map file-system-mount-point (operating-system-file-systems os))) - (let* ((mappings (device-mapping-services os)) - (root-fs (root-file-system-service)) - (other-fs (non-boot-file-system-service os)) - (swaps (swap-services os)) - (procs (service user-processes-service-type)) - (host-name (host-name-service (operating-system-host-name os))) - (entries (operating-system-directory-base-entries os))) + (let* ((mappings (device-mapping-services os)) + (root-fs (root-file-system-service)) + (boot-fs (boot-file-system-service os)) + (non-boot-fs (non-boot-file-system-service os)) + (swaps (swap-services os)) + (procs (service user-processes-service-type)) + (host-name (host-name-service (operating-system-host-name os))) + (entries (operating-system-directory-base-entries os))) (cons* (service system-service-type entries) (service linux-builder-service-type (linux-builder-configuration @@ -674,7 +683,7 @@ bookkeeping." (operating-system-setuid-programs os)) (service profile-service-type (operating-system-packages os)) - other-fs + boot-fs non-boot-fs (append mappings swaps ;; Add the firmware service. @@ -812,8 +821,7 @@ of PROVENANCE-SERVICE-TYPE to its services." (define %base-packages ;; Default set of packages globally visible. It should include anything ;; required for basic administrator tasks. - (append (list e2fsprogs) - %base-packages-interactive + (append %base-packages-interactive %base-packages-linux %base-packages-networking %base-packages-utils)) diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index 464e87cb18..35803d39e9 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -3,6 +3,7 @@ ;;; Copyright © 2020 Google LLC ;;; Copyright © 2020 Jakub Kądziołka ;;; Copyright © 2020 Maxim Cournoyer +;;; Copyright © 2020 Brice Waegeneire ;;; ;;; This file is part of GNU Guix. ;;; @@ -54,6 +55,7 @@ file-system-create-mount-point? file-system-dependencies file-system-location + file-system-utilities? file-system-type-predicate btrfs-subvolume? @@ -129,7 +131,9 @@ (default '())) ; or (location file-system-location (default (current-source-location)) - (innate))) + (innate)) + (utilities? file-system-utilities? ; Boolean + (default #t))) ;; A file system label for use in the 'device' field. (define-record-type -- 2.31.1