-
-
Notifications
You must be signed in to change notification settings - Fork 15k
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
texlive: create scope #250416
base: master
Are you sure you want to change the base?
texlive: create scope #250416
Conversation
@@ -478,12 +478,14 @@ let | |||
texliveBinaries = bin; | |||
}; | |||
|
|||
tl = lib.mapAttrs (pname: { revision, extraRevision ? "", ... }@args: | |||
texlivePackages = lib.makeScope newScope (self: lib.mapAttrs (pname: { revision, extraRevision ? "", ... }@args: |
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.
To understand: why do we need newScope
here (as opposed to (x: x)
)? The only difference seems to be the attribute callPackage
, which we do not use, after all. Everybody else seems to be using makeScope newScope
.
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.
if we don't need/want callPackage, we could use
texlivePackages = lib.makeScope newScope (self: lib.mapAttrs (pname: { revision, extraRevision ? "", ... }@args: | |
texlivePackages = lib.makeExtensible (self: lib.mapAttrs (pname: { revision, extraRevision ? "", ... }@args: |
In this case, the "extender"-attribute is called extend
instead of overrideScope'
.
Edit: there also is lib.makeExtensibleWithCustomName
.
I don't really see why you would want to use id
instead of newScope
-- eval time should be identical due to the lazy nature of nix and using id
will result in "broken" callPackage and newScope attributes.
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.
"broken" callPackage and newScope attributes.
My problem is probably that I don't quite understand what newScope
is supposed to do. Is it to make it so the new callPackage
knows all the attributes from the previous scope?
Edit: there also is
lib.makeExtensibleWithCustomName
.
Excellent. We want camel case attributes whenever possible to avoid a repeat of the combine
clash, and makeScope
injects packages
, low risk name for sure, but still a risk. If we don't have a use for newScope
and callPackage
, it seems like an obvious choice.
@apfelkuchen6 I believe I jumped ahead of you! |
The main benefit of the the approach in #120578 -- making the whole texlive attrset a scope -- is that it allows overriding the binaries, which isn't really possible with this approach, where just the package set is a scope. Having overridable binaries is kind of neccessary for adding texlive-2023 without ugly case distinctions, so we will probably have to make texlive a scope anyway (I'm open to other ideas though). I'm not sure whether also making the package set a scope adds anything in this case. One could already override the package set with something along the lines of |
I see. I suppose the key point here is that unlike lua/python/perl/etc, the binary part of texlive is not quite a monolithic package; where one would manipulate TL;DR we have to move texlive.overrideScope (final: prev: { bin = prev.bin // { core = prev.bin.core.overrideAttrs { ...}; }; }) achieves the intended result. Does the above make sense? (Code tomorrow probably, if you don't beat me to it.) |
That makes sense. Unfortunately, getting the splicing to work in combination with the compatibility fixups that reinsert the packages into the toplevel is not particular easy. Just doing what everyone else does (defining the other splices "from the top" as Can you think of a better solution? I have code for this lying around, I hope it is somewhat rebasable :D |
Yes please! Any suggestions for debugging the splicing? E.g. how/where can I inspect |
You can browse in the repl. Be aware that only cross package sets are spliced:
No idea how to debug infinite recursion though. I just noticed that currently cross-compilation of texlive.bin.core's dependency libavif is broken, so we cannot really test it anyway, but what I've done at least instantiates. |
Oh so it's the packages under |
When accessing things via "fully qualified attr paths" such as Adding custom splicing-magic is only neccessary when things in scope refer to each other "relatively" via the scope and not "fully qualified" via the top level. In this case, the splicing done in But this means that there probably is no pretty way to debug whether the splicing is done correctly inside the scope, as we only have the "outside view" where |
I think I have figured it out? I can create a scope using builtins tools only via Except that Give me a moment to complete the multi-output, then I'll rebase this PR, and we'll compare against your reference implementation. |
528d0bc
to
a695286
Compare
texlive = makeScopeWithSplicing' { | ||
f = makeTeXLive; | ||
otherSplices = generateSplicesForMkScope "texlive"; | ||
}; | ||
in | ||
# backward compatibility layer: expose packages directly under texlive, but not as derivations | ||
# this cannot be done from within the scope | ||
(builtins.mapAttrs | ||
# flag if manpages are present | ||
(n: p: let pWithMan = p // lib.optionalAttrs (p ? man) { texdoc = p.texdoc // { hasManpages = true; }; }; in { | ||
pkgs = builtins.concatMap (n: lib.optional (p ? ${n}) p.${n}) [ "tex" "texdoc" "texsource" "tlpkg" "out" ]; | ||
}) | ||
texlive.__pkgs) // texlive |
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.
The compromise here is that you cannot use inherit (texlive.overrideScope ...) package
, so this must come after buildEnv
.
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.
...or we do @apfelkuchen6's applyOverScope
trick:
13e7808#diff-78dd1e8609118bb30c483b837f017110017218a9b7c388887a9c0ed0aa823f36R162-R176
a695286
to
ffa7562
Compare
…for TeX Live packages
Minimal implementation of texlive.buildEnv which builds the same outputs as texlive.combine. Prefixed to allow for testing and changes to the interface.
Initial step to convert the texlive attribute into a scope with slices. This commit does not add the self references needed to make .overrideScope useful.
ffa7562
to
628ac6e
Compare
@@ -90,11 +90,12 @@ core = stdenv.mkDerivation rec { | |||
|
|||
nativeBuildInputs = [ | |||
pkg-config | |||
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform) [ | |||
] ++ lib.optionals (!stdenv.buildPlatform.canExecute stdenv.hostPlatform && self.bin.core ? __spliced) [ |
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.
@apfelkuchen6 this was causing infinite recursion when evaluating the splice hostHost
, because in that case the build self.bin.core
would be the same as the host self.bin.core
, regardless of the true buildPlatform
and hostPlaftorm
. Conveniently, __spliced
is not generated in hostHost
, hence the ? __spliced
guard.
I don't think I have seen this pattern anywhere. Is there a more idiomatic way to address the issue?
(This is an academic issue as we would never evaluate hostHost
in the actual build, it was just annoying for debugging.)
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.
There are a bunch of derivations with cross self-dependenies (for example vala and guile), but I couldn't find anything that only adds itself if the derivation is spliced.
I'd consider it a non-issue. Maybe doing nothing about it is even better as it might detect actual problems at eval time.
Description of changes
Third step along the progression multi-output / buildEnv / scope / ???: create a
texlive
scope that can be overridden in a monolithic way viaoverrideScope
. Contains the minimum bits and pieces of #250626 to get here.This should prove that the multi-output style and
texlive.__buildEnv
are complete enough to move forward.Note that this is only groundwork for proper overridability: we need further bits, like an overridable
buildTeXLivePackage
, and a user-friendly way to override everything related to tlpdb; #250626 has more stuff about overriding the binaries in a nice way, allowing for different years to coexist, for instance.Things done
sandbox = true
set innix.conf
? (See Nix manual)nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD"
. Note: all changes have to be committed, also see nixpkgs-review usage./result/bin/
)