home-services: shells: Remove dependency on (radix utils) and (radix combinators), and make sure each plugin derivation is already computed prior to the service instantiation

main
Luis Guilherme Coelho 2024-09-01 13:47:26 -03:00
parent dda033a2d9
commit bfefb07673
No known key found for this signature in database
GPG Key ID: 1F2E76ACE3F531C8
1 changed files with 29 additions and 20 deletions

View File

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