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)
(lambda (subdirs)
(map (cut string-append dir "/" <>)
(cddr subdirs)))))
(define (plugin-subdir-files plugin drv-subdir)
(map (lambda (file) (map (lambda (file)
(let ((almost-basename (almost-basename file))) (let ((name (string-append (basename (dirname file))
(list (string-append "fish/" almost-basename) "/" (basename file))))
(file-append plugin (list (string-append "fish/" name)
(string-append "/share/fish/" (file-append plugin (string-append "/share/fish/" name)))))
almost-basename))))) (list-contents drv-subdir)))
(list-contents dir)))
(let* ((drv (run-with-store (open-connection) (define plugins (home-fish-configuration-plugins config))
(with-store %store (define derivations
(package->derivation plugin)))) (run-with-store (open-connection)
(path (string-append (derivation->output-path drv) "/share/fish/"))) (mlet* %store-monad
(append-map directory-files ((drvs (mapm %store-monad
(filter (negate (cut string-suffix? "doc" <>)) package->derivation
(list-contents path))))) plugins))
(_ (built-derivations drvs)))
(append-map plugin-files (return drvs))))
(home-fish-configuration-plugins config))) (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