Skip to content

buildRustCrate should support nix-shell features #37945

Open

Description

@vitiral

Issue description

The following features are currently absent from buildRustCrate which would be excellent for nix-shell:

  • Shell-only dependencies, i.e.being able to use cargo from within the shell without adding build dependencies
  • Setting of environment variables
  • Setting build phases, especially running tests

This issue was brought up in this thread

Activity

  1. vitiral commented on Mar 27, 2018

    @vitiral
    ContributorAuthor

    Quote from @P-E-Meunier

    Ok, I didn't remember this was an issue, so PLEASE add it to the current documentation: a derivation has phases, documented in https://nixos.org/nixpkgs/manual/#sec-stdenv-phases.

    Nix-build sets up the environment by downloading all the buildInputs/propagatedBuildInputs, and then runs all the phases, while nix-shell only sets up the environment.

  2. Mic92 commented on Apr 6, 2018

    @Mic92
    Member

    I am not sure how cargo can pick up downloaded crates from environment variables. In buildRustCrate a .cargo/config file is used.

  3. lilyball commented on May 19, 2019

    @lilyball
    Member

    Cargo unifies config by walking up the file tree looking for .cargo/config and ends with $CARGO_HOME/config (where $CARGO_HOME defaults to $HOME/.cargo). The shell environment could specify CARGO_HOME as pointing at a temporary directory that specifies the desired config. The only practical difference here is that a local .cargo/config in a parent directory could potentially override the values specified in the Nix-provided config (though not one in the current directory, as if the current directory already specifies the keys that Nix is adding, then the Nix build would fail as well due to duplicate keys as it appends its configuration onto any existing .cargo/config file).

  4. haslersn commented on Aug 14, 2019

    @haslersn
    Contributor

    Currently it seems like nix-shell works with buildRustPackage. Can somebody confirm? Does that solve this issue?

  5. stale commented on Jun 2, 2020

    @stale

    Thank you for your contributions.

    This has been automatically marked as stale because it has had no activity for 180 days.

    If this is still important to you, we ask that you leave a comment below. Your comment can be as simple as "still important to me". This lets people see that at least one person still cares about this. Someone will have to do this at most twice a year if there is no other activity.

    Here are suggestions that might help resolve this more quickly:

    1. Search for maintainers and people that previously touched the related code and @ mention them in a comment.
    2. Ask on the NixOS Discourse.
    3. Ask on the #nixos channel on irc.freenode.net.
  6. added
    2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
    on Jun 2, 2020
  7. Mic92 commented on Jun 2, 2020

    @Mic92
    Member

    Would this be interesting for crate2nix? https://github.com/kolloch/crate2nix cc @kolloch

  8. removed
    2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
    on Jun 2, 2020
  9. kolloch commented on Jun 2, 2020

    @kolloch
    Contributor

    The main question is where the right place for this functionality is. Making progress in nixpkgs is more challenging. @andir is working on shell support in crate2nix: nix-community/crate2nix#135

  10. stale commented on Nov 29, 2020

    @stale

    I marked this as stale due to inactivity. → More info

  11. added
    2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
    on Nov 29, 2020
  12. Mic92 commented on Nov 29, 2020

    @Mic92
    Member

    I think this is still relevant.

  13. removed
    2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
    on Nov 29, 2020
  14. stale commented on Jun 3, 2021

    @stale

    I marked this as stale due to inactivity. → More info

  15. added
    2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md
    on Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions