From patchwork Thu Apr 23 12:00:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Brice Waegeneire X-Patchwork-Id: 21434 X-Patchwork-Delegate: mail@cbaines.net 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 EA5C327BBE4; Thu, 23 Apr 2020 13:01:17 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTP id 7FE9827BBE1 for ; Thu, 23 Apr 2020 13:01:17 +0100 (BST) Received: from localhost ([::1]:41934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRaXc-00083S-Vs for patchwork@mira.cbaines.net; Thu, 23 Apr 2020 08:01:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:49918) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jRaXQ-0007rm-96 for guix-patches@gnu.org; Thu, 23 Apr 2020 08:01:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.90_1) (envelope-from ) id 1jRaXP-000810-C7 for guix-patches@gnu.org; Thu, 23 Apr 2020 08:01:04 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:42644) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1jRaXO-0007yQ-Kt for guix-patches@gnu.org; Thu, 23 Apr 2020 08:01:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1jRaXN-0001VH-VV for guix-patches@gnu.org; Thu, 23 Apr 2020 08:01:02 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#40480] [PATCH v4] services: Add file system utilities to profile. References: <20200407083054.19472-1-brice@waegenei.re> In-Reply-To: <20200407083054.19472-1-brice@waegenei.re> Resent-From: Brice Waegeneire Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 23 Apr 2020 12:01:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 40480 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 40480@debbugs.gnu.org Received: via spool by 40480-submit@debbugs.gnu.org id=B40480.15876432205718 (code B ref 40480); Thu, 23 Apr 2020 12:01:01 +0000 Received: (at 40480) by debbugs.gnu.org; 23 Apr 2020 12:00:20 +0000 Received: from localhost ([127.0.0.1]:54190 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jRaWh-0001U9-Tu for submit@debbugs.gnu.org; Thu, 23 Apr 2020 08:00:20 -0400 Received: from relay8-d.mail.gandi.net ([217.70.183.201]:54685) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1jRaWf-0001To-6s for 40480@debbugs.gnu.org; Thu, 23 Apr 2020 08:00:18 -0400 X-Originating-IP: 78.237.113.178 Received: from localhost (luy13-1-78-237-113-178.fbx.proxad.net [78.237.113.178]) (Authenticated sender: brice@waegenei.re) by relay8-d.mail.gandi.net (Postfix) with ESMTPSA id 6F65D1BF212 for <40480@debbugs.gnu.org>; Thu, 23 Apr 2020 12:00:08 +0000 (UTC) From: Brice Waegeneire Date: Thu, 23 Apr 2020 14:00:02 +0200 Message-Id: <20200423120002.32554-1-brice@waegenei.re> X-Mailer: git-send-email 2.26.0 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Received-From: 209.51.188.43 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" X-getmail-retrieved-from-mailbox: Patches * 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. --- Fix bcachefs typo and replace 'utils' by 'utilities'. Reword the documentation procedures to be clearer. Remove (srfi srfi-2) and (ice-9 regex) which weren't used since v1. gnu/services/base.scm | 40 +++++++++++++++++++++++++++++++++++-- gnu/system.scm | 28 ++++++++++++++++---------- gnu/system/file-systems.scm | 6 +++++- 3 files changed, 61 insertions(+), 13 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 2913478e4a..9b2c8c22b9 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)) @@ -66,6 +73,7 @@ #:export (fstab-service-type root-file-system-service file-system-service-type + file-system-utilities swap-service host-name-service console-keymap-service @@ -413,6 +421,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 @@ -420,6 +454,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 29e622872d..3b8a1c4822 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -424,6 +424,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 ((target (string-append "/dev/mapper/" (mapped-device-target device)))) @@ -519,13 +527,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) %boot-service @@ -552,7 +561,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. @@ -645,8 +654,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 3b599efa8e..f78c3b1b8e 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 +;;; Copyright © 2020 Brice Waegeneire ;;; ;;; This file is part of GNU Guix. ;;; @@ -42,6 +43,7 @@ file-system-create-mount-point? file-system-dependencies file-system-location + file-system-utilities? file-system-type-predicate @@ -111,7 +113,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