From patchwork Mon Jan 4 01:06:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: raid5atemyhomework X-Patchwork-Id: 26206 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 6BD5327BC0A; Mon, 4 Jan 2021 01:07:10 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL, SPF_HELO_PASS,T_DKIM_INVALID,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 ESMTPS id A7D0F27BC09 for ; Mon, 4 Jan 2021 01:07:09 +0000 (GMT) Received: from localhost ([::1]:57974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kwEKy-0001DG-T3 for patchwork@mira.cbaines.net; Sun, 03 Jan 2021 20:07:08 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kwEKs-0001Bs-Hw for guix-patches@gnu.org; Sun, 03 Jan 2021 20:07:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:55691) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kwEKs-0001C6-93 for guix-patches@gnu.org; Sun, 03 Jan 2021 20:07:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kwEKs-0003fW-2t for guix-patches@gnu.org; Sun, 03 Jan 2021 20:07:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45643] [PATCH 2/3] gnu: Make 'file-systems' target extensible. References: In-Reply-To: Resent-From: raid5atemyhomework Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Mon, 04 Jan 2021 01:07:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45643 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "45643@debbugs.gnu.org" <45643@debbugs.gnu.org> Received: via spool by 45643-submit@debbugs.gnu.org id=B45643.160972240614080 (code B ref 45643); Mon, 04 Jan 2021 01:07:02 +0000 Received: (at 45643) by debbugs.gnu.org; 4 Jan 2021 01:06:46 +0000 Received: from localhost ([127.0.0.1]:39004 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kwEKb-0003f2-Jb for submit@debbugs.gnu.org; Sun, 03 Jan 2021 20:06:45 -0500 Received: from mail-40137.protonmail.ch ([185.70.40.137]:54403) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kwEKa-0003ep-5J for 45643@debbugs.gnu.org; Sun, 03 Jan 2021 20:06:44 -0500 Date: Mon, 04 Jan 2021 01:06:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1609722397; bh=Ld4GwnJKPEAGjcPN4LQCNb/ZTUuHB+22DrU5vZk6xDw=; h=Date:To:From:Reply-To:Subject:From; b=yI5a0tE1GFKjCrTls3qQnN7cTmuPC6ooUyTxb+tzsrP+BQWtYbywYd0MoHk6Yw4Ez 76aLFEX+aa8U768oo1w50K1EReNbvx5rzLReUYwvPWqkWgH7Szo00gXmo3OekVIkeN NX2mxmpWL+UhVnut52D6oSJQc9qIlWX8luYhvibM= Message-ID: MIME-Version: 1.0 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+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" Reply-to: raid5atemyhomework , raid5atemyhomework via Guix-patches X-Patchwork-Original-From: raid5atemyhomework via Guix-patches via From: raid5atemyhomework X-getmail-retrieved-from-mailbox: Patches From fc4538963960550b678713ec46ac461cfbd6173e Mon Sep 17 00:00:00 2001 From: raid5atemyhomework Date: Sun, 3 Jan 2021 21:09:02 +0800 Subject: [PATCH 2/3] gnu: Make 'file-systems' target extensible. This is to support something like ZFS, which has a service that mounts ZFS file systems and does not normally use /etc/fstab --- doc/guix.texi | 9 +++++++-- gnu/services/base.scm | 37 +++++++++++++++++++++++++---------- gnu/services/file-systems.scm | 5 +++-- 3 files changed, 37 insertions(+), 14 deletions(-) -- 2.29.2 diff --git a/doc/guix.texi b/doc/guix.texi index 5ad3907dbe..4544b481b0 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13982,8 +13982,13 @@ mount ZFS pools that have a non-@code{legacy} mountpoint. If ZFS finds mountable ZFS filesystems that are encrypted by passphrase, it will prompt for passphrases on the console. -ZFS as root filesystem is not supported yet. ZFS for @code{/home} is -also probably not easily doable yet. +You can put @code{/home} on a ZFS filesystem by setting it as the +mountpoint of some ZFS filesystem. However, ZFS will refuse to mount +onto a non-empty directory, so if you already have an existing +@code{/home} you have to remove all files in it, then reboot to let +ZFS mount into @code{/home}. + +ZFS as root filesystem is not supported yet. @node Mapped Devices @section Mapped Devices diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 945b546607..deffd49154 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -66,6 +66,7 @@ %default-substitute-urls) #:export (fstab-service-type root-file-system-service + file-systems-service-type file-system-service-type swap-service host-name-service @@ -362,18 +363,30 @@ FILE-SYSTEM." (gnu system file-systems) ,@%default-modules))))))) +(define (file-systems-service requirements) + (list + (shepherd-service + (provision '(file-systems)) + (requirement (cons* 'root-file-system 'user-file-systems requirements)) + (documentation "Target for all the initially-mounted file systems") + (start #~(const #t)) + (stop #~(const #t))))) + +(define file-systems-service-type + (service-type + (name 'file-systems) + (extensions (list (service-extension shepherd-root-service-type + file-systems-service))) + (compose concatenate) + (extend append) + ;; Extensions can add new services to this list. + (default-value '()) + (description "The @code{file-systems} service is the target that is started +when all file systems have been mounted."))) + (define (file-system-shepherd-services file-systems) "Return the list of Shepherd services for FILE-SYSTEMS." (let* ((file-systems (filter file-system-mount? file-systems))) - (define sink - (shepherd-service - (provision '(file-systems)) - (requirement (cons* 'root-file-system 'user-file-systems - (map file-system->shepherd-service-name - file-systems))) - (documentation "Target for all the initially-mounted file systems") - (start #~(const #t)) - (stop #~(const #f)))) (define known-mount-points (map file-system-mount-point file-systems)) @@ -403,7 +416,7 @@ FILE-SYSTEM." (filter (negate known?) (mount-points))) #f)))) - (cons* sink user-unmount + (cons* user-unmount (map file-system-shepherd-service file-systems)))) (define (file-system-fstab-entries file-systems) @@ -431,6 +444,10 @@ FILE-SYSTEM." (service-extension fstab-service-type file-system-fstab-entries) + ;; Have 'file-systems' depend on each file-system + (service-extension file-systems-service-type + (cut map file-system->shepherd-service-name <>)) + ;; Have 'user-processes' depend on 'file-systems'. (service-extension user-processes-service-type (const '(file-systems))))) diff --git a/gnu/services/file-systems.scm b/gnu/services/file-systems.scm index bdc33f4028..73a6d52538 100644 --- a/gnu/services/file-systems.scm +++ b/gnu/services/file-systems.scm @@ -19,6 +19,7 @@ (define-module (gnu services file-systems) #:use-module (guix gexp) #:use-module (gnu services) + #:use-module (gnu services base) #:use-module (gnu services shepherd)) ;;; ZFS @@ -28,7 +29,7 @@ (shepherd-service (documentation "Load ZFS kernel module and import ZFS pools.") (provision '(zfs-loader)) - (requirement '(file-systems)) + (requirement '(root-file-system)) (one-shot? #t) (modules `((srfi srfi-1) (srfi srfi-34) @@ -68,5 +69,5 @@ (description "Load ZFS kernel module and import ZFS pools.") (extensions (list (service-extension shepherd-root-service-type zfs-loader-shepherd-service) - (service-extension user-processes-service-type (const '(zfs-loader))))))) + (service-extension file-systems-service-type (const '(zfs-loader)))))))