Git Product home page Git Product logo

Comments (19)

nmattia avatar nmattia commented on May 21, 2024 13

@klardotsh as mentioned above, I believe this only requires cargo nightly, not rustc nightly. Is this acceptable for you? If there's a big enough need for it I can try to figure out how to do this with cargo stable, please πŸ‘ if you're interested

from naersk.

jbaum98 avatar jbaum98 commented on May 21, 2024 8

Okay, I figured out a trick: you can override rust to use a version with the mozilla overlay, and leave cargo untouched. Alternatively, I imagine you can override cargo to use a nightly version of cargo in a similar fashion, I haven't tried that yet.

let rustOverlay = self: super:
  let rust = (super.rustChannelOf {
    channel = "1.44.0";
    sha256 = "cc2f6f7515b934457bc537ed181aa04e9a844fa8567f6dae7b9403d1a5a7a09e";
  }).rust; in { rustc = rust; };

from naersk.

tv42 avatar tv42 commented on May 21, 2024 3

It seems naersk stopped using unstable cargo option --out-dir in commit 08afb3d (setting CARGO_TARGET_DIR instead). There are still some remnants of it in docs and comments, but it seems naersk works with stable cargo now.

from naersk.

wezm avatar wezm commented on May 21, 2024 2

No sorry, I don't think that's right. Those options only work on nighly versions of cargo:

$ cargo --version
cargo 1.42.0 (86334295e 2020-01-31)

$ cargo -Z unstable-options build
error: the `-Z` flag is only accepted on the nightly channel of Cargo, but this is the `stable` channel
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.

$ cargo build --out-dir foo
error: the `--out-dir` flag is unstable, and only available on the nightly channel of Cargo, but this is the `stable` channel
See https://doc.rust-lang.org/book/appendix-07-nightly-rust.html for more information about Rust release channels.
See https://github.com/rust-lang/cargo/issues/6790 for more information about the `--out-dir` flag.

from naersk.

jonringer avatar jonringer commented on May 21, 2024 2

Yea, I can try.

Just a little busy in my personal life for the short term.

from naersk.

dpc avatar dpc commented on May 21, 2024 2

Please reopen, because the PR was reverted. We are not giving up yet. :D

from naersk.

paulyoung avatar paulyoung commented on May 21, 2024 1

I'm using flakes and haven't been able to figure out how to use a stable version of the rust toolchain from nixpkgs but use a compatible nightly build version of cargo yet.

I'll post here if I get something that works.

from naersk.

nmattia avatar nmattia commented on May 21, 2024 1

Ok, looks like there's a pretty big demand for this! @jonringer is it something you feel like tackling?

from naersk.

nmattia avatar nmattia commented on May 21, 2024

Hi! Unless you've tweaked the settings, rust stable is used. Those are cargo options, they won't impact the actual compiler. Does that help?

from naersk.

lblasc avatar lblasc commented on May 21, 2024

I hit the same problem when I tried to use stable rust from mozilla-overlay.

  pkgs = import sources.nixpkgs {
    overlays = [
      nixpkgs-mozilla
      (self: super:
          rec {
            rust = (self.rustChannelOf { date = "2020-05-07"; channel = "stable"; }).rust;
            rustc = rust;
            cargo = rust;
            rls = rust;
          }
      )
    ];
  };

from naersk.

ralsei avatar ralsei commented on May 21, 2024

Thirding this. Tried:

{ sources ? import ./nix/sources.nix
, pkgs ? import sources.nixpkgs {} }:
let
  rust = import ./nix/rust.nix { inherit sources; };

  naersk = pkgs.callPackage sources.naersk {
    rustc = rust;
    cargo = rust;
  };

  # tell nix-build to ignore the "target" directory
  src = builtins.filterSource
    (path: type: type != "directory" || builtins.baseNameOf path != "target")
    ./.;
in naersk.buildPackage {
  inherit src;
  cargoOptions = v: [];
  cargoBuildOptions = v: [ "$cargo_release" ''-j "$NIX_BUILD_CORES"''
                           "--message-format=$cargo_message_format"];
  cargoBuild = v: ''
    OUT_DIR=out cargo $cargo_options build $cargo_build_options >> $cargo_build_output_json
  '';
  remapPathPrefix = true; # remove nix store refs
}

(where ./nix/rust.nix is stable rust from nixpkgs-mozilla), and got this far:

    Finished release [optimized] target(s) in 47.03s
/nix/store/qghrkvk86f9llfkcr1bxsypqbw1a4qmw-stdenv-linux/setup: eval: line 1329: syntax error near unexpected token `||'
builder for '/nix/store/zrh0165cdhjg715xz3i2xi5r6s0l4fkm-lake-deps-0.2.0.drv' failed with exit code 2
cannot build derivation '/nix/store/8qa3543617i9jm159gp6s5ak9fr5983r-lake-0.2.0.drv': 1 dependencies couldn't be built
error: build of '/nix/store/8qa3543617i9jm159gp6s5ak9fr5983r-lake-0.2.0.drv' failed

There's got to be better ways to do this. As it currently stands, naersk is unusable with stable Cargo.

from naersk.

jbaum98 avatar jbaum98 commented on May 21, 2024

I also have this issue. I think that the --out-dir flag is unstable according to this, and according to the README that flag is important.

from naersk.

klardotsh avatar klardotsh commented on May 21, 2024

Is there any movement on this as far as mainlining some form of stable support? Taking a hard dependency on nightly is something I'd like to avoid in production. (I also can't seem to get @jbaum98's solution working in my project, which uses niv, but I'll keep playing with it)

from naersk.

veehaitch avatar veehaitch commented on May 21, 2024

If there's a big enough need for it I can try to figure out how to do this with cargo stable

I also ran into this when switching from nightly to stable. I would appreciate it if I could use the very same version of the rust toolchain during development and packaging, regardless of the rust channel.

from naersk.

evanjs avatar evanjs commented on May 21, 2024

If there's a big enough need for it I can try to figure out how to do this with cargo stable

I also ran into this when switching from nightly to stable. I would appreciate it if I could use the very same version of the rust toolchain during development and packaging, regardless of the rust channel.

I was also thinking about this.
I am now referencing oxalica via tarball url to ensure rustc is always the latest stable, but deferring cargo's version to naersk.

I am curious if relying on the latest stable rustc and a potentially older nightly for cargo might cause any issues.

from naersk.

dpc avatar dpc commented on May 21, 2024

Seems like a simple thing to fix so I gave it a try and now I have a PR. So far it works for me.

from naersk.

wezm avatar wezm commented on May 21, 2024

Oh wow, thanks @dpc. If the fix is this simple, I'm embarrassed I didn't come up with it in my efforts before opening the issue last year.

from naersk.

dpc avatar dpc commented on May 21, 2024

Maybe it isn't, and I just don't know about it yet. 🀷 :)

from naersk.

Patryk27 avatar Patryk27 commented on May 21, 2024

Seems like --out-dir is not used anymore, so I'm gonna go ahead and close this issue; if something's not working as intended, please feel free to re-open πŸ™‚

from naersk.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.