-
Notifications
You must be signed in to change notification settings - Fork 92
Replies: 1 comment · 4 replies
-
There are a few approaches you can take to generate a valid If you don't care about purity/reproducibility at all you could disable the Nix sandbox and let cargo access the network and generate its own lock file, but I'll assume this is an obvious non-starter as you likely wouldn't be using Nix at that point ;) If you know the exact dependency closure of the project and the exact repos/commits to be used you could generate the The most "interesting" solution I can think of is tracking the actual crates.io index, which is a git repository. Cargo's lock file generation should be reproducible for the same It's worth noting that the index is large and periodically it's history is truncated (to keep checkouts fast) so this may or may not pose some friction... |
Beta Was this translation helpful? Give feedback.
All reactions
-
Since I only ever want to have 'in the moment' builds, this seems like a straightforward solution! { craneLib, pkgs }:
let
cratesIoRegistry = fetchGit {
url = "https://github.com/rust-lang/crates.io-index.git";
ref = "master";
rev = "e9936adc4a5f03f929c3d19a8d3bcc73479ccc9a";
};
localCrateRegistry = pkgs.linkFarm "local-crate-registry" [
{ name = "index"; path = cratesIoRegistry; }
];
config = {
source = {
crates-io = { replace-with = "local-crates"; };
local-crates = {
local-registry = localCrateRegistry;
};
};
};
in
craneLib.writeTOML "config.toml" config This will generate a file that is valid for Sadly Sadly, I have run into this error: NixOS/nix#6647, as now my generated crate (which has some dependencies in the store path) can't build due to that. Once that is fixed, I can show a way this is possible. (Will do a private fork test, and then check· |
Beta Was this translation helpful? Give feedback.
All reactions
-
This is how cargo2nix have fixed it: https://github.com/kolloch/crate2nix/pull/253/files#diff-9aed68438126bd7e3e0b283a8ded0e33df8602aa2da5c083ab4fcdb1781fe7c9R22 |
Beta Was this translation helpful? Give feedback.
All reactions
-
I think this is happening because you are presenting the Here's an alternative solution: instead of presenting the crates.io index as a local registry, make it available to the derivation that is generating the lockfile under |
Beta Was this translation helpful? Give feedback.
All reactions
-
👍 1
-
So, it turns out you can also do this:
This will create entries in the Cargo.lock like this:
The error (long)
However, despite the error message, that store path is never referenced in that string. I guess I will go and try to report that as well. |
Beta Was this translation helpful? Give feedback.
-
I am once again trying to do something weird, in this case generating a rust project which I then want to build using crane (and extract the built binary out of).
So far, generating a
Cargo.toml
andmain.rs
worked fine, but when it came to compile the whole thing it errored because of a missing Cargo.lock! This makes sense, since I just generated it.I realize this is also a more fundamental problem, since generating a Cargo.lock also means state and thus impurity. Now, could there be a way to generate a Cargo.lock? I am fine with having to specify for example the repository by git revision or somesuch.
Or is this absolutely not possible? (I feel like it is possible, but just no infrastructure currently)
Beta Was this translation helpful? Give feedback.
All reactions