Message ID | ef1d367f845630fa686f821d4123968b15ae8280.1698156363.git.efraim@flashner.co.il |
---|---|
State | New |
Headers | show |
Series | [bug#66728] gnu: rust-analyzer: Replace with version from rust. | expand |
Efraim Flashner <efraim@flashner.co.il> writes: > * gnu/packages/rust-apps.scm (rust-analyzer): Rewrite package to contain > the rust-analyzer from the rust package. > > Change-Id: I36a15e444fda76f044323f97ebce08f562063d4b > --- > > There is a version of rust-analyzer which comes with rust itself, now > installed in the "tools" output of rust. I would like to replace the > separate rust-analyzer package with the one built from the rust sources > and wanted your opinions since you're the ones who have contributed to > the package and are most likely to have to have used it. > > gnu/packages/rust-apps.scm | 184 ++++--------------------------------- > 1 file changed, 17 insertions(+), 167 deletions(-) > > diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm > index 3ecaa049ee..1a39006cd7 100644 > --- a/gnu/packages/rust-apps.scm > +++ b/gnu/packages/rust-apps.scm > @@ -44,6 +44,7 @@ > (define-module (gnu packages rust-apps) > #:use-module (guix build-system cargo) > #:use-module (guix build-system pyproject) > + #:use-module (guix build-system trivial) > #:use-module (guix deprecation) > #:use-module (guix download) > #:use-module (guix gexp) > @@ -1940,174 +1941,23 @@ (define-public rbw > (define-public rust-analyzer maybe can use deprecated-package > (package > (name "rust-analyzer") > - (version "2022-01-10") > - (source > - (origin > - ;; The crate at "crates.io" is empty. > - (method git-fetch) > - (uri (git-reference > - (url "https://github.com/rust-analyzer/rust-analyzer") > - (commit version))) > - (file-name (git-file-name name version)) > - (sha256 > - (base32 > - "1ci85bp8xwqrk8nqr8sh6yj8njgd98nhgnhaks2g00c77wwyra41")))) > - (build-system cargo-build-system) > + (version (package-version rust)) > + (source #f) > + (build-system trivial-build-system) > (arguments > - `(#:rust ,rust-1.64 > - #:install-source? #f ; virtual manifest > - #:cargo-test-flags > - '("--release" "--lib" "--tests" "--" > - "--skip=tests::test_version_check" ;it need rustc's version > - ;; FIXME: Guix's rust does not install source in > - ;; %out/lib/rustlib/src/rust so "can't load standard library from > - ;; sysroot" > - "--skip=tests::test_loading_rust_analyzer" > - ;; Failed to run rustfmt from toolchain 'stable'. Please run `rustup > - ;; component add rustfmt --toolchain stable` to install it > - "--skip=tests::sourcegen::sourcegen_assists_docs" ;need rustfmt > - "--skip=tests::sourcegen_ast::sourcegen_ast" ;same > - > - "--skip=tidy::check_licenses" ;it runs cargo metadata > - "--skip=tidy::check_merge_commits" ;it runs git rev-list > - "--skip=tidy::check_code_formatting" ;need rustfmt as cargo fmt > - > - ;; These tests require rust <= 1.60 and too many packages > - ;; has as dependency rust-serde-json-1 that use indexmap2 > - ;; and it need rust >= 1.64 > - "--skip=tests::list_test_macros" > - "--skip=tests::test_derive_empty" > - "--skip=tests::test_attr_macro" > - "--skip=tests::test_fn_like_macro" > - "--skip=tests::test_fn_like_macro2" > - "--skip=tests::test_derive_error") > - #:cargo-development-inputs > - (("rust-arbitrary" ,rust-arbitrary-1) > - ("rust-derive-arbitrary" ,rust-derive-arbitrary-1) > - ("rust-expect-test" ,rust-expect-test-1) > - ("rust-oorandom" ,rust-oorandom-11) > - ("rust-quote" ,rust-quote-1.0.10) > - ("rust-rayon" ,rust-rayon-1) > - ("rust-tracing" ,rust-tracing-0.1) > - ("rust-tracing-subscriber" ,rust-tracing-subscriber-0.3) > - ("rust-tracing-tree" ,rust-tracing-tree-0.2) > - ("rust-ungrammar" ,rust-ungrammar-1)) > - #:cargo-inputs > - (("rust-always-assert" ,rust-always-assert-0.1) > - ("rust-anyhow" ,rust-anyhow-1) > - ("rust-anymap" ,rust-anymap-0.12) > - ("rust-arrayvec" ,rust-arrayvec-0.7) > - ("rust-cargo-metadata" ,rust-cargo-metadata-0.14) > - ("rust-cfg-if" ,rust-cfg-if-1) > - ("rust-chalk-ir" ,rust-chalk-ir-0.75) > - ("rust-chalk-recursive" ,rust-chalk-recursive-0.75) > - ("rust-chalk-solve" ,rust-chalk-solve-0.75) > - ("rust-countme" ,rust-countme-3) > - ("rust-cov-mark" ,rust-cov-mark-2) > - ("rust-crossbeam-channel" ,rust-crossbeam-channel-0.5) > - ("rust-dissimilar" ,rust-dissimilar-1) > - ("rust-dot" ,rust-dot-0.1) > - ("rust-drop-bomb" ,rust-drop-bomb-0.1) > - ("rust-either" ,rust-either-1.6.0) > - ("rust-ena" ,rust-ena-0.14) > - ("rust-env-logger" ,rust-env-logger-0.8) > - ("rust-flate2" ,rust-flate2-1) > - ("rust-fst" ,rust-fst-0.4) > - ("rust-home" ,rust-home-0.5) > - ("rust-indexmap" ,rust-indexmap-1.7) > - ("rust-itertools" ,rust-itertools-0.10) > - ("rust-jod-thread" ,rust-jod-thread-0.1) > - ("rust-libc" ,rust-libc-0.2) > - ("rust-libloading" ,rust-libloading-0.7) > - ("rust-log" ,rust-log-0.4) > - ("rust-lsp-server" ,rust-lsp-server-0.5) > - ("rust-lsp-types" ,rust-lsp-types-0.91) > - ("rust-memmap2" ,rust-memmap2-0.5) > - ("rust-mimalloc" ,rust-mimalloc-0.1) > - ("rust-miow" ,rust-miow-0.4) > - ("rust-notify" ,rust-notify-5-pre.13) > - ("rust-object" ,rust-object-0.28) > - ("rust-once-cell" ,rust-once-cell-1) > - ("rust-parking-lot" ,rust-parking-lot-0.11) > - ("rust-perf-event" ,rust-perf-event-0.4) > - ("rust-proc-macro2" ,rust-proc-macro2-1.0.34) > - ("rust-pulldown-cmark" ,rust-pulldown-cmark-0.8) > - ("rust-pulldown-cmark-to-cmark" ,rust-pulldown-cmark-to-cmark-7) > - ("rust-rowan" ,rust-rowan-0.15) > - ("rust-rustc-ap-rustc-lexer" ,rust-rustc-ap-rustc-lexer-725) > - ("rust-rustc-hash" ,rust-rustc-hash-1) > - ("rust-salsa" ,rust-salsa-0.17) > - ("rust-scoped-tls" ,rust-scoped-tls-1) > - ("rust-serde" ,rust-serde-1) > - ("rust-serde-json" ,rust-serde-json-1.0.73) > - ("rust-serde-path-to-error" ,rust-serde-path-to-error-0.1) > - ("rust-typed-arena" ,rust-typed-arena-2) > - ("rust-smallvec" ,rust-smallvec-1) > - ("rust-smol-str" ,rust-smol-str-0.1) > - ("rust-snap" ,rust-snap-1) > - ("rust-text-size" ,rust-text-size-1) > - ("rust-threadpool" ,rust-threadpool-1) > - ("rust-tikv-jemalloc-ctl" ,rust-tikv-jemalloc-ctl-0.4) > - ("rust-tikv-jemallocator" ,rust-tikv-jemallocator-0.4) > - ("rust-url" ,rust-url-2) > - ("rust-walkdir" ,rust-walkdir-2) > - ("rust-winapi" ,rust-winapi-0.3) > - ("rust-write-json" ,rust-write-json-0.1) > - ("rust-xflags" ,rust-xflags-0.2) > - ("rust-xshell" ,rust-xshell-0.1)) > - #:phases > - (modify-phases %standard-phases > - (add-before 'check 'fix-tests > - (lambda _ > - (let ((bash (string-append "#!" (which "bash")))) > - (with-directory-excursion "crates/parser/test_data/lexer/ok" > - (substitute* "single_line_comments.txt" > - (("SHEBANG 19") > - (string-append "SHEBANG " > - (number->string (string-length bash)))) > - (("#!/usr/bin/env bash") bash)))))) > - (add-before 'install 'install-doc > - (lambda* (#:key outputs #:allow-other-keys) > - (let* ((out (assoc-ref outputs "out")) > - (doc (string-append out "/share/doc/rust-analyzer-" > - ,version))) > - (copy-recursively "docs" doc)))) > - (add-before 'install 'chdir > - (lambda _ > - (chdir "crates/rust-analyzer"))) > - (add-after 'install 'wrap-program > - (lambda* (#:key inputs outputs #:allow-other-keys) > - (let* ((out (assoc-ref outputs "out")) > - (bin (string-append out "/bin")) > - (rust-src-path (search-input-directory > - inputs "/lib/rustlib/src/rust/library"))) > - ;; if environment variable RUST_SRC_PATH is not set, set it, > - ;; make rust-analyzer work out of box. > - (with-directory-excursion bin > - (let* ((prog "rust-analyzer") > - (wrapped-file (string-append (dirname prog) > - "/." (basename prog) "-real")) > - (prog-tmp (string-append wrapped-file "-tmp"))) > - (link prog wrapped-file) > - (call-with-output-file prog-tmp > - (lambda (port) > - (format port "#!~a > -if test -z \"${RUST_SRC_PATH}\";then export RUST_SRC_PATH=~S;fi; > -exec -a \"$0\" \"~a\" \"$@\"" after use rust:tools's rust-analyzer, user cann't overwrite RUST_SRC_PATH to use their own version rust-src. maybe add a 'fallback for wrap-program and use it is better one. > - (which "bash") > - rust-src-path > - (canonicalize-path wrapped-file)))) > - (chmod prog-tmp #o755) > - (rename-file prog-tmp prog)))))) > - (replace 'install-license-files > - (lambda* (#:key outputs #:allow-other-keys) > - (let* ((out (assoc-ref outputs "out")) > - (doc (string-append out "/share/doc/rust-analyzer-" > - ,version))) > - (chdir "../..") > - (install-file "LICENSE-MIT" doc) > - (install-file "LICENSE-APACHE" doc))))))) > - (native-inputs (list rust-src-1.64)) please don't forget to delete rust-src-1.64. > + (list > + #:modules '((guix build utils)) > + #:builder > + #~(begin > + (use-modules (guix build utils)) > + (let ((rust (assoc-ref %build-inputs "rust")) > + (out (assoc-ref %outputs "out"))) > + (install-file (string-append rust "/bin/rust-analyzer") > + (string-append out "/bin")) > + (copy-recursively (string-append rust "/share") > + (string-append out "/share")))))) > + (inputs > + (list (list rust "tools"))) > (home-page "https://rust-analyzer.github.io/") > (synopsis "Experimental Rust compiler front-end for IDEs") > (description "Rust-analyzer is a modular compiler frontend for the Rust > > base-commit: a3946d5c1d6539546d0ad6502928bd58a8b0e8ea other LGTM.
Taken care of in the rust-team branch.
diff --git a/gnu/packages/rust-apps.scm b/gnu/packages/rust-apps.scm index 3ecaa049ee..1a39006cd7 100644 --- a/gnu/packages/rust-apps.scm +++ b/gnu/packages/rust-apps.scm @@ -44,6 +44,7 @@ (define-module (gnu packages rust-apps) #:use-module (guix build-system cargo) #:use-module (guix build-system pyproject) + #:use-module (guix build-system trivial) #:use-module (guix deprecation) #:use-module (guix download) #:use-module (guix gexp) @@ -1940,174 +1941,23 @@ (define-public rbw (define-public rust-analyzer (package (name "rust-analyzer") - (version "2022-01-10") - (source - (origin - ;; The crate at "crates.io" is empty. - (method git-fetch) - (uri (git-reference - (url "https://github.com/rust-analyzer/rust-analyzer") - (commit version))) - (file-name (git-file-name name version)) - (sha256 - (base32 - "1ci85bp8xwqrk8nqr8sh6yj8njgd98nhgnhaks2g00c77wwyra41")))) - (build-system cargo-build-system) + (version (package-version rust)) + (source #f) + (build-system trivial-build-system) (arguments - `(#:rust ,rust-1.64 - #:install-source? #f ; virtual manifest - #:cargo-test-flags - '("--release" "--lib" "--tests" "--" - "--skip=tests::test_version_check" ;it need rustc's version - ;; FIXME: Guix's rust does not install source in - ;; %out/lib/rustlib/src/rust so "can't load standard library from - ;; sysroot" - "--skip=tests::test_loading_rust_analyzer" - ;; Failed to run rustfmt from toolchain 'stable'. Please run `rustup - ;; component add rustfmt --toolchain stable` to install it - "--skip=tests::sourcegen::sourcegen_assists_docs" ;need rustfmt - "--skip=tests::sourcegen_ast::sourcegen_ast" ;same - - "--skip=tidy::check_licenses" ;it runs cargo metadata - "--skip=tidy::check_merge_commits" ;it runs git rev-list - "--skip=tidy::check_code_formatting" ;need rustfmt as cargo fmt - - ;; These tests require rust <= 1.60 and too many packages - ;; has as dependency rust-serde-json-1 that use indexmap2 - ;; and it need rust >= 1.64 - "--skip=tests::list_test_macros" - "--skip=tests::test_derive_empty" - "--skip=tests::test_attr_macro" - "--skip=tests::test_fn_like_macro" - "--skip=tests::test_fn_like_macro2" - "--skip=tests::test_derive_error") - #:cargo-development-inputs - (("rust-arbitrary" ,rust-arbitrary-1) - ("rust-derive-arbitrary" ,rust-derive-arbitrary-1) - ("rust-expect-test" ,rust-expect-test-1) - ("rust-oorandom" ,rust-oorandom-11) - ("rust-quote" ,rust-quote-1.0.10) - ("rust-rayon" ,rust-rayon-1) - ("rust-tracing" ,rust-tracing-0.1) - ("rust-tracing-subscriber" ,rust-tracing-subscriber-0.3) - ("rust-tracing-tree" ,rust-tracing-tree-0.2) - ("rust-ungrammar" ,rust-ungrammar-1)) - #:cargo-inputs - (("rust-always-assert" ,rust-always-assert-0.1) - ("rust-anyhow" ,rust-anyhow-1) - ("rust-anymap" ,rust-anymap-0.12) - ("rust-arrayvec" ,rust-arrayvec-0.7) - ("rust-cargo-metadata" ,rust-cargo-metadata-0.14) - ("rust-cfg-if" ,rust-cfg-if-1) - ("rust-chalk-ir" ,rust-chalk-ir-0.75) - ("rust-chalk-recursive" ,rust-chalk-recursive-0.75) - ("rust-chalk-solve" ,rust-chalk-solve-0.75) - ("rust-countme" ,rust-countme-3) - ("rust-cov-mark" ,rust-cov-mark-2) - ("rust-crossbeam-channel" ,rust-crossbeam-channel-0.5) - ("rust-dissimilar" ,rust-dissimilar-1) - ("rust-dot" ,rust-dot-0.1) - ("rust-drop-bomb" ,rust-drop-bomb-0.1) - ("rust-either" ,rust-either-1.6.0) - ("rust-ena" ,rust-ena-0.14) - ("rust-env-logger" ,rust-env-logger-0.8) - ("rust-flate2" ,rust-flate2-1) - ("rust-fst" ,rust-fst-0.4) - ("rust-home" ,rust-home-0.5) - ("rust-indexmap" ,rust-indexmap-1.7) - ("rust-itertools" ,rust-itertools-0.10) - ("rust-jod-thread" ,rust-jod-thread-0.1) - ("rust-libc" ,rust-libc-0.2) - ("rust-libloading" ,rust-libloading-0.7) - ("rust-log" ,rust-log-0.4) - ("rust-lsp-server" ,rust-lsp-server-0.5) - ("rust-lsp-types" ,rust-lsp-types-0.91) - ("rust-memmap2" ,rust-memmap2-0.5) - ("rust-mimalloc" ,rust-mimalloc-0.1) - ("rust-miow" ,rust-miow-0.4) - ("rust-notify" ,rust-notify-5-pre.13) - ("rust-object" ,rust-object-0.28) - ("rust-once-cell" ,rust-once-cell-1) - ("rust-parking-lot" ,rust-parking-lot-0.11) - ("rust-perf-event" ,rust-perf-event-0.4) - ("rust-proc-macro2" ,rust-proc-macro2-1.0.34) - ("rust-pulldown-cmark" ,rust-pulldown-cmark-0.8) - ("rust-pulldown-cmark-to-cmark" ,rust-pulldown-cmark-to-cmark-7) - ("rust-rowan" ,rust-rowan-0.15) - ("rust-rustc-ap-rustc-lexer" ,rust-rustc-ap-rustc-lexer-725) - ("rust-rustc-hash" ,rust-rustc-hash-1) - ("rust-salsa" ,rust-salsa-0.17) - ("rust-scoped-tls" ,rust-scoped-tls-1) - ("rust-serde" ,rust-serde-1) - ("rust-serde-json" ,rust-serde-json-1.0.73) - ("rust-serde-path-to-error" ,rust-serde-path-to-error-0.1) - ("rust-typed-arena" ,rust-typed-arena-2) - ("rust-smallvec" ,rust-smallvec-1) - ("rust-smol-str" ,rust-smol-str-0.1) - ("rust-snap" ,rust-snap-1) - ("rust-text-size" ,rust-text-size-1) - ("rust-threadpool" ,rust-threadpool-1) - ("rust-tikv-jemalloc-ctl" ,rust-tikv-jemalloc-ctl-0.4) - ("rust-tikv-jemallocator" ,rust-tikv-jemallocator-0.4) - ("rust-url" ,rust-url-2) - ("rust-walkdir" ,rust-walkdir-2) - ("rust-winapi" ,rust-winapi-0.3) - ("rust-write-json" ,rust-write-json-0.1) - ("rust-xflags" ,rust-xflags-0.2) - ("rust-xshell" ,rust-xshell-0.1)) - #:phases - (modify-phases %standard-phases - (add-before 'check 'fix-tests - (lambda _ - (let ((bash (string-append "#!" (which "bash")))) - (with-directory-excursion "crates/parser/test_data/lexer/ok" - (substitute* "single_line_comments.txt" - (("SHEBANG 19") - (string-append "SHEBANG " - (number->string (string-length bash)))) - (("#!/usr/bin/env bash") bash)))))) - (add-before 'install 'install-doc - (lambda* (#:key outputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out")) - (doc (string-append out "/share/doc/rust-analyzer-" - ,version))) - (copy-recursively "docs" doc)))) - (add-before 'install 'chdir - (lambda _ - (chdir "crates/rust-analyzer"))) - (add-after 'install 'wrap-program - (lambda* (#:key inputs outputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out")) - (bin (string-append out "/bin")) - (rust-src-path (search-input-directory - inputs "/lib/rustlib/src/rust/library"))) - ;; if environment variable RUST_SRC_PATH is not set, set it, - ;; make rust-analyzer work out of box. - (with-directory-excursion bin - (let* ((prog "rust-analyzer") - (wrapped-file (string-append (dirname prog) - "/." (basename prog) "-real")) - (prog-tmp (string-append wrapped-file "-tmp"))) - (link prog wrapped-file) - (call-with-output-file prog-tmp - (lambda (port) - (format port "#!~a -if test -z \"${RUST_SRC_PATH}\";then export RUST_SRC_PATH=~S;fi; -exec -a \"$0\" \"~a\" \"$@\"" - (which "bash") - rust-src-path - (canonicalize-path wrapped-file)))) - (chmod prog-tmp #o755) - (rename-file prog-tmp prog)))))) - (replace 'install-license-files - (lambda* (#:key outputs #:allow-other-keys) - (let* ((out (assoc-ref outputs "out")) - (doc (string-append out "/share/doc/rust-analyzer-" - ,version))) - (chdir "../..") - (install-file "LICENSE-MIT" doc) - (install-file "LICENSE-APACHE" doc))))))) - (native-inputs (list rust-src-1.64)) + (list + #:modules '((guix build utils)) + #:builder + #~(begin + (use-modules (guix build utils)) + (let ((rust (assoc-ref %build-inputs "rust")) + (out (assoc-ref %outputs "out"))) + (install-file (string-append rust "/bin/rust-analyzer") + (string-append out "/bin")) + (copy-recursively (string-append rust "/share") + (string-append out "/share")))))) + (inputs + (list (list rust "tools"))) (home-page "https://rust-analyzer.github.io/") (synopsis "Experimental Rust compiler front-end for IDEs") (description "Rust-analyzer is a modular compiler frontend for the Rust