From patchwork Wed Jan 6 15:54:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: raid5atemyhomework X-Patchwork-Id: 26244 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 328F827BC0F; Wed, 6 Jan 2021 15:55:16 +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 2B54627BC0E for ; Wed, 6 Jan 2021 15:55:15 +0000 (GMT) Received: from localhost ([::1]:40934 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxB9W-0001OS-CU for patchwork@mira.cbaines.net; Wed, 06 Jan 2021 10:55:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43484) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxB9L-0001Nx-0H for guix-patches@gnu.org; Wed, 06 Jan 2021 10:55:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33753) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxB9J-0005oR-SI for guix-patches@gnu.org; Wed, 06 Jan 2021 10:55:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kxB9J-00021U-Rb for guix-patches@gnu.org; Wed, 06 Jan 2021 10:55:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45692] [PATCH 1/4] gnu: Allow services to install kernel-loadable modules. References: In-Reply-To: Resent-From: raid5atemyhomework Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 06 Jan 2021 15:55:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45692 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "45692@debbugs.gnu.org" <45692@debbugs.gnu.org> Received: via spool by 45692-submit@debbugs.gnu.org id=B45692.16099484947757 (code B ref 45692); Wed, 06 Jan 2021 15:55:01 +0000 Received: (at 45692) by debbugs.gnu.org; 6 Jan 2021 15:54:54 +0000 Received: from localhost ([127.0.0.1]:45299 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxB97-00020x-L4 for submit@debbugs.gnu.org; Wed, 06 Jan 2021 10:54:54 -0500 Received: from mail-40132.protonmail.ch ([185.70.40.132]:19967) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxB92-00020b-GN for 45692@debbugs.gnu.org; Wed, 06 Jan 2021 10:54:48 -0500 Date: Wed, 06 Jan 2021 15:54:33 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1609948477; bh=hGPrUa6tM+1uugZYWcqsoLzUVtMpEchptuPfK1FnEJg=; h=Date:To:From:Reply-To:Subject:From; b=t54NBqbXP5kB/Kjrstc3ARP9sUJWzISaby8HMNpvRGeebjx5kt26uvbY1FjBIEmss KToZQh4So8J/A+bx4i5SzJ2v5SXjVoXSzbVgzjLOq/rhrgwVyHECZKSB+GYmkWOue1 CIBIy9EbQ9gN1MxN6dqfI/H/e60cadqGjsHFmizc= Message-ID: <2yOs7mxigs8_Vx_yi858pxAkoyXmU8IidizK5grcmX4M92O5QK-_Ywo9nrHMHvzLGj4U7B9ysl26eNbiPmzmeOQsuFvp5VjouVptRfwxKng=@protonmail.com> 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 4beb73c62995cf236b402dad8e1c36016027c781 Mon Sep 17 00:00:00 2001 From: raid5atemyhomework Date: Tue, 5 Jan 2021 22:27:56 +0800 Subject: [PATCH 1/4] gnu: Allow services to install kernel-loadable modules. * gnu/system.scm (operating-system-directory-base-entries): Remove code to handle generation of "kernel" and "hurd". (operating-system-default-essential-services): Instantiate kernel-loadable-module-service. (hurd-default-essential-services): Instantiate kernel-loadable-module-service. (package-for-kernel): Move ... * gnu/services.scm: ... to here. (kernel-loadable-module-service-type): New variable. (kernel-loadable-module-service): New procedure. * gnu/tests/linux-modules.scm (run-loadable-kernel-modules-test): Move code to ... (run-loadable-kernel-modules-test-base): ... new procedure here. (run-loadable-kernel-modules-service-test): New procedure. (%test-loadable-kernel-modules-service-0): New variable. (%test-loadable-kernel-modules-service-1): New variable. (%test-loadable-kernel-modules-service-2): New variable. * doc/guix.texi: Document kernel-loadable-module-service-type. --- doc/guix.texi | 6 +++ gnu/services.scm | 70 ++++++++++++++++++++++++++++++++ gnu/system.scm | 37 +++++------------ gnu/tests/linux-modules.scm | 81 ++++++++++++++++++++++++++++++++----- 4 files changed, 157 insertions(+), 37 deletions(-) -- 2.29.2 diff --git a/doc/guix.texi b/doc/guix.texi index 0f6e95a65a..78770151e3 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -32409,6 +32409,12 @@ configuration when you use @command{guix system reconfigure}, @command{guix system init}, or @command{guix deploy}. @end defvr +@defvr {Scheme Variable} kernel-loadable-module-service-type +Type of the service that collects lists of packages containing +kernel-loadable modules, and adds them to the set of kernel-loadable +modules. +@end defvr + @node Shepherd Services @subsection Shepherd Services diff --git a/gnu/services.scm b/gnu/services.scm index 13259dfaee..d7332a46b2 100644 --- a/gnu/services.scm +++ b/gnu/services.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2015, 2016, 2017, 2018, 2019, 2020 Ludovic Courtès ;;; Copyright © 2016 Chris Marusich ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen +;;; Copyright © 2021 raid5atemyhomework ;;; ;;; This file is part of GNU Guix. ;;; @@ -33,6 +34,8 @@ #:use-module (guix diagnostics) #:autoload (guix openpgp) (openpgp-format-fingerprint) #:use-module (guix modules) + #:use-module (guix packages) + #:use-module (guix utils) #:use-module (gnu packages base) #:use-module (gnu packages bash) #:use-module (gnu packages hurd) @@ -75,6 +78,7 @@ service-back-edges instantiate-missing-services fold-services + kernel-loadable-module-service service-error? missing-value-service-error? @@ -106,6 +110,7 @@ profile-service-type firmware-service-type gc-root-service-type + kernel-loadable-module-service-type %boot-service %activation-service @@ -864,6 +869,71 @@ as Wifi cards."))) will not be reclaimed by the garbage collector.") (default-value '()))) +;; Configuration for the kernel builder. +(define-record-type* kernel-builder-configuration + make-kernel-builder-configuration + kernel-builder-configuration? + this-kernel-builder-configuration + + (kernel kernel-builder-configuration-kernel (default #f)) + (hurd kernel-builder-configuration-hurd (default #f)) + (modules kernel-builder-configuration-modules (default '()))) + +(define (package-for-kernel target-kernel module-package) + "Return a package like MODULE-PACKAGE, adapted for TARGET-KERNEL, if +possible (that is if there's a LINUX keyword argument in the build system)." + (package + (inherit module-package) + (arguments + (substitute-keyword-arguments (package-arguments module-package) + ((#:linux kernel #f) + target-kernel))))) + +(define (kernel-builder-configuration->system-entry config) + "Return the kernel and hurd entries of the 'system' directory." + (mbegin %store-monad + (let* ((kernel (kernel-builder-configuration-kernel config)) + (hurd (kernel-builder-configuration-hurd config)) + (modules (kernel-builder-configuration-modules config)) + (kernel (if hurd + kernel + (profile + (content (packages->manifest + (cons kernel + (map (lambda (module) + (if (package? module) + (package-for-kernel kernel module) + module)) + modules)))) + (hooks (list linux-module-database)))))) + (return `(("kernel" ,kernel) + ,@(if hurd `(("hurd" ,hurd)) '())))))) + +(define (kernel-builder-configuration-add-modules config modules) + "Constructs a kernel builder configuration that has its modules extended." + (kernel-builder-configuration + (inherit config) + (modules (append (kernel-builder-configuration-modules config) modules)))) + +(define kernel-loadable-module-service-type + (service-type (name 'kernel-loadable-modules) + (extensions + (list (service-extension system-service-type + kernel-builder-configuration->system-entry))) + (compose concatenate) + (extend kernel-builder-configuration-add-modules) + (description + "Register packages containing kernel-loadable modules and adds them +to the system."))) + +(define (kernel-loadable-module-service kernel hurd modules) + "Constructs the service that sets up kernel loadable modules." + (service kernel-loadable-module-service-type + (kernel-builder-configuration + (kernel kernel) + (hurd hurd) + (modules modules)))) + ;;; ;;; Service folding. diff --git a/gnu/system.scm b/gnu/system.scm index c284a18379..5c530f176e 100644 --- a/gnu/system.scm +++ b/gnu/system.scm @@ -12,6 +12,7 @@ ;;; Copyright © 2020 Maxim Cournoyer ;;; Copyright © 2020 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2020 Efraim Flashner +;;; Copyright © 2021 raid5atemyhomework ;;; ;;; This file is part of GNU Guix. ;;; @@ -600,16 +601,6 @@ OS." (file-append (operating-system-kernel os) "/" (system-linux-image-file-name)))) -(define (package-for-kernel target-kernel module-package) - "Return a package like MODULE-PACKAGE, adapted for TARGET-KERNEL, if -possible (that is if there's a LINUX keyword argument in the build system)." - (package - (inherit module-package) - (arguments - (substitute-keyword-arguments (package-arguments module-package) - ((#:linux kernel #f) - target-kernel))))) - (define %default-modprobe-blacklist ;; List of kernel modules to blacklist by default. '("usbmouse" ;races with bcm5974, see @@ -625,26 +616,10 @@ possible (that is if there's a LINUX keyword argument in the build system)." "Return the basic entries of the 'system' directory of OS for use as the value of the SYSTEM-SERVICE-TYPE service." (let* ((locale (operating-system-locale-directory os)) - (kernel (operating-system-kernel os)) (hurd (operating-system-hurd os)) - (modules (operating-system-kernel-loadable-modules os)) - (kernel (if hurd - kernel - (profile - (content (packages->manifest - (cons kernel - (map (lambda (module) - (if (package? module) - (package-for-kernel kernel - module) - module)) - modules)))) - (hooks (list linux-module-database))))) (initrd (and (not hurd) (operating-system-initrd-file os))) (params (operating-system-boot-parameters-file os))) - `(("kernel" ,kernel) - ,@(if hurd `(("hurd" ,hurd)) '()) - ("parameters" ,params) + `(("parameters" ,params) ,@(if initrd `(("initrd" ,initrd)) '()) ("locale" ,locale)))) ;used by libc @@ -663,6 +638,10 @@ bookkeeping." (host-name (host-name-service (operating-system-host-name os))) (entries (operating-system-directory-base-entries os))) (cons* (service system-service-type entries) + (kernel-loadable-module-service + (operating-system-kernel os) + (operating-system-hurd os) + (operating-system-kernel-loadable-modules os)) %boot-service ;; %SHEPHERD-ROOT-SERVICE must come last so that the gexp that @@ -699,6 +678,10 @@ bookkeeping." (define (hurd-default-essential-services os) (let ((entries (operating-system-directory-base-entries os))) (list (service system-service-type entries) + (kernel-loadable-module-service + (operating-system-kernel os) + (operating-system-hurd os) + (operating-system-kernel-loadable-modules os)) %boot-service %hurd-startup-service %activation-service diff --git a/gnu/tests/linux-modules.scm b/gnu/tests/linux-modules.scm index 953b132ef7..9739e4124d 100644 --- a/gnu/tests/linux-modules.scm +++ b/gnu/tests/linux-modules.scm @@ -2,6 +2,7 @@ ;;; Copyright © 2019 Jakob L. Kreuze ;;; Copyright © 2020 Danny Milosavljevic ;;; Copyright © 2020 Brice Waegeneire +;;; Copyright © 2021 raid5atemyhomework ;;; ;;; This file is part of GNU Guix. ;;; @@ -34,7 +35,10 @@ #:use-module (guix utils) #:export (%test-loadable-kernel-modules-0 %test-loadable-kernel-modules-1 - %test-loadable-kernel-modules-2)) + %test-loadable-kernel-modules-2 + %test-loadable-kernel-modules-service-0 + %test-loadable-kernel-modules-service-1 + %test-loadable-kernel-modules-service-2)) ;;; Commentary: ;;; @@ -66,17 +70,11 @@ that MODULES are actually loaded." (member module modules string=?)) '#$modules)))))) -(define* (run-loadable-kernel-modules-test module-packages module-names) - "Run a test of an OS having MODULE-PACKAGES, and verify that MODULE-NAMES -are loaded in memory." +(define* (run-loadable-kernel-modules-test-base base-os module-names) + "Run a test of BASE-OS, verifying that MODULE-NAMES are loaded in memory." (define os (marionette-operating-system - (operating-system - (inherit (simple-operating-system)) - (services (cons (service kernel-module-loader-service-type module-names) - (operating-system-user-services - (simple-operating-system)))) - (kernel-loadable-modules module-packages)) + base-os #:imported-modules '((guix combinators)))) (define vm (virtual-machine os)) (define (test script) @@ -98,6 +96,37 @@ are loaded in memory." (gexp->derivation "loadable-kernel-modules" (test (modules-loaded?-program os module-names)))) +(define* (run-loadable-kernel-modules-test module-packages module-names) + "Run a test of an OS having MODULE-PACKAGES, and verify that MODULE-NAMES +are loaded in memory." + (run-loadable-kernel-modules-test-base + (operating-system + (inherit (simple-operating-system)) + (services (cons (service kernel-module-loader-service-type module-names) + (operating-system-user-services + (simple-operating-system)))) + (kernel-loadable-modules module-packages)) + module-names)) + +(define* (run-loadable-kernel-modules-service-test module-packages module-names) + "Run a test of an OS having MODULE-PACKAGES, which are loaded by creating a +service that extends KERNEL-LOADABLE-MODULE-SERVICE-TYPE. Then verify that +MODULE-NAMES are loaded in memory." + (define module-installing-service-type + (service-type + (name 'module-installing-service) + (extensions (list (service-extension kernel-loadable-module-service-type + (const module-packages)))) + (default-value #f))) + (run-loadable-kernel-modules-test-base + (operating-system + (inherit (simple-operating-system)) + (services (cons* (service kernel-module-loader-service-type module-names) + (service module-installing-service-type) + (operating-system-user-services + (simple-operating-system))))) + module-names)) + (define %test-loadable-kernel-modules-0 (system-test (name "loadable-kernel-modules-0") @@ -129,3 +158,35 @@ with two extra modules.") (package-arguments ddcci-driver-linux)))))) '("acpi_call" "ddcci"))))) + +(define %test-loadable-kernel-modules-service-0 + (system-test + (name "loadable-kernel-modules-service-0") + (description "Tests loadable kernel modules extensible service with no +extra modules.") + (value (run-loadable-kernel-modules-service-test '() '())))) + +(define %test-loadable-kernel-modules-service-1 + (system-test + (name "loadable-kernel-modules-service-1") + (description "Tests loadable kernel modules extensible service with one +extra module.") + (value (run-loadable-kernel-modules-service-test + (list ddcci-driver-linux) + '("ddcci"))))) + +(define %test-loadable-kernel-modules-service-2 + (system-test + (name "loadable-kernel-modules-service-2") + (description "Tests loadable kernel modules extensible service with two +extra modules.") + (value (run-loadable-kernel-modules-service-test + (list acpi-call-linux-module + (package + (inherit ddcci-driver-linux) + (arguments + `(#:linux #f + ,@(strip-keyword-arguments '(#:linux) + (package-arguments + ddcci-driver-linux)))))) + '("acpi_call" "ddcci"))))) From patchwork Wed Jan 6 15:55:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: raid5atemyhomework X-Patchwork-Id: 26245 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 64D1927BC0F; Wed, 6 Jan 2021 15:56:11 +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 C7D5527BC0E for ; Wed, 6 Jan 2021 15:56:10 +0000 (GMT) Received: from localhost ([::1]:41286 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxBAQ-0001eS-0A for patchwork@mira.cbaines.net; Wed, 06 Jan 2021 10:56:10 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:43858) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxBAJ-0001eE-5u for guix-patches@gnu.org; Wed, 06 Jan 2021 10:56:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33762) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxBAI-0006PZ-VL for guix-patches@gnu.org; Wed, 06 Jan 2021 10:56:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kxBAI-00023r-Ux for guix-patches@gnu.org; Wed, 06 Jan 2021 10:56:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45692] [PATCH 2/4] gnu: Make file-systems target extensible by services. References: In-Reply-To: Resent-From: raid5atemyhomework Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 06 Jan 2021 15:56:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45692 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "45692@debbugs.gnu.org" <45692@debbugs.gnu.org> Received: via spool by 45692-submit@debbugs.gnu.org id=B45692.16099485487882 (code B ref 45692); Wed, 06 Jan 2021 15:56:02 +0000 Received: (at 45692) by debbugs.gnu.org; 6 Jan 2021 15:55:48 +0000 Received: from localhost ([127.0.0.1]:45306 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxBA4-000234-BS for submit@debbugs.gnu.org; Wed, 06 Jan 2021 10:55:48 -0500 Received: from mail-40137.protonmail.ch ([185.70.40.137]:29246) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxBA2-00022q-FJ for 45692@debbugs.gnu.org; Wed, 06 Jan 2021 10:55:47 -0500 Date: Wed, 06 Jan 2021 15:55:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1609948539; bh=GxSEl8pf4rtfbeKWy5CBrnQ7sXo8U9yJRByUJ+I7Dec=; h=Date:To:From:Reply-To:Subject:From; b=PIZTFn5cFfG4etRzfdqsEMGYg1hZ50+zw2uSaY9vK+EmRdZdhy1oZXYAYQTbPFkPY HDuyliz8kirBEiqps0zct0niWFD6s0xaOq27xiRVdtNBk7EX5+f8GjPrYSe9vn8ksw jdQ7I/ugFr2x/7sMHl7OWd4wkmTTXWY6VXes8eJw= 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 792a8f8efc95e4fe9a94d42f839ddcfb034b8540 Mon Sep 17 00:00:00 2001 From: raid5atemyhomework Date: Wed, 6 Jan 2021 08:15:54 +0800 Subject: [PATCH 2/4] 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(-) -- 2.29.2 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 © 2019 Jan (janneke) Nieuwenhuizen ;;; Copyright © 2020 Florian Pelz ;;; Copyright © 2020 Brice Waegeneire +;;; Copyright © 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 requirements)) + (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-services))) + (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 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 declared file system. + (service-extension file-systems-target-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/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? From patchwork Wed Jan 6 15:56:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: raid5atemyhomework X-Patchwork-Id: 26246 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 C7D5427BC0F; Wed, 6 Jan 2021 15:57:40 +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 7A78927BC0E for ; Wed, 6 Jan 2021 15:57:40 +0000 (GMT) Received: from localhost ([::1]:43552 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxBBr-0002cM-Kt for patchwork@mira.cbaines.net; Wed, 06 Jan 2021 10:57:39 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44338) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxBBG-0002b8-4I for guix-patches@gnu.org; Wed, 06 Jan 2021 10:57:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33766) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxBBF-0006yD-SH for guix-patches@gnu.org; Wed, 06 Jan 2021 10:57:01 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kxBBF-00025n-Ra for guix-patches@gnu.org; Wed, 06 Jan 2021 10:57:01 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45692] [PATCH 3/4] gnu: Fix ZFS package. References: In-Reply-To: Resent-From: raid5atemyhomework Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 06 Jan 2021 15:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45692 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "45692@debbugs.gnu.org" <45692@debbugs.gnu.org> Received: via spool by 45692-submit@debbugs.gnu.org id=B45692.16099486138027 (code B ref 45692); Wed, 06 Jan 2021 15:57:01 +0000 Received: (at 45692) by debbugs.gnu.org; 6 Jan 2021 15:56:53 +0000 Received: from localhost ([127.0.0.1]:45312 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxBB6-00025P-S6 for submit@debbugs.gnu.org; Wed, 06 Jan 2021 10:56:53 -0500 Received: from mail-40137.protonmail.ch ([185.70.40.137]:11179) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxBB3-000257-V9 for 45692@debbugs.gnu.org; Wed, 06 Jan 2021 10:56:51 -0500 Date: Wed, 06 Jan 2021 15:56:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1609948604; bh=gPxzhvpUdKObuRlyTPGRFncAR7asLteqHD1lt9RsH7k=; h=Date:To:From:Reply-To:Subject:From; b=cUe8SFmJYjV/tomQQ1qLErI1yrkFiLs0IcJuZ2KgyxnY98g7ix6ei+7lclL2jzxNI 0i6v2sHptSrx9LVXtjLUUifJQyYBZN+ilmlZ7qmge1NsH/BwikF8bVApzkfdT9FHhy ejV4MC4O8hHTCOBwGktzFbAsd0YVci+A99GhqVWE= 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 d1c88161f2a32f4c03de57ee9d7582cc6c40f6bc Mon Sep 17 00:00:00 2001 From: raid5atemyhomework Date: Tue, 5 Jan 2021 20:00:50 +0800 Subject: [PATCH 3/4] gnu: Fix ZFS package. * gnu/packages/file-systems.scm (zfs): Correct "util-linux" input, add separate "util-linux:lib" input. --- gnu/packages/file-systems.scm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- 2.29.2 diff --git a/gnu/packages/file-systems.scm b/gnu/packages/file-systems.scm index 895ad069c5..2c5ad95d63 100644 --- a/gnu/packages/file-systems.scm +++ b/gnu/packages/file-systems.scm @@ -6,6 +6,7 @@ ;;; Copyright © 2019, 2020 Efraim Flashner ;;; Copyright © 2020 Raghav Gururajan ;;; Copyright © 2020 Morgan Smith +;;; Copyright © 2021 raid5atemyhoemwork ;;; ;;; This file is part of GNU Guix. ;;; @@ -944,7 +945,8 @@ APFS.") ("openssl" ,openssl) ("python" ,python) ("python-cffi" ,python-cffi) - ("util-linux" ,util-linux "lib") + ("util-linux" ,util-linux) + ("util-linux:lib" ,util-linux "lib") ("zlib" ,zlib))) (home-page "https://zfsonlinux.org/") (synopsis "Native ZFS on Linux") From patchwork Wed Jan 6 15:57:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: raid5atemyhomework X-Patchwork-Id: 26247 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 4689827BC0F; Wed, 6 Jan 2021 15:58:34 +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 7879927BC0E for ; Wed, 6 Jan 2021 15:58:33 +0000 (GMT) Received: from localhost ([::1]:45526 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxBCi-0003Sb-MW for patchwork@mira.cbaines.net; Wed, 06 Jan 2021 10:58:32 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:44692) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxBCE-0003Aq-V6 for guix-patches@gnu.org; Wed, 06 Jan 2021 10:58:02 -0500 Received: from debbugs.gnu.org ([209.51.188.43]:33770) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kxBCE-0007Pc-CO for guix-patches@gnu.org; Wed, 06 Jan 2021 10:58:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1kxBCE-00027j-BQ for guix-patches@gnu.org; Wed, 06 Jan 2021 10:58:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#45692] [PATCH 4/4] gnu: Add ZFS service. References: In-Reply-To: Resent-From: raid5atemyhomework Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 06 Jan 2021 15:58:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 45692 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: "45692@debbugs.gnu.org" <45692@debbugs.gnu.org> Received: via spool by 45692-submit@debbugs.gnu.org id=B45692.16099486598123 (code B ref 45692); Wed, 06 Jan 2021 15:58:02 +0000 Received: (at 45692) by debbugs.gnu.org; 6 Jan 2021 15:57:39 +0000 Received: from localhost ([127.0.0.1]:45316 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxBBr-00026v-6W for submit@debbugs.gnu.org; Wed, 06 Jan 2021 10:57:39 -0500 Received: from mail-40137.protonmail.ch ([185.70.40.137]:58035) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1kxBBo-00026g-BU for 45692@debbugs.gnu.org; Wed, 06 Jan 2021 10:57:37 -0500 Date: Wed, 06 Jan 2021 15:57:19 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail; t=1609948650; bh=+sTyLZEtmpxQDhHBaG434JA++LcD2ayQQpzePuQHEZA=; h=Date:To:From:Reply-To:Subject:From; b=pDHYImwpaLjyZKWrvu29YmIeXLLBERImkycZhPKKsQY8wxoEGwFv9CZBk9gJc6W8L Wsx9OptfvpV592a2cuCo9Aoe8lTMtBvqfKFotPtY3OPXklyIqyRZjiB6fFBVWrYNDS YMk0s/18a3u7CYDmfxK/QHJODP5ZGUNj32uvhtyM= Message-ID: <6wemXB-PfHUqbuVr5-XRf0-tY4cKGGtKiUqrZPrIZYXoBw17L3xRuZrGOJQfTo5PKfFNCM8KyRTllidoc7asPE2x98BTiJSPVR7OSjxCuw8=@protonmail.com> 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 deded39fe88c44a18b0b66bab8c4300aca4c387e Mon Sep 17 00:00:00 2001 From: raid5atemyhomework Date: Wed, 6 Jan 2021 09:24:20 +0800 Subject: [PATCH 4/4] gnu: Add ZFS service. * gnu/services/file-systems.scm: New file. (zfs-service-type): New variable. (zfs-configuration): New variable. (zfs-configuration?): New procedure. * gnu/local.mk: Add gnu/services/file-systems.scm. * doc/guix.texi (ZFS file system): New subsection. --- doc/guix.texi | 107 ++++++++++++++++++++++++++ gnu/local.mk | 2 + gnu/services/file-systems.scm | 136 ++++++++++++++++++++++++++++++++++ 3 files changed, 245 insertions(+) create mode 100644 gnu/services/file-systems.scm -- 2.29.2 diff --git a/doc/guix.texi b/doc/guix.texi index 78770151e3..62437083cb 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -13885,6 +13885,113 @@ a file system declaration such as: compress-force=zstd,space_cache=v2")) @end lisp +@node ZFS file system +@subsection ZFS file system + +The ZFS file system has a license incompatible with the Linux kernel, +and thus cannot be distributed with the kernel. However, as a user +you have the right to do whatever you want on your own hardware, +including download the ZFS source code, compile it, link it to your +own private copy of Linux, and run it. You can even use the Guix build +system to automate this. + +As a large and complex kernel module, ZFS on Linux has to be compiled +with a specific version of the kernel. Often even the latest ZFS +package available cannot be compiled with the latest Linux kernel +package provided by Guix System. Thus, installing the @code{zfs} +package is likely to fail. + +Instead, you have to use an older long-term-support Linux kernel. +Do not use @code{linux-libre-lts} as the latest long-term-support +kernel might be too new for the ZFS package; instead, explicitly +select the version number, like @code{linux-libre-5.4}. + +Then, you have to modify your system configuration file and use the +selected older kernel, and add the @code{zfs-service-type} service. + +@lisp +(use-modules (gnu)) +(use-package-modules + ; @dots{} + linux) +(use-service-modules + ; @dots{} + file-systems) + +(define my-kernel linux-libre-5.4) + +(operating-system + (kernel my-kernel) + ;; @dots{} + (services + (cons* (service zfs-service-type + (zfs-configuration + (kernel my-kernel))) + ; @dots{} + %desktop-services)) + ;; @dots{} + ) +@end lisp + +@defvr {Scheme Variable} zfs-service-type +This is the type of the service to compile and install OpenZFS to +your operating system. It loads the ZFS module at startup, imports +pools, mounts automounted ZFS datasets, installs the ZFS command +line tools, and can provide module options for the ZFS module. Its +value must be a @code{zfs-configuration} record (see below). + +Here is an example use: + +@lisp +(service zfs-service-type + (zfs-configuration + (kernel linux-libre-5.4) + (options '("zfs_arc_max=5000000000")))) +@end lisp +@end defvr + +@deftp {Data Type} zfs-configuration +This data type represents the configuration of the ZFS service. +The available fields are: + +@table @asis +@item @code{kernel} +The package of the Linux kernel to compile ZFS for. Required. + +@item @code{base-zfs} (default: @code{zfs}) +The ZFS package to use. It will be modified to use the indicated +kernel. + +@item @code{options} (default: @code{'()}) +A list of string options to pass as options to the ZFS module. +These will be put in a @file{/etc/modprobe.d/zfs.conf} file, +for example setting this to @code{'("zfs_admin_snapshot=1" +"zfs_trim_extent_bytes_min=0")} will create the following file: + +@example +options zfs zfs_admin_snapshot=1 zfs_trim_extent_bytes_min=0 +@end example +@end table +@end deftp + +Once your system has been configured to include the ZFS service +and you have restarted the system, you can manage ZFS pools and +datasets with @code{zpool} and @code{zfs} commands. + +ZFS datasets with an appropriate @code{mountpoint} property will +be automounted at startup after the root file system is started. +Encrypted datasets that are automounted will cause boot to pause +and prompt for the password to be provided on the console. + +It's possible to have a ZFS dataset as your @code{/home} by simply +setting the @code{mountpoint} property. However, note that ZFS will +refuse to mount over a non-empty directory, so if your root +filesystem already has a non-empty @code{/home}, you should remove +it and its contents, then restart the system. + +Having ZFS as a root filesystem or as @code{/boot} is not supported +yet. + @node Mapped Devices @section Mapped Devices diff --git a/gnu/local.mk b/gnu/local.mk index 53a67e6ffe..49073ac2ac 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -39,6 +39,7 @@ # Copyright © 2020 Martin Becze # Copyright © 2020 Malte Frank Gerdes # Copyright © 2020 Vinicius Monego +# Copyright © 2021 raid5atemyhomework # # This file is part of GNU Guix. # @@ -601,6 +602,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/dict.scm \ %D%/services/dns.scm \ %D%/services/docker.scm \ + %D%/services/file-systems.scm \ %D%/services/authentication.scm \ %D%/services/games.scm \ %D%/services/ganeti.scm \ diff --git a/gnu/services/file-systems.scm b/gnu/services/file-systems.scm new file mode 100644 index 0000000000..7a92a2b9d5 --- /dev/null +++ b/gnu/services/file-systems.scm @@ -0,0 +1,136 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2021 raid5atemyhomework +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix is free software; you can redistribute it and/or modify it +;;; under the terms of the GNU General Public License as published by +;;; the Free Software Foundation; either version 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix is distributed in the hope that it will be useful, but +;;; WITHOUT ANY WARRANTY; without even the implied warranty of +;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +;;; GNU General Public License for more details. +;;; +;;; You should have received a copy of the GNU General Public License +;;; along with GNU Guix. If not, see . + +(define-module (gnu services file-systems) + #:use-module (gnu packages file-systems) + #:use-module (gnu services) + #:use-module (gnu services base) + #:use-module (gnu services shepherd) + #:use-module (guix gexp) + #:use-module (guix packages) + #:use-module (guix records) + #:export (zfs-service-type + zfs-configuration + zfs-configuration?)) + +(define-record-type* + zfs-configuration make-zfs-configuration zfs-configuration? + ; kernel you want to compile the base-zfs module for. + (kernel zfs-configuration-kernel) + ; base package that will be compiled for the kernel + (base-zfs zfs-configuration-base-zfs (default zfs)) + ; list of string options. + (options zfs-configuration-options (default '()))) + +(define (make-zfs-package conf) + (let ((base-zfs (zfs-configuration-base-zfs conf)) + (kernel (zfs-configuration-kernel conf))) + (package + (inherit base-zfs) + (name (string-join (list (package-name base-zfs) + "for" + (package-name kernel) + (package-version kernel) + "version") + "-")) + (arguments (cons* #:linux kernel (package-arguments base-zfs)))))) + +(define (zfs-loadable-module conf) + (list (list (make-zfs-package conf) "module"))) + +(define (zfs-shepherd-services conf) + (let* ((zfs-package (make-zfs-package conf)) + (zpool (file-append zfs-package "/sbin/zpool"))) + (list + (shepherd-service + (documentation "Scans for ZFS pools and automounts filesystems.") + (provision '(zfs-scan-automount)) + (requirement '(root-file-system)) + (modules `((srfi srfi-1) + (srfi srfi-34) + (srfi srfi-35) + (rnrs io ports) + ,@%default-modules)) + (start #~(lambda _ + (and + ;; You'd think we could've used kernel-module-loader-service-type, + ;; but the kernel-module-loader shepherd service is dependent on + ;; file-systems, and file-systems is made dependent on this + ;; service. And we need the kernel module to be loaded before we + ;; scan for ZFS pools. So break the dependency loop by just + ;; loading ZFS module here by ourselves. + (or (file-exists? "/proc/sys/kernel/modprobe") + (begin + (format (current-error-port) "error loading 'zfs' module: ~a~%" + "Kernel is missing loadable module support.") + #f)) + (guard (c ((message-condition? c) + (format (current-error-port) + "error loading 'zfs' module: ~a~%" + (condition-message c)) + #f)) + (let ((modprobe (call-with-input-file "/proc/sys/kernel/modprobe" + get-line))) + (invoke/quiet modprobe "--" "zfs"))) + + ; scan for pools and automount contained datasets. + (guard (c ((message-condition? c) + (format (current-error-port) + "error importing zpools: ~a~%" + (condition-message?)) + #f)) + ;; (current-output-port) is typically connected to /dev/klog, + ;; so redirect it to (current-error-port) so that user can see + ;; prompts for passphrases on console + (with-output-to-port (current-error-port) + (lambda () + (invoke #$zpool "import" "-a" "-l"))))))) + (stop #~(const #t)))))) + +(define (zfs-profile-service conf) + (list (make-zfs-package conf))) + +(define (zfs-etc-service conf) + (let ((options (zfs-configuration-options conf))) + (if (null? options) + '() + `(("modprobe.d/zfs.conf" + ,(plain-file "zfs.conf" + (string-join (cons "options zfs" options) " "))))))) + +(define zfs-service-type + (service-type (name 'zfs) + (extensions + (list + ; install the kernel module + (service-extension kernel-loadable-module-service-type + zfs-loadable-module) + ; load ZFS module, scan ZFS pools, and automount filesystems + (service-extension shepherd-root-service-type + zfs-shepherd-services) + ; make sure automount occurs before file-systems target is reached + (service-extension file-systems-target-service-type + (const '(zfs-scan-automount))) + ; install ZFS management tools + (service-extension profile-service-type + zfs-profile-service) + ; install ZFS module options + (service-extension etc-service-type + zfs-etc-service))) + (description + "Install ZFS, an advanced filesystem and volume manager.")))