rust: add-layer after launch-rust-analyzer
This commit is contained in:
parent
cbf478cc4f
commit
93f6c9989b
1 changed files with 30 additions and 7 deletions
37
env/rust.scm
vendored
37
env/rust.scm
vendored
|
@ -28,6 +28,8 @@
|
|||
init-rustup-environment
|
||||
launch-rust-analyzer))
|
||||
|
||||
(define directory-files (@@ (ice-9 ftw) directory-files))
|
||||
|
||||
(define rustup-origin
|
||||
(let ((name "rustup")
|
||||
(commit "737ad82333742dfd350a733c1649ce4e36109773")
|
||||
|
@ -154,9 +156,15 @@ function."
|
|||
(define* (launch-rustup-environment #:optional home)
|
||||
(exec-in-rustup-environment '("/bin/sh") #:home home))
|
||||
|
||||
(define* (launch-rust-analyzer env target-name
|
||||
(define* (launch-rust-analyzer env target-sym
|
||||
#:key
|
||||
(tag 'current) (share '()) (expose '()))
|
||||
(onto (if (member target-sym
|
||||
(environment-tags env))
|
||||
target-sym
|
||||
'current))
|
||||
(share '())
|
||||
(expose '()))
|
||||
(define controlled-files '(".cargo" ".rustup" ".profile"))
|
||||
(define (remap w)
|
||||
(let ((home (getenv "HOME")))
|
||||
(λ (m)
|
||||
|
@ -170,13 +178,11 @@ function."
|
|||
(loop (list s s)))
|
||||
(throw 'file-doesnt-exist))))))))
|
||||
|
||||
(let* ((target (string-append (@@ (env) %env-directory) "/" target-name))
|
||||
(let* ((target (string-append (@@ (env) %env-directory)
|
||||
"/" (symbol->string target-sym)))
|
||||
;; TODO should actually detect if overlay is mounted not that the
|
||||
;; directory exists.
|
||||
(mnt (if (file-exists? target)
|
||||
target
|
||||
(overlay-mount-merged
|
||||
(mount-environment env #:tag tag #:target target))))
|
||||
(mnt (mount-environment env #:tag onto #:target target))
|
||||
(mappings (append (map (remap #f) expose)
|
||||
(map (remap #t) share))))
|
||||
(exec-in-rustup-environment '("./.cargo/bin/rust-analyzer")
|
||||
|
@ -184,6 +190,23 @@ function."
|
|||
#:mappings mappings)
|
||||
(sync)
|
||||
(system* "umount" target)
|
||||
(with-directory-excursion (overlay-mount-upper mnt)
|
||||
(for-each (λ (f)
|
||||
(unless (member f controlled-files)
|
||||
(format (current-output-port)
|
||||
"Deleting uncontrolled-file: ~a\n"
|
||||
f)
|
||||
(delete-file-recursively f)))
|
||||
(directory-files ".")))
|
||||
(if (nil? (directory-files (overlay-mount-upper mnt)))
|
||||
(display "No files to add\n")
|
||||
(begin
|
||||
(display "Adding layer\n")
|
||||
(apply add-layer
|
||||
(list env
|
||||
(overlay-mount-upper mnt)
|
||||
onto
|
||||
target-sym))))
|
||||
(for-each delete-file-recursively
|
||||
(list target
|
||||
(overlay-mount-upper mnt)
|
||||
|
|
Loading…
Reference in a new issue