-
|
Some packages don't have a main binary (e.g. Currently, |
Beta Was this translation helpful? Give feedback.
Replies: 9 comments 4 replies
-
|
Looks like this is the intended way to use it: inputs.wrappers.lib.wrapPackage {
inherit pkgs;
package = pkgs.cowsay;
wrapperVariants.foobar = { };
wrapperFunction =
{
config,
wlib,
callPackage,
...
}:
(import wlib.modules.makeWrapper).wrapVariants {
inherit config wlib callPackage;
};
}It feels very verbose though, it would be nice if there's a simpler approach. Also even with this method, there's no option to autowrap all the binaries in |
Beta Was this translation helpful? Give feedback.
-
|
I mean, what you did works technically, but it feels overcomplicated. Also you redefined it in a more verbose way than necessary (Edit: turns out you did not, but this less verbose way works now), this is equivalent to your cowsay example inputs.wrappers.lib.wrapPackage {
inherit pkgs;
package = pkgs.cowsay;
wrapperVariants.foobar = { };
wrapperFunction = (import wlib.modules.makeWrapper).wrapVariants;
}It takes the same arguments and returns a string, so you can just use that directly. The value from calling it is given to builderFunction. Verbosity aside though, can't this be fixed by setting I don't understand the cowsay example. What is it trying to create? Cowsay does not contain a
The variants by default have the same values you set in the main wrapper options but can be modified, except they have If you want to change the There is no "wrap all of them", there are not very many derivations where it contains enough things in bin/ for that to be a problem. And if you were wrapping them all the same way, that would just be 1 line per binary using the wrapperVariants option. Theoretically this is possible, however there would be no way to get information about that back into nix, only within the drv's build script, as otherwise that is IFD. So such an option would likely have to be mutually exclusive with the wrapperVariants options, or you would have to accept much more hidden behavior.
However what you provided is far more verbose than it should be, and redefining |
Beta Was this translation helpful? Give feedback.
-
inputs.wrappers.lib.wrapPackage {
inherit pkgs;
package = pkgs.cowsay;
exePath = "bin/foobar";
binName = "foobar";
}if Is that what the goal is here? i.e. inputs.wrappers.lib.wrapPackage {
inherit pkgs;
package = pkgs.hydrus;
# you should pick whichever one you would run via `nix run` for the main one.
exePath = "bin/hydrus-client";
binName = "hydrus-client";
# wrap the package
# will repeat whatever you set for the main one but with different `exePath` and `binName` unless you change some values per item.
wrapperVariants.hydrus-server = {};
wrapperVariants.hydrus-test = {};
}Does that achieve the goal you wanted to achieve? If you really really wanted them all to have entirely disconnected options, that would be when you would do the verbose thing, but I am pretty sure this would be quite rare inputs.wrappers.lib.wrapPackage {
inherit pkgs;
package = pkgs.hydrus;
# redefine wrapperFunction so that it doesn't wrap a main one (this is equivalent to what you had for cowsay)
wrapperFunction = (import wlib.modules.makeWrapper).wrapVariants;
# top level exePath now does nothing, and binName is used a few places, but the only one of note here is:
drv.meta.mainProgram = null; # <- I am pretty sure setting null for meta.mainProgram is OK? If not choose one and we can maybe see about what to do about that, but honestly we probably should choose one anyway for hydrus.
# now they will all inherit from what you set at the top level, but there is no "main" one.
wrapperVariants.hydrus-client = {};
wrapperVariants.hydrus-server = {};
wrapperVariants.hydrus-test = {};
}I don't expect this to be common though, usually the first way is the way to go? It is usually only 1 or 2 options which need to differ for the variants if any, so usually I would say you should just set those for the variants yourself in your module instead of redefining wrapperFunction. The fact you CAN do that is good, and given the amount of behavior the above example redefines, it is honestly pretty decent in terms of verbosity? But I am not sure it is what you need here to achieve what you want, basically. Totally fine if it is the best thing to do, but it is at least not the only way to do it. |
Beta Was this translation helpful? Give feedback.
-
|
Thank you, I didn't know that Note that this does not work for me though: inputs.wrappers.lib.wrapPackage {
inherit pkgs;
package = pkgs.cowsay;
wrapperVariants.foobar = { };
wrapperFunction = (import inputs.wrappers.lib.modules.makeWrapper).wrapVariants;
}It errors with: error: function 'wrapVariants' called with unexpected argument 'name'
at /nix/store/5m8gisfdln2v1cvf9jb3i569s3ma8s2l-source/modules/makeWrapper/module.nix:555:5:
554| wrapVariants =
555| {
| ^
556| pkgs ? null, |
Beta Was this translation helpful? Give feedback.
-
|
Oh! I could make that work I guess.... Thanks for letting me know. I thought that would work, and did not actually run it to check... my bad.... I can fix that pretty easily actually, may be a lot nicer. wrapAll =
{
pkgs ? null,
wlib,
callPackage ? pkgs.callPackage or (usage_err "wrapAll"),
config,
...
}:
callPackage (import ./. null) { inherit config wlib; };
wrapMain =
{
pkgs ? null,
wlib,
callPackage ? pkgs.callPackage or (usage_err "wrapMain"),
config,
...
}:
callPackage (import ./. false) { inherit config wlib; };
wrapVariants =
{
pkgs ? null,
wlib,
callPackage ? pkgs.callPackage or (usage_err "wrapVariants"),
config,
...
}:
callPackage (import ./. true) { inherit config wlib; };If I add the Im not going to do it for wrapVariant though, because it doesn't make sense to use also binName docs should be defined in the core options and exePath should as well |
Beta Was this translation helpful? Give feedback.
-
|
ok, now the shorter version where you just pass it directly should work haha my bad sorry If you want to do it that way, go for it, otherwise, yeah, binName and exePath work at top level as well they just are not defined by the makeWrapper module but core instead. binName is used for pname and a few other things if the drv used doesn't provide one, so it had to be in core, and I did not really know what to do with exePath but it seemed a good idea for wrapperFunction implementations to use such an option so I added it there as well so that if people do their own wrapperFunction implementations they will use the already existing exePath option And then the variants are literally the same exact function just called on the value from one of the wrapperVariants instead of the whole config |
Beta Was this translation helpful? Give feedback.
-
|
Thanks!
Oh my bad, I see it now. |
Beta Was this translation helpful? Give feedback.
-
|
Also related, the reason wrapperVariants was added in the first place: |
Beta Was this translation helpful? Give feedback.
-
|
When this PR is merged, this discussion will be closed as The functions that have been moved have been given deprecation warnings in the PR |
Beta Was this translation helpful? Give feedback.
if
cowsayhad abin/foobarand you wanted to wrap that and NOTbin/cowsay, which it appears is what your example is doing, you would just do this.Is that what the goal is here?
i.e.