-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
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
[RFC] Declarative wrappers #85103
[RFC] Declarative wrappers #85103
Conversation
The problem now is that wrapGAppsHook is smarter - it knows about packages that need certain search directories even if they are not in the dependency tree.
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/declarative-wrappers-another-idea/6661/6 |
Co-Authored-By: Cole Helbling <cole.e.helbling@outlook.com>
Any particular reason for using |
I'm much happier with the I'm also just curious about the lack of path separators ( |
No at all. I manually added new lines for the sake of readability. Now I edited my first comment to indicate that.
That's a good question. I guess I could use Let's take
If I change it to:
One of the colon separated values I get in the wrapped picard is:
Versus what I get now with
I think the documentation of
Hence
I'm up for consistency as well, but I think the way to refer to outputs eventually depends on the context - shell scripts use To make overrides for derivations built with
|
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/any-way-to-get-a-derivations-inputdrvs-from-within-nix/7212/5 |
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/awesomewm-luamodules-apparently-not-taking-effect/8507/6 |
@doronbehar i can help you out with the RFC. What I would like to have is a set of functions that describe what should be done. Then, there is a new |
Awesome :). If you've read my draft, there's that big list of issues I collected during my busy semester. I'd like to filter those who may not be relevant and better explain what's the issue behind them and explain for each how declarative wrappers could be used. Perhaps we can split the work on the RFC for "Motivation" vs "Design"?
? Nix Functions?
Definitely 👍.
That's even better. |
About the build instruction, see how the JSON could look for a single wrapper #95569. |
Thanks for working on this @FRidh . I've updated most of the Motivation part of the RFC draft at https://github.com/doronbehar/rfcs/blob/declarative-wrappers/rfcs/0075-declarative-wrappers.md . I'll update tomorrow regarding progress for the design and other sections. |
Official RFC live at NixOS/rfcs#75 . |
linkCmds_ = builtins.trace "linkCmds is ${builtins.toJSON linkCmds}" linkCmds; | ||
in | ||
symlinkJoin { | ||
name = "runtime-env"; |
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.
Perhaps this should inherit the name of the parent derivation.
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.
Not always there's a single parent derivation, but certainly for most purposes, this would be nicer.
# Useful for debugging, not evaluated if not used. | ||
linkCmds_ = builtins.trace "linkCmds is ${builtins.toJSON linkCmds}" linkCmds; | ||
in | ||
symlinkJoin { |
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.
One disadvantage of symlinkJoin
is that when absolute path is used in an entry point (e.g. desktop files, systemd services…), it will launch the unwrapped program.
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.
Right.. Extra commands should be at postBuild
for that to work. I wonder whether it'd be worth the effort to write something generic, or make wrapGeneric
accept a extraBuildCommands
string.
let | ||
# From some reason, pkg == knownPkg doesn't work :/ don't know | ||
# why... Never the less this should be good enough | ||
deeperPkgs = builtins.filter notInEncyclopedia (pkg.buildInputs ++ pkg.propagatedBuildInputs); |
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.
How does the neowrapper handle propagation boundaries when buildInputs
and propagatedBuildInputs
are the same?
For example, libinput
depends on pyudev
for its utilities but we do not want everything that links against libinput
to have pyudev
as dependency.
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.
libinput
not only has a certain python environment in it's buildInputs
, it also references this python env at ${libinput.bin}/libexec/libinput/libinput-measure-fuzz
. Note it's the bin
output, not the more widely linked against out
output.
we do not want everything that links against libinput to have pyudev as dependency.
Agreed. The current design suffers from the inability to distinguish between libinput
specified in a drv's buildInputs
, vs libinput.out
(and not libinput.bin
) referenced by a drv. With the ability to distinguish between the two, wrapGenric
should be capable of knowing not to add python related env vars to a wrapper, if it's only libinput.out
that's referenced.
This issue naturally relates to the unresolved questions of the RFC.
}, | ||
*/ | ||
wrapOut ? {}, | ||
}: |
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 wonder if you consider targetting wrappers in-scope? For example, fwupd
needs to exclude EFI files from being wrapped; gjs
only wants to wrap installed tests…
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.
Am I to understand you are concerned that wrapGeneric
can't be instructed to wrap only some executables and not others?
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.
Yes. Ideally, it should be able to handle multiple disjoint wrappers.
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.
Definitely we need to have that ability and it shouldn't be that hard to implement. I still don't have an idea though as to how this interface should look like. I'll update this PR or the RFC once I'll think about something, suggestions are welcome.
Closing as the design we aim at now has been thoroughly changed and there's nothing much interesting here IMO. |
Motivation for this change
Create a new wrapper to rule them all! 😈
Now Seriously: This has been talked over since like for ever and now I'd like to present to you a Pure Nix function that creates a wrapper environment for any derivation you'll give it, using
symlinkJoin
. It does so by recursively searching for a derivation's inputs' for derivations with an attribute such as:This recursive search means, that you don't have to take care of orchestrating
wrapGAppsHook
andwrapQtAppsHook
or others with stuff like this:I tested in this new function in wrapping picard, gucview (which is currently not wrapped but there's an open PR that wraps it the old way #84449) and arandr.
Here's an example of the environments (new lines inserted to help readability) created for guvcview with the old way and the new way:
OLD
NEW
As you can see, there are duplicates entries in the old wrapper which increases the chances of hitting obsurd issues such as what #84689 fixed.
What
didn'tworks?(EDIT) Everything I tested.
How would a user override a derivation wrapped this way?
Say
all-packages.nix
has:Assuming the user knows
my-awesome-pkg
is wrapped withwrapGeneric
, he would need to use an overlay like this:Things done
sandbox
innix.conf
on non-NixOS linux)nix-shell -p nixpkgs-review --run "nixpkgs-review wip"
./result/bin/
)nix path-info -S
before and after)