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
kdeWrapper: postpone /share linking till final buildEnv #21771
Conversation
mkdir -p "$out/nix-support" | ||
cat "$drv/nix-support/propagated-user-env-packages" >> "$out/nix-support/propagated-user-env-packages" | ||
fi | ||
echo "$drv" >> "$out/nix-support/propagated-user-env-packages" |
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 add the unwrapped packages to the final environment, won't that just create collisions between the binaries and their wrappers? I don't think we want to do this.
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 thought so too and initially wanted to set higher priority for the wrapper to remedy this. However, experiment showed that somehow that's not the case:
$ nix-build -E 'with import ./. {}; buildEnv { name = "foo"; paths = [ kde5.gwenview ]; ignoreCollisions = false; checkCollisionContents = true; }'
completed without any collision warnings. I'm still wary of this however (that's part of why I'm unsure if this is a good idea). It solves problem of linking unwrapped /share
on the other hand.
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 think it won't collide when you evaluate buildEnv
, but later, when you try to install it to an environment!
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.
Aren't collision warnings printed by buildEnv
builder script? environment.systemPackages
is also buildEnv
so if we don't get them with this command we shouldn't get them at all. Still, I'm not sure there isn't anything else in the equation...
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 first buildEnv
doesn't see a collision because it hasn't included the propagatedUserEnvPkgs
yet. The final buildEnv
is going to look at the propagated-user-env-pkgs
file we create in this expression and then it's going to try to include all those packages; that is when the collision will occur.
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.
That's right, but my test adds wrapped derivation as its path, so it creates the scenario that you describe and yet, somehow, collision doesn't occur. Why it isn't is beyond me. To show it in more verbosity, this Nix expression:
with import <nixpkgs> {};
let
pkg = kde5.kdeWrapper {
unwrapped = [ kde5.gwenview.unwrapped ];
targets = [ "bin/gwenview" ];
paths = [ kde5.kipi-plugins ];
};
in buildEnv {
name = "foo";
paths = [ pkg ];
ignoreCollisions = false;
checkCollisionContents = true;
}
should be equivalent to my older experiment (so, it won't show collision warnings). I can't reproduce it right now to be sure though because my ISP blocks cache.nixos.org
again -_-. Can you try?
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.
It turns out that buildEnv
automatically ignores collisions involving propagatedUserEnvPkgs
, so this is all fine!
@@ -61,13 +61,9 @@ stdenv.mkDerivation { | |||
fi | |||
done | |||
|
|||
ln -s "$env/share" "$out" |
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.
You're definitely right to remove this. What I can't decide is: do we need to instead link the /share
paths from the unwrapped packages? I think probably not, for standalone applications, so don't worry about that yet.
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 think we need to do this because of /share/applications
and other paths that we would want to see in the user environment.
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.
That's true. What we should probably do, then, is to switch from mkDerivation
to buildEnv
and set pathsToLink = [ "/share"]
. We can set up the wrappers in a postBuild
script. Does that sound good?
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 would give us the same problem -- unwrapped packages' propagated-user-env-pkgs
would get there too, and so we'll get collisions later.
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.
That's OK! buildEnv
is smart enough to avoid collisions if the same package ends up in propagatedUserEnvPkgs
many times. What it is not smart enough to do is avoid collisions if you have two different packages that provide symlinks to the same destination! That's the root problem here.
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 I understand correctly exactly this would happen:
buildEnv
№1 (that is,kdeWrapper
) makes/share
including all packages propagated withpropagatedUserEnvPkgs
;buildEnv
№2 (environment.systemPackages
) has №1 as its input (including symlinks to some propagatedfoo
) and alsofoo
as its second input. Here we get a clash!
@abbradar This change prevents the |
Strange, it installed one for Gwenview in resulting buildEnv. I'll investigate when I get somewhere laptop-friendly; sorry for the trouble!
--
Nikolay.
|
Fixed in 9d35918.
|
Motivation for this change
Fix #21763. The idea is that now
/share
doesn't get linked to wrapped package. Instead we list unwrapped packages inpropagated-user-env-pkgs
, so that finalbuildEnv
builds/share
for us.I'm not sure this is the right way to fix the problem -- review appreciated!
Things done
(nix.useSandbox on NixOS,
or option
build-use-sandbox
innix.conf
on non-NixOS)
nix-shell -p nox --run "nox-review wip"
./result/bin/
)