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: 0.13.0 -> 0.14.0 #30493

Merged
merged 3 commits into from Oct 19, 2017
Merged

sway: 0.13.0 -> 0.14.0 #30493

merged 3 commits into from Oct 19, 2017

Conversation

disassembler
Copy link
Member

@disassembler disassembler commented Oct 17, 2017

Motivation for this change

comment said it segfaults, but worked fine for me.

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
    • 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 nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

@Mic92
Copy link
Member

Mic92 commented Oct 17, 2017

How can I test this?

@disassembler
Copy link
Member Author

It doesn't seem to work if all you do is nix-build -A sway and run result/bin/sway. I'm not exactly sure why. But if you add sway and xwayland to environment.systemPackages and run nixos-rebuild -I nixpkgs=/path/to/nixpkgs and then stop X11 and run sway as a user, you should have the sway background show up. hitting super+enter will give you a terminal. You can also switch workspaces using super+# (where # is the workspace you want). The sway bar doesn't seem to work with the default config on 0.14.0. Works great with 0.15-rc2 though, so maybe we just wait until that releases.

@7c6f434c
Copy link
Member

7c6f434c commented Oct 17, 2017 via email

@Mic92
Copy link
Member

Mic92 commented Oct 17, 2017

I added a module with the capabilities as described in the project page, but I get a segfault as well:

gdb> bt
#0  0x00007f4798edf0f7 in wl_list_remove () from /nix/store/xyajc0iyp9z1pkmssfazjjsvw1r9kc68-wayland-1.12.0/lib/libwayland-server.so.0
#1  0x00007f47997ce3a7 in wlc_xwm_release () from /nix/store/ia6jgf3yw2nrz0704dbnnk09bcrx6rsj-wlc-0.0.10/lib/libwlc.so.0
#2  0x00007f47997b34c0 in xwayland_event () from /nix/store/ia6jgf3yw2nrz0704dbnnk09bcrx6rsj-wlc-0.0.10/lib/libwlc.so.0
#3  0x00007f47997cbafc in wlc_xwayland_terminate () from /nix/store/ia6jgf3yw2nrz0704dbnnk09bcrx6rsj-wlc-0.0.10/lib/libwlc.so.0
#4  0x00007f47997cc422 in destroy_event () from /nix/store/ia6jgf3yw2nrz0704dbnnk09bcrx6rsj-wlc-0.0.10/lib/libwlc.so.0
#5  0x00007f4798eda7bc in wl_client_destroy () from /nix/store/xyajc0iyp9z1pkmssfazjjsvw1r9kc68-wayland-1.12.0/lib/libwayland-server.so.0
#6  0x00007f4798eda8d8 in wl_client_connection_data () from /nix/store/xyajc0iyp9z1pkmssfazjjsvw1r9kc68-wayland-1.12.0/lib/libwayland-server.so.0
#7  0x00007f4798edcae2 in wl_event_loop_dispatch () from /nix/store/xyajc0iyp9z1pkmssfazjjsvw1r9kc68-wayland-1.12.0/lib/libwayland-server.so.0
#8  0x00007f4798edaf8a in wl_display_run () from /nix/store/xyajc0iyp9z1pkmssfazjjsvw1r9kc68-wayland-1.12.0/lib/libwayland-server.so.0
#9  0x00007f47997c992c in wlc_run () from /nix/store/ia6jgf3yw2nrz0704dbnnk09bcrx6rsj-wlc-0.0.10/lib/libwlc.so.0
#10 0x000000000040bc81 in main ()
#11 0x00007f47974f4560 in __libc_start_main () from /nix/store/yydnhs7migvlbl48wpsxan1yvq2icbr9-glibc-2.25-49/lib/libc.so.6
#12 0x000000000040be3a in _start ()

Do you have something regarding opengl disabled/enabled? What graphic card do you use?

