From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp0 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MEGvB6xI9V/HGAAA0tVLHw (envelope-from ) for ; Wed, 06 Jan 2021 05:20:44 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp0 with LMTPS id 4J6CA6xI9V9FUgAA1q6Kng (envelope-from ) for ; Wed, 06 Jan 2021 05:20:44 +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 511899402D6 for ; Wed, 6 Jan 2021 05:20:43 +0000 (UTC) Received: from localhost ([::1]:45020 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kx1FS-00075y-72 for larch@yhetil.org; Wed, 06 Jan 2021 00:20:42 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:60998) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kx1FJ-00075g-3I for guix-devel@gnu.org; Wed, 06 Jan 2021 00:20:33 -0500 Received: from mail-40130.protonmail.ch ([185.70.40.130]:60461) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kx1FF-0004m2-RN for guix-devel@gnu.org; Wed, 06 Jan 2021 00:20:32 -0500 Date: Wed, 06 Jan 2021 05:20:23 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1609910426; bh=Jj6WgfTuhMHEfsjWdGM8lxYFpdhn5e9Fz/Ov3O7DeOA=; h=Date:To:From:Reply-To:Subject:In-Reply-To:References:From; b=ScS2Foeojs977t0K6j5DVZJAYQiOaSi8bCHDY/eKYoViZ7TFawE/SRYue7nDmR98G 5L3xidfpck5QJyCqvjGWQ4ZA4G9Ox3X8bF246VdaLszGqPqK1i7z8L+whgLk8lkp2E 2gMIumCkfUiWcHkaoqVu0TmK3Res+2j5LB6Xz8QE= To: "guix-devel@gnu.org" From: raid5atemyhomework Subject: Re: ZFS on Guix Message-ID: In-Reply-To: References: <_1CLe9QSGsoMlu5WxBMXm4CbFLM_M9iRG1XQF9GDsK0GP208jpngdymfix4tAfoLP94mhMTt-Tx6OP2xN_n78Jhx5KQzkiqPpIci_44C9OI=@protonmail.com> <87lfd698xq.fsf@zancanaro.id.au> <5DEAAAD8-1D08-4489-9AEC-675618F8E388@zancanaro.id.au> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=185.70.40.130; envelope-from=raid5atemyhomework@protonmail.com; helo=mail-40130.protonmail.ch X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: guix-devel@gnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "Development of GNU Guix and the GNU System distribution." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: raid5atemyhomework Errors-To: guix-devel-bounces+larch=yhetil.org@gnu.org Sender: "Guix-devel" X-Migadu-Flow: FLOW_IN X-Migadu-Spam-Score: -3.04 Authentication-Results: aspmx1.migadu.com; dkim=pass header.d=protonmail.com header.s=protonmail header.b=ScS2Foeo; dmarc=pass (policy=quarantine) header.from=protonmail.com; spf=pass (aspmx1.migadu.com: domain of guix-devel-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=guix-devel-bounces@gnu.org X-Migadu-Queue-Id: 511899402D6 X-Spam-Score: -3.04 X-Migadu-Scanner: scn0.migadu.com X-TUID: NI4c40OtRb+q Hi guix-developers, Another issue here is that ZFS prefers to not be managed via `/etc/fstab`/`= mount`/`umount`. Instead, at startup ZFS magically imports ZFS pools and m= ounts ZFS datasets in the correct place, as configured in the `mountpoint` = properties of the dataset. This magic is actually implemented by executing= `zpool import -a` at startup after ZFS module loading. Note that `zpool i= mport -a` has to be executed always so that ZFS can detect its pools, thoug= h the automatic mounting can be suppressed with `zpool import -a -N`. (`systemd`-based distros have a number of `systemd` services that handle ZF= S importation by use of a `/etc/zfs/zpool.cache` file that ZFS maintains, a= nd then does `zfs mount -a` to do automounting, but I'll leave that for lat= er.) Now, properly speaking, the shepherd `file-systems` service should not be s= tarted until we have actually performed ZFS automounting. This means that = `file-systems` has to have as a requirement the ZFS shepherd service that i= mplements the automounting. And of course it should *not* require that if = ZFS isn't installed in the system. So, I made another patch that makes the `file-systems` shepherd service hav= e an extensible set of requirements, like `user-processes` does. It's belo= w. Actual `file-system`s declared in the operating system then make themse= lves requirements of `file-systems`. Then, a ZFS automounting shepherd ser= vice can be installed by the `zfs-service-type` and added as a requirement = of the `file-systems` shepherd service. This is important since one possible use of ZFS is to have it provide the `= /home` filesystem. And the `/home` filesystem has to be mounted before `us= er-homes` shepherd service starts. So the ZFS automounting shepherd servic= e has to be a requirement of `file-systems`, which is enabled by the below. Please review! >From 792a8f8efc95e4fe9a94d42f839ddcfb034b8540 Mon Sep 17 00:00:00 2001 From: raid5atemyhomework Date: Wed, 6 Jan 2021 08:15:54 +0800 Subject: [PATCH] gnu: Make file-systems target extensible by services. * gnu/services/base.scm (file-system-shepherd-services): Move file-systems shepherd service to ... (file-systems-target-shepherd-services): ... new procedure here. (file-systems-target-service-type): New variable. (file-system-service-type): Extend file-systems-target service to add each file-system as a requirement. * gnu/system.scm (operating-system-default-essential-services): Instantiate file-systems-target-service-type. (hurd-default-essential-services): Instantiate file-systems-target-service-= type. --- gnu/services/base.scm | 37 +++++++++++++++++++++++++++---------- gnu/system.scm | 2 ++ 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 945b546607..13cfb6a8a2 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -13,6 +13,7 @@ ;;; Copyright =C2=A9 2019 Jan (janneke) Nieuwenhuizen ;;; Copyright =C2=A9 2020 Florian Pelz ;;; Copyright =C2=A9 2020 Brice Waegeneire +;;; Copyright =C2=A9 2021 raid5atemyhomework ;;; ;;; This file is part of GNU Guix. ;;; @@ -67,6 +68,7 @@ #:export (fstab-service-type root-file-system-service file-system-service-type + file-systems-target-service-type swap-service host-name-service console-keymap-service @@ -362,18 +364,29 @@ FILE-SYSTEM." (gnu system file-systems) ,@%default-modules))))))) +(define (file-systems-target-shepherd-services requirements) + (list + (shepherd-service + (provision '(file-systems)) + (requirement (cons* 'root-file-system 'user-file-systems requirement= s)) + (documentation "Target for all the initially-mounted file systems") + (start #~(const #t)) + (stop #~(const #t))))) +(define file-systems-target-service-type + (service-type + (name 'file-systems) + (extensions (list (service-extension shepherd-root-service-type + file-systems-target-shepherd-serv= ices))) + (compose concatenate) + (extend append) + ;; Extensions can add new values to this list. + (default-value '()) + (description "The @code{file-systems} service is the target that is st= arted +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 declared file= system. + (service-extension file-systems-target-service-type + (cut map file-system->shepherd-s= ervice-name <>)) + ;; Have 'user-processes' depend on 'file-systems'. (service-extension user-processes-service-type (const '(file-systems))))) diff --git a/gnu/system.scm b/gnu/system.scm index 5c530f176e..6987641ee8 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -667,6 +667,7 @@ bookkeeping." (operating-system-setuid-programs os)) (service profile-service-type (operating-system-packages os)) + (service file-systems-target-service-type) other-fs (append mappings swaps @@ -691,6 +692,7 @@ bookkeeping." (operating-system-groups os)) (operating-system-skeletons os)) (root-file-system-service) + (service file-systems-target-service-type) (service file-system-service-type '()) (service fstab-service-type (filter file-system-needed-for-boot? -- 2.29.2