-
-
Notifications
You must be signed in to change notification settings - Fork 15.1k
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
treewide: load structured attributes in all bash builders consistently #357053
treewide: load structured attributes in all bash builders consistently #357053
Conversation
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.
All the files which already load the attrs file before sourcing stdenv are straight-forward.
A lot of files can easily be verified to be passed to mkDerivation
's builder
argument. Those are the cases that are straight up broken with structuredAttrs and easily fixed by loading the attrs file globally.
There are some remaining cases which are more special and need more attention. I left comments on each of them. Maybe I need to split some of these into a separate clean-up commit.
4e583b2
to
175515d
Compare
I split up the commits better, all the straight-forward cases are in the first commit now, the other cases in the remaining respectively. |
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.
Found a few more cases of source $stdenv/setup
outside pkgs/
. Added fixes for the simple ones, but still need to look into the last two commits I added.
FTR: I can't make any sense of this at all, yet, will probably leave it out of this PR:
+ const patchShebangs = () => spawn('bash', ['-c', 'source $stdenv/setup; patchShebangs node_modules'], { cwd: dir }) |
Putting in on draft until I looked at the last two commits again.
175515d
to
7f894f0
Compare
I don't think this is strictly related to the Nix deprecation story: minver is supposed to be bumped conservatively to give even older instances a chance to upgrade. The 2.3 thing just became a very hot topic since 2.4+ are somewhat controversial (tl;dr flakes and a very large diff) which is why I'm a little hesitant to write it off (also, it's still maintained). I fully agree with what @wolfgangwalther said here, we should stop supporting Nix versions to get rid of workarounds like that (I mean, there are a bunch of places that don't check for both cases, so technically 2.3 is broken there currently) and I think this is the quicker way to achieve that. Also, I think Tvix is targeting Nix 2.3 as baseline? Anyways, at the end of the day, somebody has to make that call. I think we even had a Nixpkgs architecture team in the past ;-)
I get the motivation, but wouldn't it be awkward if your Nix is sufficient to evaluate, but not to build nixpkgs? Anyways, @wolfgangwalther the current state looks reasonable. I'd go through the changes soonish one last time and merge then. |
Meh this now needs a rebase @wolfgangwalther. Feel free to merge after that. |
It's hard to put the sourcing of ./.attrs.sh into all builder consistently - mistakes will happen. Thus, load structured attrs once in make-derivation and then source the remaining builder on top. This should fix quite a few builders with structured attributes in principle. Most importantly it helps substitute / substituteAll, which are required for bootstrap on some platforms.
When building with structuredAttrs, two things would happen: - sourcing stdenv would fail, because $stdenv is not set. - the error is swallowed because bash is called without -e. Thus, the build appears to be successful at first, but could fail later when anything depends on a sourced stdenv.
Those are run inside buildCommand, which is evaled inside stdenv/setup - so no reason to source it again.
This should have been removed in 82e1d0c.
The NIX_ATTRS_SH_FILE needs to be available visible inside the fakechroot environment, so that we can load it for structuredAttrs support.
6b070c2
to
255012c
Compare
Late to the party here, but the Nix minimum version bump that makes sense to me is 2.18, as the “new 2.3” and a reasonable baseline for Nix semantics, given Lix’s explicit choice of it as a base and the year that Nixpkgs was stuck on it. That cuts off 23.05, but the upside is that 23.11 doesn’t just contain 2.18 but also defaults to it, so the story is pretty simple: “upgrade to 23.11 before upgrade to 25.05”. I don’t think that anyone really cares about the versions between 2.4 and 2.18, and the latter has had an above‐average level of maintenance put into it given its use as the default version across multiple Nixpkgs releases. I know Tvix is aiming for 2.3 compatibility, but I believe that relates to post‐2.3 eval behaviour regressions that Nixpkgs assuming any newer version might run into anyway, and I imagine there is room for adjustment there given the importance of Nixpkgs compatibility. (But of course we should ping representatives of all implementations, and anyone else who might have a stake in the choice, on the PR.) |
I'm not really opposed to your suggestion, I just tried to be as conservative as possible to get it through. But I'm not sure I'll follow through now that things got a little more complicated. |
Sorry if I contributed to any of the complication :) I do think some bump is a reasonable idea and I’m not too fussy about what exact version. |
I think I used the wrong wording here, all good! That being said, I do think your approach is reasonable and I'd be in favor of such a change. |
Gotcha. Admittedly the (IMO premature) removal of 2.18 from Nixpkgs might make dropping 2.3 more controversial still. (Though probably most people who would move to that would just use Lix instead these days, I suppose?) |
Bisect says that this broke The only output is:
|
I get this output:
|
I also note that |
So the problem is:
Once I fix that, both Will open a PR. |
It's hard to put the sourcing of ./.attrs.sh into all builder consistently - mistakes will happen. Thus, load structured attrs once in make-derivation and then source the remaining builder on top.
This should fix quite a few builders with structured attributes in principle. Most importantly it helps substitute / substituteAll, which are required for bootstrap on some platforms.
Part of the overall effort to enable structuredAttrs by default eventually, tracking: #205690
As the author of #257919, you might be interested in reviewing this, @Ma27?
Things done
nix.conf
? (See Nix manual)sandbox = relaxed
sandbox = true
nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)Add a 👍 reaction to pull requests you find important.