From 5e6491ac2ac33476fdc5afd681ba1c191b118629 Mon Sep 17 00:00:00 2001
From: Joerg Thalheim <joerg@thalheim.io>
Date: Tue, 17 Oct 2017 15:09:42 +0100
Subject: [PATCH] nixos/sway: add module
Signed-off-by: Joerg Thalheim <joerg@thalheim.io>
---
 nixos/modules/module-list.nix   |  1 +
 nixos/modules/programs/sway.nix | 19 +++++++++++++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 nixos/modules/programs/sway.nix
diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix
index a8cb957ffe2..e8fecafb2c8 100644
--- a/nixos/modules/module-list.nix
+++ b/nixos/modules/module-list.nix
@@ -99,6 +99,7 @@
   ./programs/ssh.nix
   ./programs/ssmtp.nix
   ./programs/sysdig.nix
+  ./programs/sway.nix
   ./programs/thefuck.nix
   ./programs/tmux.nix
   ./programs/venus.nix
diff --git a/nixos/modules/programs/sway.nix b/nixos/modules/programs/sway.nix
new file mode 100644
index 00000000000..e0fcd0c1deb
--- /dev/null
+++ b/nixos/modules/programs/sway.nix
@@ -0,0 +1,19 @@
+{ config, pkgs, lib, ... }:
+
+with lib;
+{
+  options.programs.sway.enable = mkEnableOption "sway";
+
+  config = mkIf config.programs.sway.enable {
+    environment.systemPackages = [ pkgs.sway ];
+    security.wrappers.sway = {
+      source = "${pkgs.sway}/bin/sway";
+      capabilities = "cap_sys_ptrace,cap_sys_tty_config=eip";
+      owner = "root";
+      group = "sway";
+      permissions = "u+rx,g+rx";
+    };
+
+    users.extraGroups.sway = {};
+  };
+}
--
2.14.2

@disassembler
Copy link
Member Author

Graphics card is Intel Corporation Haswell-ULT Integrated Graphics Controller (rev 09) I have this in my configuration.nix:

      opengl.enable = true;                                                               
      opengl.extraPackages = [ pkgs.vaapiIntel ];

@Mic92
Copy link
Member

Mic92 commented Oct 17, 2017

I have a Broadwell CPU + graphics. The version here keeps segfaulting while the old version seems to work. Can you make sure, you also tested the updated version and not the old?

@disassembler
Copy link
Member Author

disassembler commented Oct 18, 2017

using programs.sway.enable = true; I get a segfault as well, but if I just put sway and xwayland in environment.systemPackages it works fine for me. Here's the configuration.nix I used: https://gist.github.com/anonymous/6fab3b96d18cf6c808fafc5d0eeb05a5. Command to install was sudo nixos-rebuild switch -I nixpkgs=/home/sam/nixpkgs

proof of newer version of sway running:

sam      28275  1.0  1.5 252592 62856 tty1     S+   21:58   0:03 /run/current-system/sw/bin/sway                                                   
sam      28277  0.0  0.0 177456  1232 tty1     S+   21:58   0:00 /run/current-system/sw/bin/sway                                                   
sam      28279  0.0  0.5 150456 22384 tty1     S+   21:58   0:00 swaybg 0 /nix/store/r4g9pwhs6biyfsyaxxa2vnwbhlfwi8a0-sway-0.14.0/share/sway/Sway_Wallpaper_Blue_1920x1080.png fill
$ ls -hal `which sway`                                                                                                                             
lrwxrwxrwx 1 root root 64 Dec 31  1969 /run/current-system/sw/bin/sway -> /nix/store/r4g9pwhs6biyfsyaxxa2vnwbhlfwi8a0-sway-0.14.0/bin/sway         

@Mic92
Copy link
Member

Mic92 commented Oct 18, 2017

Ok. With xwayland in my systemPackages it works. But adding just adding ${xwayland}/bin in the sway wrapper does not solve the problem. So it must be a different dependency, which gets propagated by this package.

@disassembler
Copy link
Member Author

