Skip to content
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

Merged
merged 1 commit into from Jan 10, 2017

Conversation

abbradar
Copy link
Member

@abbradar abbradar commented Jan 9, 2017

Motivation for this change

Fix #21763. The idea is that now /share doesn't get linked to wrapped package. Instead we list unwrapped packages in propagated-user-env-pkgs, so that final buildEnv builds /share for us.

I'm not sure this is the right way to fix the problem -- review appreciated!

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@mention-bot
Copy link

@abbradar, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ttuegel to be a potential reviewer.

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"
Copy link
Member

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.

Copy link
Member Author

@abbradar abbradar Jan 9, 2017

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.

Copy link
Member

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!

Copy link
Member Author

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...

Copy link
Member

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.

Copy link
Member Author

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?

Copy link
Member

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"
Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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?

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

@abbradar abbradar Jan 9, 2017

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:

  1. buildEnv №1 (that is, kdeWrapper) makes /share including all packages propagated with propagatedUserEnvPkgs;
  2. buildEnv №2 (environment.systemPackages) has №1 as its input (including symlinks to some propagated foo) and also foo as its second input. Here we get a clash!

@ttuegel ttuegel merged commit 127b2fc into NixOS:master Jan 10, 2017
@ttuegel
Copy link
Member

ttuegel commented Jan 10, 2017

@abbradar This change prevents the .desktop file for Konsole from being installed; any idea why?

@abbradar
Copy link
Member Author

abbradar commented Jan 10, 2017 via email

@ttuegel
Copy link
Member

ttuegel commented Jan 10, 2017

Fixed in 9d35918.

propagated-user-env-packages needs to be a list of packages separated by a single space only, but the packages were separated by newlines, so buildEnv would take only the first one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Huge amount of collissions between KDE programs
3 participants