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

sway: refactor with a wrapper #75247

Merged
merged 1 commit into from Dec 21, 2019
Merged

sway: refactor with a wrapper #75247

merged 1 commit into from Dec 21, 2019

Conversation

ghost
Copy link

@ghost ghost commented Dec 8, 2019

Motivation for this change

When executing sway, if you start waybar, or wofi , Icon themes and/or Gtk Themes are not loaded.

It can be fixed by bulindg Sway with a wrapGAppsHook in nativeBuildInputs. @primeos proposed on issue #67704 to default on an unwrapped version. which is made is this PR with programs.sway.package option defaulting to an unwrapped version of Sway.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @primeos

@primeos primeos self-assigned this Dec 8, 2019
Copy link
Member

@primeos primeos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the delay, I'm a bit short on time atm.

This differs from what I had in mind, but I'm also open for suggestions if you or someone else has a better idea (I haven't thought that much about this so far). If you just want the functionality I'm also fine if this only changes the sway package by e.g. introducing a wrapGApps "use flag" (true/false).

Feel free to ask any questions, my review might be too short to properly explain what I had in mind... :o

nixos/modules/programs/sway.nix Show resolved Hide resolved
pkgs/top-level/all-packages.nix Outdated Show resolved Hide resolved
@ofborg ofborg bot requested a review from primeos December 11, 2019 10:40
@ghost
Copy link
Author

ghost commented Dec 11, 2019

Hello @primeos, thank you for your extensive review ! I've re-read what you said on #67704 and with the information you given I've changed the way I implemented it :

  • We now have a wrapper separated from sway itself.
  • I've moved the wrapper from the sway module (programs.sway) to the wrapper itself.
    • It is enabled by default, and it has a toggle named withBaseWrapper.
  • I've added a toggle named withGAppsWrapper, disabled by default.

I did not understood what you meant with the swaybg part on your last review. Could you please clarify this point ? :)

@ghost ghost changed the title sway: refactor with an unwrapped version sway: refactor with a wrapper Dec 11, 2019
@Synthetica9
Copy link
Member

Maybe rename the withGAppsWrapper to something like withGTKWrapper? GApps is already widely used for Google Apps on the Android platform, I don't think I've ever heard it used in reference to GTK.

@ghost
Copy link
Author

ghost commented Dec 11, 2019

@Synthetica9 You are right, It wasn't really explicit. Fixed it.

@ghost
Copy link
Author

ghost commented Dec 12, 2019

@primeos I have just found your PR about adding Sway to dislpay managers :

    # To make a Sway session available if a display manager like SDDM is enabled:
    services.xserver.displayManager.extraSessionFilePackages = [ swayJoined ];

I believe it will be impacted by this PR (if merged). Do you want to merge yours first then let me rebase mine or the other way around ?

Copy link
Member

@primeos primeos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, looks way better now :)

Regarding the other PR: I'll probably merge my PR first as it's very trivial and already good to go (I assume). Feel free to rebase if you want.

nixos/modules/programs/sway.nix Show resolved Hide resolved
nixos/modules/programs/sway.nix Outdated Show resolved Hide resolved
pkgs/applications/window-managers/sway/wrapper.nix Outdated Show resolved Hide resolved
pkgs/applications/window-managers/sway/wrapper.nix Outdated Show resolved Hide resolved
pkgs/applications/window-managers/sway/wrapper.nix Outdated Show resolved Hide resolved
pkgs/applications/window-managers/sway/wrapper.nix Outdated Show resolved Hide resolved
pkgs/applications/window-managers/sway/wrapper.nix Outdated Show resolved Hide resolved
@primeos
Copy link
Member

primeos commented Dec 13, 2019

