Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-analyzer: 2020-08-24 -> 2020-09-14 and some clean-up #97444

Merged
merged 2 commits into from Sep 21, 2020

Conversation

oxalica
Copy link
Contributor

@oxalica oxalica commented Sep 8, 2020

Motivation for this change

Bump version and do some clean-up.

  • unstable-2020-09-07 requires rustc 1.46.0 to compile but we still have 1.45.2 in master. Patches are introduced for a temporary fix.
  • Feature jemalloc is removed now, and a new features mimalloc is introduced.
  • Remove fake rustup in check phase, since we currently test only sub-crate rust-analyzer, which doesn't need it anymore.
  • Install check works now. Enable it by default.
Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.

r? @danieldk

@danieldk
Copy link
Contributor

danieldk commented Sep 8, 2020

This update touches node packages, since I literally know nothing about node, I'll leave up the reviewing to someone else.

@@ -17,26 +18,21 @@ rustPlatform.buildRustPackage {

buildAndTestSubdir = "crates/rust-analyzer";

cargoBuildFlags = lib.optional useJemalloc "--features=jemalloc";
cargoBuildFlags = lib.optional useMimalloc "--features=mimalloc";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Upstream PR in rust-lang/rust-analyzer#5354


nativeBuildInputs = lib.optionals doCheck [ rustPlatform.rustcSrc ];
nativeBuildInputs = lib.optional useMimalloc cmake;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: Needed for mimalloc_rust to build its bundled version of the mimalloc library. https://github.com/purpleprotocol/mimalloc_rust#requirements

# Version specific args
, rev, version, sha256, cargoSha256 }:
{ rev, version, sha256, cargoSha256, ... }@args:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to split the arguments? Looking at the output of rg -B3 '@args', it doesn't look like a common pattern in nixpkgs.

Comment on lines 10 to 14
patches = [
# FIXME: Temporary fix for our rust 1.45.0 since rust-analyzer requires 1.46.0
./no-loop-in-const-fn.patch
./no-option-zip.patch
];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this would better belong in generic.nix, along with other build instructions.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 But it's temporary.

Well, I'm not quite sure what should be put in generic file. You mean all about "how to build", yeah?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd expect most patches are supposed to be temporary workarounds, so it wouldn't be a problem as long as there's a comment explaining why they're necessary. If you want to make absolutely sure that you remove the patch when it's no longer needed, I guess you could do something like this:

  patches = with lib;
    if !versionAtLeast (getVersion rustPlatform.rust.rustc) "1.46.0" then [
      # FIXME: Temporary fix for our rust 1.45.0 since rust-analyzer requires 1.46.0
      ./no-loop-in-const-fn.patch
      ./no-option-zip.patch
    ] else warn "Some patches for ${pname} needs to be removed." [];

(edited, it was missing a !)

This would exclude the patches from the build and warn you about it once rustc reaches 1.46.0.

You mean all about "how to build", yeah?

Yes.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to make absolutely sure that you remove the patch when it's no longer needed, I guess you could do something like this

These patches just do the same thing in a more compatible way and don't change any semantics. I think it's not quite necessary to do that check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense.

@ofborg ofborg bot requested a review from midchildan September 15, 2020 11:42
@oxalica oxalica changed the title rust-analyzer: 2020-08-24 -> 2020-09-07 and some clean-up rust-analyzer: 2020-08-24 -> 2020-09-14 and some clean-up Sep 15, 2020
Comment on lines 1 to 7
# Version specific args
, rev, version, sha256, cargoSha256 }:
{ rev, version, sha256, cargoSha256 }:

{ lib, stdenv, fetchFromGitHub, rustPlatform, darwin, cmake
, useMimalloc ? false
, doCheck ? true
}:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you also make this a simple function instead of a nested one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary? Some are just extracted version related parameters, while others are passed through callPackages which can be overrided. It's not expected to directly configure rev, version and hashes like other packages in nixpkgs.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's only a matter of style but I found the original version easier to read than the nested version, although they basically do the same thing.

original:

rust-analyzer-unwrapped = callPackage ./generic.nix rec {
  rev = ...;
  ...
};

nested:

rust-analyzer-unwrapped = callPackage (import ./generic.nix rec {
  rev = ...;
  ...
}) {};

Copy link
Member

@midchildan midchildan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. The remaining point is a minor style issue, so I don't see much point holding this up.

@midchildan
Copy link
Member

@oxalica This still needs to go through committer review, but you might want to squash the commits in the meantime.

@oxalica
Copy link
Contributor Author

oxalica commented Sep 16, 2020

The global node-packages (pkgs/development/node-packages/node-packages.nix) is updated too frequently.
I'm thinking about using a standalone generated node-packages.nix for the package.

What's the best practice about these npm packages as only build-dependency?

@jonringer

@oxalica
Copy link
Contributor Author

oxalica commented Sep 17, 2020

I refactored the node packages part to use generated standalone node-packages.nix to avoid touching global nodePackages.

@midchildan Have a look? What do you think about it?

@ofborg ofborg bot requested a review from midchildan September 17, 2020 20:04
@midchildan
Copy link
Member

midchildan commented Sep 18, 2020

Using node2nix outside of nodePackages is generally frowned upon [1,2] even if it's only used as a build dependency [3,4]. The guideline for node.js packaging [5], however, states that "the package set should only provide end user software package," and this has been pointed out in another issue [6], but I think it's best to stick with the currently accepted practice for now because no decision has been reached yet.

@oxalica
Copy link
Contributor Author

oxalica commented Sep 18, 2020

@midchildan I'm just tired of generating and generating again over ALL NPM packages used by nixpkgs every time having merge conflict (it's updated quite often). We have package-lock.json but node2nix ignores them and fetches all packages every time, which takes about an hour for me and (accidentally) cause ~100 package rebuild (which may be not needed or even lead to build failure)

(Also node2nix is poor designed and the fetching is synchronous. It takes years in a proxy environment with high latency but large bandwidth.)

Note that just when I typing this comment, there's another update on pkgs/development/node-packages/node-packages.nix.
MERGE CONFLICT AGAIN 😞

@midchildan
Copy link
Member

The current situation isn't ideal, but I believe this discussion would be best done in a separate issue because this affects how node packaging should be done in general, and isn't limited to this package. #82662 seems like a good place to start.

For now, I'd recommend ignoring merge conflicts until you receive committer approval. You can perform a rebase afterwards.

@ofborg ofborg bot requested a review from midchildan September 21, 2020 13:27
Copy link
Contributor

@jonringer jonringer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

failures are broken on target branch

https://github.com/NixOS/nixpkgs/pull/97444
2 packages failed to build:
dat vimPlugins.coc-imselect

17 packages built:
bitwarden-cli castnow epgstation joplin lumo mirakurun netlify-cli redoc-cli rust-analyzer rust-analyzer-unwrapped thelounge vimPlugins.coc-eslint vimPlugins.coc-git vimPlugins.coc-metals vimPlugins.coc-prettier vimPlugins.coc-stylelint vimPlugins.coc-vetu

@jonringer jonringer merged commit 21a6f3a into NixOS:master Sep 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants