services: nix-search-paths: Group system and home extensions.

This commit is contained in:
Hilton Chain committed 2026-07-06 21:12:35 +08:00
1 parent 6cf57b252d
commit 4d553b92ce
1 file changed
+29 -35
+29 -35
View File
@@ -22,39 +22,33 @@
(use-modules (guix build utils)) (use-modules (guix build utils))
(mkdir-p (dirname #$config))))) (mkdir-p (dirname #$config)))))
(define (nix-search-paths-shepherd-root-extension config) (define* (nix-search-paths-shepherd-extension #:key home?)
(list (shepherd-service (lambda (config)
(documentation (list (shepherd-service
"Build Nix profile and symlink it to the specified path.") (documentation
(requirement '(user-processes nix-daemon networking)) "Build Nix profile and symlink it to the specified path.")
(provision '(build-nix-profile)) (requirement
(one-shot? #t) (if home?
(start '()
#~(make-forkexec-constructor '(user-processes nix-daemon networking)))
(list "/run/current-system/profile/bin/build-nix-profile" (provision '(build-nix-profile))
#$config)))))) (one-shot? #t)
(start
(define (nix-search-paths-home-shepherd-extension config) #~(make-forkexec-constructor
(list (shepherd-service (list #$(if home?
(documentation "build-nix-profile"
"Build Nix profile and symlink it to the specified path.") "/run/current-system/profile/bin/build-nix-profile")
(requirement '()) #$config)))))))
(provision '(build-nix-profile))
(one-shot? #t)
(start
#~(make-forkexec-constructor
(list "build-nix-profile" #$config))))))
;; TODO: Avoid duplicating search paths from the system profile. ;; TODO: Avoid duplicating search paths from the system profile.
(define (nix-search-paths-etc-profile-d-extension config) (define* (nix-search-paths-profile-extension #:key home?)
(list (mixed-text-file "nix-search-paths.sh" "\ (lambda (config)
eval \"$(" guix "/bin/guix package --search-paths=suffix \ (list (mixed-text-file "nix-search-paths.sh" "\
-p /run/current-system/profile -p" config ")\""))) eval \"$(" guix "/bin/guix package --search-paths=suffix"
" -p " (if home?
(define (nix-search-paths-home-shell-profile-extension config) "~/.guix-home/profile"
(list (mixed-text-file "nix-search-paths.sh" "\ "/run/current-system/profile")
eval \"$(" guix "/bin/guix package --search-paths=suffix \ " -p " config ")\""))))
-p ~/.guix-home/profile -p" config ")\"")))
(define nix-search-paths-service-type (define nix-search-paths-service-type
(service-type (service-type
@@ -63,9 +57,9 @@ eval \"$(" guix "/bin/guix package --search-paths=suffix \
(list (service-extension activation-service-type (list (service-extension activation-service-type
nix-search-paths-activation) nix-search-paths-activation)
(service-extension shepherd-root-service-type (service-extension shepherd-root-service-type
nix-search-paths-shepherd-root-extension) (nix-search-paths-shepherd-extension))
(service-extension etc-profile-d-service-type (service-extension etc-profile-d-service-type
nix-search-paths-etc-profile-d-extension))) (nix-search-paths-profile-extension))))
(default-value "/nix/var/nix/profiles/guix-system-nix-profile") (default-value "/nix/var/nix/profiles/guix-system-nix-profile")
(description "Set up search paths for @code{with-nix-profile}."))) (description "Set up search paths for @code{with-nix-profile}.")))
@@ -77,9 +71,9 @@ eval \"$(" guix "/bin/guix package --search-paths=suffix \
(list (service-extension home-activation-service-type (list (service-extension home-activation-service-type
nix-search-paths-activation) nix-search-paths-activation)
(service-extension home-shepherd-service-type (service-extension home-shepherd-service-type
nix-search-paths-home-shepherd-extension) (nix-search-paths-shepherd-extension #:home? #t))
(service-extension home-shell-profile-service-type (service-extension home-shell-profile-service-type
nix-search-paths-home-shell-profile-extension))) (nix-search-paths-profile-extension #:home? #t))))
(default-value "/var/tmp/guix-home-nix-profile"))) (default-value "/var/tmp/guix-home-nix-profile")))
(define-service-type-mapping (define-service-type-mapping