cc @gnidorah @colemickens (FYI, forgot that @GrahamcOfBorg doesn't notify module maintainers, feel free to add feedback)

@ofborg ofborg bot requested a review from primeos December 13, 2019 14:55
@ghost
Copy link
Author

ghost commented Dec 13, 2019

Thank you again @primeos for your time and review, I've made the fixes you asked, important changes made in this iteration :

  • We now have a wrapperFeatures that can be used like you proposed (it's way cleaner).
  • I've moved swaybg to the wrapper.

EDIT: I'm still having trouble to understand the exact behavior of wrapGAppsHook, it seems what in buildInputs can affect how it behaves, but I'm not sure why.

@ghost
Copy link
Author

ghost commented Dec 19, 2019

Rebased branch after merging of #75363

@primeos
Copy link
Member

primeos commented Dec 21, 2019

@elyhaka thanks for your awesome work, I finally got around to properly review this (sorry for the long delay :o) and added a few minor improvements. Are you ok with these changes? If so I would run a final test, squash my commit into yours and it should be ready to be merged.

Copy link
Member

@primeos primeos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick review for myself to not forget about the wrong indentations I've introduced...

Update: Fixed the indentations.

TODOs:

  • ACK from @elyhaka
  • Squash the commits
  • Final test

nixos/modules/programs/sway.nix Show resolved Hide resolved
nixos/modules/programs/sway.nix Show resolved Hide resolved
nixos/modules/programs/sway.nix Outdated Show resolved Hide resolved
nixos/modules/programs/sway.nix Outdated Show resolved Hide resolved
@ofborg ofborg bot requested a review from primeos December 21, 2019 15:21
@ghost
Copy link
Author

ghost commented Dec 21, 2019

This looks good to me ! Thank you for taking the time to do the final changes 😄

@ghost
Copy link
Author

ghost commented Dec 21, 2019

@primeos : I've made some tests, and it seems we have a regression on gsettings. I'm investigating the cause.

EDIT : I managed to make it works again locally (I haven't committed since I do not want to touch your modification without being sure it fits the requirements).

Here are my steps to restore the expected behavior:

  1. Removed the dontWrapGApps = true;

  2. Rewrite the postBuild hook with the following content:

    wrapProgram $out/bin/sway --prefix PATH : "${swaybg}/bin"
    ${optionalString withGtkWrapper "wrapGAppsHook"}
    

I am not sure at all why it behaves this way

@ghost
Copy link
Author

ghost commented Dec 21, 2019

@primeos : It works with the last commit 👍

@primeos
Copy link
Member

primeos commented Dec 21, 2019

@elyhaka thanks, I totally missed that regression :o I verified that the wrapper was adding arguments but didn't realise that some where missing. I've had a look at pkgs/build-support/setup-hooks/wrap-gapps-hook.sh and noticed that wrapGAppsHook must be executed to initialize the variables. It should work as expected now. I've also updated buildInputs as it turns out that only gdk-pixbuf should be required.

The reason for the dontWrapGApps=true hack is that I would like to avoid wrapping all binaries and wrapping sway twice:

[root@nixos-unstable:/var/nixpkgs]# ls -al /nix/store/k4cm6pvbc37iwz9ac6vb38kvzpwipczc-sway-1.2/bin/
total 44
dr-xr-xr-x 2 root root 4096 Jan  1  1970 .
dr-xr-xr-x 5 root root 4096 Jan  1  1970 ..
-r-xr-xr-x 1 root root 1047 Jan  1  1970 sway
-r-xr-xr-x 1 root root  959 Jan  1  1970 swaybar
lrwxrwxrwx 1 root root   74 Jan  1  1970 .swaybar-wrapped -> /nix/store/86gzfk3pj8bg4clw2var203id2br8wr2-sway-unwrapped-1.2/bin/swaybar
-r-xr-xr-x 1 root root  959 Jan  1  1970 swaymsg
lrwxrwxrwx 1 root root   74 Jan  1  1970 .swaymsg-wrapped -> /nix/store/86gzfk3pj8bg4clw2var203id2br8wr2-sway-unwrapped-1.2/bin/swaymsg
-r-xr-xr-x 1 root root  959 Jan  1  1970 swaynag
lrwxrwxrwx 1 root root   74 Jan  1  1970 .swaynag-wrapped -> /nix/store/86gzfk3pj8bg4clw2var203id2br8wr2-sway-unwrapped-1.2/bin/swaynag
lrwxrwxrwx 1 root root   71 Jan  1  1970 .sway-wrapped -> /nix/store/86gzfk3pj8bg4clw2var203id2br8wr2-sway-unwrapped-1.2/bin/sway
-r-xr-xr-x 1 root root  956 Jan  1  1970 .sway-wrapped_

With this hack only sway will be wrapped and also only once (if I think about it it should also be possible to get rid of .sway-wrapped by using something like makeWrapper $oldBinary $wrapper $args but that could be optimized later):

[root@nixos-unstable:/var/nixpkgs]# ls -al /nix/store/0g4gkad9ikim9hf94sgzn9g3dgnganbv-sway-1.2/bin/
total 28
dr-xr-xr-x 2 root root 4096 Jan  1  1970 .
dr-xr-xr-x 5 root root 4096 Jan  1  1970 ..
-r-xr-xr-x 1 root root 1046 Jan  1  1970 sway
lrwxrwxrwx 1 root root   74 Jan  1  1970 swaybar -> /nix/store/86gzfk3pj8bg4clw2var203id2br8wr2-sway-unwrapped-1.2/bin/swaybar
lrwxrwxrwx 1 root root   74 Jan  1  1970 swaymsg -> /nix/store/86gzfk3pj8bg4clw2var203id2br8wr2-sway-unwrapped-1.2/bin/swaymsg
lrwxrwxrwx 1 root root   74 Jan  1  1970 swaynag -> /nix/store/86gzfk3pj8bg4clw2var203id2br8wr2-sway-unwrapped-1.2/bin/swaynag
lrwxrwxrwx 1 root root   71 Jan  1  1970 .sway-wrapped -> /nix/store/86gzfk3pj8bg4clw2var203id2br8wr2-sway-unwrapped-1.2/bin/sway

Edit:

@primeos : It works with the last commit +1

Awesome, thanks :)

@ghost
Copy link
Author

ghost commented Dec 21, 2019

@primeos Wow, really good catch ! Thank you very much for the explanation. It is way cleaner with this approach. Everything looks good to me !

Copy link
Member

@primeos primeos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be ready to merge now :) \o/

Thank you @elyhaka

@ghost
Copy link
Author

ghost commented Dec 21, 2019

Thank you too @primeos ! 😃

@primeos primeos merged commit b9b7738 into NixOS:master Dec 21, 2019
@ghost ghost deleted the sway branch December 22, 2019 07:40
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.

None yet

3 participants