fix flake lock references pointing to wrong nixpkgs #380
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi! I think crate2nix is tremendously useful! I noticed that in addition to the caching benefits it provides there is less configuration required to use crate2nix compared to crane - especially when cross-compiling and statically-linking. I'm working on updating the git-workspaces branch in #298. (My work so far is here but there is a bit more for me to do.) While I was working I ran into some problems getting tests running that I wanted to submit PRs for. One problem has to do with references to inputs gotten from parsing
flake.lock
.There a couple of nix expressions that read
flake.lock
to load nixpkgs:crate2nix/default.nix
nix/nix-test-runner.nix
The problem is that
flakeLock.nodes.nixpkgs
does not refer to the intended nixpkgs version: it refers to the cachix input's nixpkgs input which is quite old. The version of nixpkgs locked at the flake root isflakeLock.nodes.nixpkgs_6
.Lock file node names are named somewhat arbitrarily. If the intention is to load the version of nixpkgs that is locked in flake.nix then it is necessary to:
flakeLock.root
to get the name of the root node. (The name is"root"
, but it's better not to assume.)flakeLock.nodes.${rootNodeName}.inputs.nixpkgs
to get the name of the lock file node of the intended nixpkgs version.flakeLock.nodes.${nixpkgsNodeName}
nix/nix-test-runner.nix
also gets the wrong version of nix-test-runner for the same reason.This change introduces a function,
flakeInput
, that applies the steps above.I wanted to be able to submit a PR with working tests, but the tests were not working so this PR also includes some test fixes. While I was at it I fixed clippy warnings.There is another issue that is explained in a comment that I put in
nix/nix-test-runner.nix
. I have a fix for that which I will submit in another PR.