-
-
Notifications
You must be signed in to change notification settings - Fork 7
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
Allow nixpkgs-check-by-name to work with recent Nix versions #79
Allow nixpkgs-check-by-name to work with recent Nix versions #79
Conversation
Nice, this looks like the right fix! Could you also extend the test suite I mentioned in #78 (comment) with a case for this? Furthermore it would be great to have some comments giving the extra context Edit: Also, let's increase the version number so we get a new release from this :) |
I'm trying, but I have no idea how you generated that test case. 😬 All the test says is "these are what Could you help me out with reproduction instructions? My best attempt is: toInherit: {
testA = 1;
"testB" = 2;
${"testC"} = 3;
"${"testD"}" = 4;
# A
testE
# B
=
# C
5
# D
;
# E
/**/testF/**/=/**/5/**/;/*E*/
testG = {
valueG = 6;
};
inherit toInherit;
inherit (toInherit) testH;
}
It's not helped out by unsafeGetAttrPos having no documentation whatsoever. |
Oh yeah I can't quite remember how I got those numbers, probably just some trial-and-error, but obviously without actually running the final version through Nix eval, because the file in main is invalid :P Your approach is pretty good though! I'm suggesting some changes: testG: {
testA = 1;
"testB" = 2;
${"testC"} = 3;
"${"testD"}" = 4;
# A
testE
# B
=
# C
5
# D
;
# E
/**/testF/**/=/**/5/**/;/*E*/
inherit testG;
inherit ({}) testH;
inherit ({})
testI testJ
testK testL;
}
|
52fd4a8
to
d128f5e
Compare
I'll do the requested version bump (and hence release) in a separate PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out of time for now, but ended up spending a bunch of time to improve the testing with #83
# Tests the tool on the pinned Nixpkgs tree with various Nix and Lix versions. | ||
# This allows exposure to changes in behavior from Nix and Nix-alikes. | ||
nixpkgsCheckWithLatestNix = packages.nixpkgsCheck.nixVersions.latest; | ||
nixpkgsCheckWithGitNix = packages.nixpkgsCheck.nixVersions.git; | ||
nixpkgsCheckWithMinimumNix = packages.nixpkgsCheck.nixVersions.minimum; | ||
nixpkgsCheckWithStableLix = packages.nixpkgsCheck.lixVersions.stable; | ||
nixpkgsCheckWithLatestLix = packages.nixpkgsCheck.lixVersions.latest; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is slowing down CI by about 3.5 minutes. I opened #83 instead to allow running the test suite with different Nix versions, which this PR can make use of.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is way less important now that #83 is merged and the tool doesn't depend on the ambient version of Nix. I'm fine cutting them all, or going down to {minimum,stable,latest}.
That said, given that reviews are usually a matter of a week or more, 3.5 minutes more isn't an actual issue. Amdahl's law!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I decided to keep these in the CI run. The number of PRs that aren't you or I is quite low.
src/nix_file.rs
Outdated
@@ -190,9 +190,7 @@ impl NixFile { | |||
// Something like `foo`, `"foo"` or `${"foo"}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While testing, I found out that this is the branch also used for the foo
in inherit (bar) foo
in Nix > 2.20.
// Something like `foo`, `"foo"` or `${"foo"}` | |
// Something like `foo`, `"foo"` or `${"foo"}` | |
// For Nix versions > 2.20, this is also `foo` in `inherit (bar) foo` |
src/nix_file.rs
Outdated
@@ -190,9 +190,7 @@ impl NixFile { | |||
// Something like `foo`, `"foo"` or `${"foo"}` | |||
} else if ast::Inherit::can_cast(node.kind()) { | |||
// Something like `inherit <attr>` or `inherit (<source>) <attr>`. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// Something like `inherit <attr>` or `inherit (<source>) <attr>`. | |
// Only for Nix versions <= 2.20: Something like `inherit <attr>` or `inherit (<source>) <attr>`. |
I'll take the various suggestions about comments and fix it up to run the cargo tests under a plethora of Nix versions. |
Nix eval using 2.3.18 (as performed by |
d128f5e
to
ba8bc85
Compare
This is drafted until an update for nixpkgs causes eval on 2.3.18 to pass. Edit on 2024-07-26: #88 unblocked this. |
…x version To run against a specific Nix or Lix version, run this: ``` nix-build -A nixpkgsCheck.nixVersions.nix_2_20 nix-build -A nixpkgsCheck.lixVersions.lix_2_90 ``` To run against all Nix or Lix versions, run this: ``` nix-build -A nixpkgsCheck.nixVersions nix-build -A nixpkgsCheck.lixVersions ``` CI will build the following versions: * `nixpkgsCheck` (using `nixVersions.stable`) * `nixpkgsCheckWithMinimumNix` (using `nixVersions.minimum`) * `nixpkgsCheckWithLatestNix` (using `nixVersions.latest`) * `nixpkgsCheckWithGitNix` (using `nixVersions.git`) * `nixpkgsCheckWithStableLix` (using `lixVersions.stable`) * `nixpkgsCheckWithLatestLix` (using `lixVersions.latest`) These new tests exposes that Nix versions greater than 2.20 fail. We don't currently have a derivation for unwrapped `nixpkgs-check-by-name`. Maybe soon.
…note This exposes that Nix latest and all Lix versions fail.
This causes the following tests to pass: - `nix-build -A nixpkgsCheck.nixVersions.nix_2_21` - `nix-build -A nixpkgsCheck.nixVersions.nix_2_22` - `nix-build -A nixpkgsCheck.nixVersions.nix_2_23` - `nix-build -A nixpkgsCheck.nixVersions.git` - `nix-build -A nixpkgsCheck.lixVersions.stable` Add a regression test for this multiline inherit situation. In that test, use `pretty_assertions` to get a nice diff expression for the assertion, and make it do one assertion instead of asserting in a loop.
ba8bc85
to
bb1b9e1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go! Thanks for this :D
Fixes #78. I didn't root cause what the new behavior in the most recent Nix versions was that made the output of nix-instantiate different.