@Mic92 I tried propagating the buildInputs for wlc, and it works for me now! Can you test?

@disassembler
Copy link
Member Author

I updated the nixos module to include xwayland and things work for me.

@Mic92 Mic92 merged commit e09f070 into NixOS:master Oct 19, 2017
@NeQuissimus
Copy link
Member

Should we pick this into stable?

@Mic92
Copy link
Member

Mic92 commented Oct 19, 2017

Probably a good idea. This capability stuff was security relevant.

@NeQuissimus
Copy link
Member

NeQuissimus commented Oct 19, 2017

I am trying to figure out how this module is supposed to work...
If I enable it and remove everything I have that is XMonad and XServer related, I land on a plain tty1 prompt upon reboot.
I log in, I say sway and it complains about X not running.

Ideally, this module would just replace the xserver module and give me a UI to log in to etc. right?
Am I misunderstanding its purpose?

Also, would it not be better to sit in services next to xserver than in programs?

@ghost
Copy link

ghost commented Oct 19, 2017

@NeQuissimus There were efforts on this, but none got finished and merged:
#19663
#23059

@NeQuissimus
Copy link
Member

Ah, OK.

So if we mixed #19663 with a little bit of #20385 and this one here, we should have all the ingredients to make this work, correct?

@ghost
Copy link

ghost commented Oct 19, 2017

Most likely. Here's someone was able to login via slim #19663 (comment)
It's important not to miss extraSessionCommands, because many things are configured this way starting from https://github.com/swaywm/sway/wiki#input-configuration

@NeQuissimus
Copy link
Member

I mix-and-matched the PRs together but cannot get past SLiM or SDDM...
https://gist.github.com/NeQuissimus/bce7119e985bf077eafc16d9f99bcbcb

@ghost
Copy link

ghost commented Oct 20, 2017

@NeQuissimus Your patch works for me if services.xserver.enable = true;. I'm able to login into sway and it works.
Regarding your patch:

  1. package option is not necessary atm, since there are no sway forks, while there is valuable i3 fork - i3gaps.
  2. Would be nice to also add extraPackages option https://github.com/NixOS/nixpkgs/blob/release-17.09/nixos/modules/services/x11/window-managers/i3.nix#L40 to your patch

@ghost
Copy link

ghost commented Oct 20, 2017

@NeQuissimus Perhaps something is wrong with your setup. If not using your patch:

If I enable it and remove everything I have that is XMonad and XServer related, I land on a plain tty1 prompt upon reboot.
I log in, I say sway and it complains about X not running.

If you disable xserver, then your should add hardware.opengl.enable = true; to your config. But actually you don't need to disable xserver and xmonad to test sway. Just switch to console tty, login and run sway command.

@NeQuissimus
Copy link
Member

NeQuissimus commented Oct 20, 2017

I use this to configure sway: (I import it and have no other xserver-related config)
https://github.com/NeQuissimus/DevSetup/blob/master/nixos-sway.nix

I updated the Gist to reflect your changes.
I still cannot log in... And I see no errors anywhere either.

@ghost
Copy link

ghost commented Oct 20, 2017

@NeQuissimus Thanks. I've took your updated patch and nixos-sway.nix, did

I import it and have no other xserver-related config

the same. And it works fine for me. To debug try following:

  1. Use your normal config with xserver and xmonad
  2. Put programs.sway.enable = true; there, do rebuild
  3. Switch to console tty (ctrl+alt+f1), login here
  4. Run sway -Vd >/tmp/sway.log 2>&1 (you would like to start it via dbus-launch to have bar)

@NeQuissimus
Copy link
Member

I will spend some more time with this over the weekend if I can. Once I have things working, I will send a PR with the contents of my Gist...

@ghost ghost mentioned this pull request Oct 25, 2017
8 tasks
@peterhoeg peterhoeg added this to Non-mainstream DE in Wayland Nov 1, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Wayland
  
Non-mainstream DE
Development

Successfully merging this pull request may close these issues.

None yet

4 participants