From mboxrd@z Thu Jan 1 00:00:00 1970 From: Danny Milosavljevic Subject: bug#25917: [PATCH] file-systems: Factorize file-system-packages. Date: Thu, 16 Mar 2017 18:40:29 +0100 Message-ID: <20170316174029.1663-1-dannym@scratchpost.org> References: <20170301173838.797d5dbc@scratchpost.org> Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:34285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1coZOb-0005Og-Ch for bug-guix@gnu.org; Thu, 16 Mar 2017 13:41:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1coZOY-0007hG-I1 for bug-guix@gnu.org; Thu, 16 Mar 2017 13:41:05 -0400 Received: from debbugs.gnu.org ([208.118.235.43]:60991) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1coZOY-0007fx-19 for bug-guix@gnu.org; Thu, 16 Mar 2017 13:41:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1coZOX-0005RM-Ok for bug-guix@gnu.org; Thu, 16 Mar 2017 13:41:01 -0400 In-Reply-To: <20170301173838.797d5dbc@scratchpost.org> Sender: "Debbugs-submit" Resent-Message-ID: List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+gcggb-bug-guix=m.gmane.org@gnu.org Sender: "bug-Guix" To: 25917@debbugs.gnu.org, ludo@gnu.org * gnu/system/linux-initrd.scm (base-initrd): Move helper-packages body to ... * gnu/system/file-systems.scm (file-system-packages): ... here. Also export it. * gnu/services/base.scm (file-system-shepherd-service): Set PATH by using file-system-packages. --- gnu/services/base.scm | 12 ++++++------ gnu/system/file-systems.scm | 26 ++++++++++++++++++++++++++ gnu/system/linux-initrd.scm | 18 +----------------- 3 files changed, 33 insertions(+), 23 deletions(-) diff --git a/gnu/services/base.scm b/gnu/services/base.scm index 5298a11f6..f3224aae1 100644 --- a/gnu/services/base.scm +++ b/gnu/services/base.scm @@ -274,7 +274,9 @@ FILE-SYSTEM." (options (file-system-options file-system)) (check? (file-system-check? file-system)) (create? (file-system-create-mount-point? file-system)) - (dependencies (file-system-dependencies file-system))) + (needed-for-boot? (file-system-needed-for-boot? file-system)) + (dependencies (file-system-dependencies file-system)) + (packages (file-system-packages (list file-system)))) (and (file-system-mount? file-system) (with-imported-modules '((gnu build file-systems) (guix build bournish)) @@ -292,11 +294,9 @@ FILE-SYSTEM." ;; Make sure fsck.ext2 & co. can be found. (dynamic-wind (lambda () - (setenv "PATH" - (string-append - #$e2fsprogs "/sbin:" - "/run/current-system/profile/sbin:" - $PATH))) + (set-path-environment-variable "PATH" + '("bin" "sbin") + '#$packages)) (lambda () (mount-file-system `(#$device #$title #$target #$type #$flags diff --git a/gnu/system/file-systems.scm b/gnu/system/file-systems.scm index 7011a279d..8107722c7 100644 --- a/gnu/system/file-systems.scm +++ b/gnu/system/file-systems.scm @@ -22,6 +22,8 @@ #:use-module (guix records) #:use-module ((gnu build file-systems) #:select (string->uuid uuid->string)) + #:use-module (gnu packages linux) + #:use-module (gnu packages disk) #:re-export (string->uuid uuid->string) #:export ( @@ -65,6 +67,8 @@ file-system-mapping->bind-mount + file-system-packages + %store-mapping %network-configuration-files %network-file-mappings)) @@ -411,4 +415,26 @@ a bind mount." (writable? (string=? file "/etc/resolv.conf")))) %network-configuration-files)) +(define (file-system-type-predicate type) + (lambda (fs) + (string=? (file-system-type fs) type))) + +(define* (file-system-packages file-systems #:key (volatile-root? #f)) + `(,@(if (find (lambda (fs) + (string-prefix? "ext" (file-system-type fs))) + file-systems) + (list e2fsck/static) + '()) + ,@(if (find (lambda (fs) + (string-suffix? "fat" (file-system-type fs))) + file-systems) + (list fatfsck/static) + '()) + ,@(if (find (file-system-type-predicate "btrfs") file-systems) + (list btrfs-progs/static) + '()) + ,@(if volatile-root? + (list unionfs-fuse/static) + '()))) + ;;; file-systems.scm ends here diff --git a/gnu/system/linux-initrd.scm b/gnu/system/linux-initrd.scm index 81c1278c0..1f1c30682 100644 --- a/gnu/system/linux-initrd.scm +++ b/gnu/system/linux-initrd.scm @@ -272,23 +272,7 @@ loaded at boot time in the order in which they appear." ,@extra-modules)) (define helper-packages - ;; Packages to be copied on the initrd. - `(,@(if (find (lambda (fs) - (string-prefix? "ext" (file-system-type fs))) - file-systems) - (list e2fsck/static) - '()) - ,@(if (find (lambda (fs) - (string-suffix? "fat" (file-system-type fs))) - file-systems) - (list fatfsck/static) - '()) - ,@(if (find (file-system-type-predicate "btrfs") file-systems) - (list btrfs-progs/static) - '()) - ,@(if volatile-root? - (list unionfs-fuse/static) - '()))) + (file-system-packages file-systems #:volatile-root? volatile-root?)) (raw-initrd file-systems #:linux linux