packages: Allow file names as package sources.
* guix/packages.scm (package-source-derivation): Add cases for SOURCE as a store path or user file. * tests/packages.scm ("package-source-derivation, file", "package-source-derivation, store path"): New tests.
This commit is contained in:
parent
b095792f9b
commit
7357138bba
@ -250,7 +250,11 @@ (define* (package-source-derivation store source
|
||||
(match source
|
||||
(($ <origin> uri method sha256 name)
|
||||
(method store uri 'sha256 sha256 name
|
||||
#:system system))))
|
||||
#:system system))
|
||||
((and (? string?) (? store-path?) file)
|
||||
file)
|
||||
((? string? file)
|
||||
(add-to-store store (basename file) #t "sha256" file))))
|
||||
|
||||
(define (transitive-inputs inputs)
|
||||
(let loop ((inputs inputs)
|
||||
|
@ -99,7 +99,27 @@ (define read-at
|
||||
("d" ,d) ("d/x" "something.drv"))
|
||||
(pk 'x (package-transitive-inputs e))))))
|
||||
|
||||
(test-skip (if (not %store) 6 0))
|
||||
(test-skip (if (not %store) 8 0))
|
||||
|
||||
(test-assert "package-source-derivation, file"
|
||||
(let* ((file (search-path %load-path "guix.scm"))
|
||||
(package (package (inherit (dummy-package "p"))
|
||||
(source file)))
|
||||
(source (package-source-derivation %store
|
||||
(package-source package))))
|
||||
(and (store-path? source)
|
||||
(valid-path? %store source)
|
||||
(equal? (call-with-input-file source get-bytevector-all)
|
||||
(call-with-input-file file get-bytevector-all)))))
|
||||
|
||||
(test-assert "package-source-derivation, store path"
|
||||
(let* ((file (add-to-store %store "guix.scm" #t "sha256"
|
||||
(search-path %load-path "guix.scm")))
|
||||
(package (package (inherit (dummy-package "p"))
|
||||
(source file)))
|
||||
(source (package-source-derivation %store
|
||||
(package-source package))))
|
||||
(string=? file source)))
|
||||
|
||||
(test-assert "return values"
|
||||
(let-values (((drv-path drv)
|
||||
|
Loading…
Reference in New Issue
Block a user