diff --git a/radix/home/services/shells.scm b/radix/home/services/shells.scm index 9936d6e..ab3e892 100644 --- a/radix/home/services/shells.scm +++ b/radix/home/services/shells.scm @@ -4,6 +4,7 @@ #:use-module (gnu home services) #:use-module (gnu packages shells) #:use-module (guix gexp) + #:use-module (guix monads) #:use-module (guix store) #:use-module (guix derivations) #:use-module (guix packages) @@ -12,8 +13,6 @@ #:use-module (srfi srfi-9) #:use-module (srfi srfi-26) #:use-module (ice-9 match) - #:use-module (radix utils) - #:use-module (radix combinators) #:use-module (radix packages fish-xyz) #:export (home-fish-service-type @@ -197,26 +196,36 @@ end\n\n") home-fish-extension-plugins extension-configs))))) (define (fish-plugin-files-service config) - (define (plugin-files plugin) - (define (directory-files dir) - (map (lambda (file) - (let ((almost-basename (almost-basename file))) - (list (string-append "fish/" almost-basename) - (file-append plugin - (string-append "/share/fish/" - almost-basename))))) - (list-contents dir))) + (define (list-contents dir) + (and=> (scandir dir) + (lambda (subdirs) + (map (cut string-append dir "/" <>) + (cddr subdirs))))) - (let* ((drv (run-with-store (open-connection) - (with-store %store - (package->derivation plugin)))) - (path (string-append (derivation->output-path drv) "/share/fish/"))) - (append-map directory-files - (filter (negate (cut string-suffix? "doc" <>)) - (list-contents path))))) + (define (plugin-subdir-files plugin drv-subdir) + (map (lambda (file) + (let ((name (string-append (basename (dirname file)) + "/" (basename file)))) + (list (string-append "fish/" name) + (file-append plugin (string-append "/share/fish/" name))))) + (list-contents drv-subdir))) - (append-map plugin-files - (home-fish-configuration-plugins config))) + (define plugins (home-fish-configuration-plugins config)) + (define derivations + (run-with-store (open-connection) + (mlet* %store-monad + ((drvs (mapm %store-monad + package->derivation + plugins)) + (_ (built-derivations drvs))) + (return drvs)))) + (append-map + (lambda (plugin drv) + (let ((out (derivation->output-path drv))) + (append-map (cut plugin-subdir-files plugin <>) + (list-contents (string-append out "/share/fish"))))) + plugins + derivations)) ;; TODO: Support for generating completion files (define home-fish-service-type