-
-
Notifications
You must be signed in to change notification settings - Fork 14k
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] How to package crate without Cargo.lock #29981
Comments
@wizeman @Mic92 @the-kenny Pinging you as some of the top-contributors to the rust compiler infrastructure in nixpkgs and due to no response in 7 days. |
I'm a bit stale on our current rust infrastructure. I'll try to have a look into it when I find some time. |
I'm not sure how you could package without a Maybe you could try to provide a Cargo.lock file as part of your nix derivation if upstream doesn't provide one. |
That's exactly what I tried, but if you studied my initial comment here you'll see that it does not work. |
See for an example c3d5fd5 you probably want On the long run we should fix the patch phase instead. |
I tried the cargoUpdatesHook as well and it didn't work. See my initial message. |
How about passing a patched |
How would I do that? This is what I have so far: {
mkImagPackage = { pkgs, pname, version, cratePath, sha256, cargoLock }:
pkgs.rustPlatform.buildRustPackage rec {
inherit pname version;
name = "${pname}-v${version}";
sourceRoot = "imag-src/${cratePath}";
src = pkgs.stdenv.mkDerivation {
name = "${pname}-src";
src = pkgs.fetchFromGitHub {
inherit sha256;
owner = "matthiasbeyer";
repo = "imag";
rev = "v${version}";
};
phases = [ "unpackPhase" "buildPhase" ];
buildPhase = ''
cat ${cargoLock} > Cargo.lock
mkdir $out -p
cp ./* -rv $out
'';
};
depsSha256 = "2pbb0swgpsbd6x3avxz6fv3q31dg801li47jibz721a4n9c0rssx";
buildInputs = with pkgs;
[ cmake curl gcc libpsl openssl pkgconfig which zlib ];
meta = with pkgs.stdenv.lib; {
description = "imag";
homepage = https://imag-pim.org;
license = with licenses; [ lgpl2 ];
maintainers = with maintainers; [ matthiasbeyer ];
platforms = platforms.linux;
};
};
imag = { pkgs }: mkImagPackage {
inherit pkgs;
pname = "imag";
version = "0.4.0";
sha256 = "0vsfhark6l8g7vp4bd1dm24icy7a9kv40x8g7smh4lwf6m860m23";
cratePath = "bin/core/imag";
cargoLock = ./imag-cargolock-0.4.0;
};
} and it fails with
... the line that irritates me is |
@matthiasbeyer can you provide also the |
Pasted in pastebin because of size: https://pastebin.com/VhzvkPVS |
The
Now there is project-specific, different error. |
I wonder why that is (the wrong path). The project is a multi-crate project and the cargo.lock file should live at the top-level of the project. I will investigate! |
This was not necessarily project specific: There exists a crate as a dotfile: I now have
but it fails with
|
you set |
But cargo should search for the |
You build a subdirectory here, which has its own |
Yes, but this is a multi-crate project, it has a |
So this is a wrong assumption by |
Well, that explains a lot. I guess I have to dig deeper then. |
Hm, @Mic92 can you point me? From what I see the rust package helper simply calls |
We would need to add an exception here, to not check for |
Hm,... I would not do this,... I would rather check whether a |
a while loop, which looks for |
I'd like to update svgcleaner but upstream stopped shipping |
@vincentbernat I think RazrFalcon/svgcleaner#157 is the best way to deal with this. |
(triage) @Mic92 @matthiasbeyer are there any action items left to close the issue? |
this was solved. |
I just want to chime in here, Cargo.lock in rust projects is NOT always necessary nor recommended. Core rust devs even mention this. See rust-lang/cargo#315 - conventional wisdom is not to include a cargo.lock for libraries. |
Yes. We mostly build applications with very few exceptions. There are now mechanism to add missing
|
@Mic92 posted the answer that worked for me. For discoverability it would be great if this was suggested when the package doesn't have a Cargo.lock instead of leaving the user stranded looking for an answer. |
Added here: #89523 |
Issue description
I want to (locally) package a crate which does not (yet) have a
Cargo.lock
file. I asked how to do this before on the Mailinglist but I got no answer which helped me enough to get it packaged.An example how I want to package it in my local configuration is in the initial email in this thread. There I try to package
imag
0.3.0, 0.4.0 was released just a few days ago, so if you want to try yourself when helping me, chose either.As far as I can tell, the
cargoDepsHook
does not get evaluated from my package definition and thecargoUpdateHook
runs after the check whether aCargo.lock
exists, so I cannot use it.The documentation on this subject is rather sparse... so I guess if I can get it packaged I may update the documentation on the rust packaging a bit 😄
The text was updated successfully, but these errors were encountered: