From bfdd94bf7ee040e00158f6b18da149978f3045b2 Mon Sep 17 00:00:00 2001 From: kat witch Date: Tue, 2 Mar 2021 22:27:58 +0000 Subject: [PATCH] Screenstub derivation. Murmur. --- config/hosts/athame/configuration.nix | 5 +- config/hosts/athame/murmur.nix | 23 ++++ config/hosts/samhain/configuration.nix | 1 + config/private | 2 +- pkgs/default.nix | 4 +- pkgs/screenstub/default.nix | 29 +++++ pkgs/screenstub/main.patch | 142 +++++++++++++++++++++++++ 7 files changed, 202 insertions(+), 4 deletions(-) create mode 100644 config/hosts/athame/murmur.nix create mode 100644 pkgs/screenstub/default.nix create mode 100644 pkgs/screenstub/main.patch diff --git a/config/hosts/athame/configuration.nix b/config/hosts/athame/configuration.nix index 50a70e25..b5b16f06 100644 --- a/config/hosts/athame/configuration.nix +++ b/config/hosts/athame/configuration.nix @@ -17,6 +17,7 @@ ./nextcloud.nix ./bitwarden.nix # comms + ./murmur.nix ./znc.nix ./weechat.nix ./matrix.nix @@ -37,8 +38,8 @@ interfaces.enp1s0.useDHCP = true; }; - networking.firewall.allowedTCPPorts = [ 80 443 5160 5060 ]; - networking.firewall.allowedUDPPorts = [ 5160 5060 ]; + networking.firewall.allowedTCPPorts = [ 80 443 5160 5060 64738 ]; + networking.firewall.allowedUDPPorts = [ 5160 5060 64738 ]; networking.firewall.allowedTCPPortRanges = [{ from = 10000; to = 20000; diff --git a/config/hosts/athame/murmur.nix b/config/hosts/athame/murmur.nix new file mode 100644 index 00000000..6fa9c61e --- /dev/null +++ b/config/hosts/athame/murmur.nix @@ -0,0 +1,23 @@ +{ config, pkgs, ... }: + +let secrets = (import ../../../secrets.nix); +in { + security.acme = { + certs."kittywit.ch" = { + group = "kittywit-ch"; + }; + }; + + users.groups."kittywit-ch".members = ["murmur" "nginx"]; + + services.murmur = { + enable = true; + + hostName = "kittywit.ch"; + + extraConfig = '' + sslCert=/var/lib/acme/kittywit.ch/fullchain.pem + sslKey=/var/lib/acme/kittywit.ch/key.pem + ''; + }; +} diff --git a/config/hosts/samhain/configuration.nix b/config/hosts/samhain/configuration.nix index 21549fef..6fab15e4 100644 --- a/config/hosts/samhain/configuration.nix +++ b/config/hosts/samhain/configuration.nix @@ -67,6 +67,7 @@ in { environment.systemPackages = [ # pkgs.nur.repos.arc.packages.screenstub # for DDC/CI and input forwarding (currently disabled due to using changed source) pkgs.arc.pkgs.scream-arc # for audio forwarding + pkgs.screenstub # for input handling pkgs.ddcutil # for diagnostics on DDC/CI pkgs.virt-manager # obvious reasons ]; diff --git a/config/private b/config/private index 933f5058..49b90f76 160000 --- a/config/private +++ b/config/private @@ -1 +1 @@ -Subproject commit 933f5058c9942bfd51812cd0beaaf9b61a8205b7 +Subproject commit 49b90f76775092bf2545db515c15afe596e4d6eb diff --git a/pkgs/default.nix b/pkgs/default.nix index cc788996..7488ad26 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,7 +4,7 @@ let sources = import ../nix/sources.nix; pkgs = import sources.nixpkgs args; - overlay = self: super: { + overlay = self: super: rec { dino = super.callPackage "${sources.qyliss-nixlib}/overlays/patches/dino" { inherit (super) dino; }; @@ -15,6 +15,8 @@ let unstable = import sources.nixpkgs-unstable { inherit (self) config; }; nur = import sources.NUR { nurpkgs = self; pkgs = self; }; + screenstub = unstable.callPackage ./screenstub { }; + linuxPackagesFor = kernel: (super.linuxPackagesFor kernel).extend (_: ksuper: { vendor-reset = diff --git a/pkgs/screenstub/default.nix b/pkgs/screenstub/default.nix new file mode 100644 index 00000000..b5f2e518 --- /dev/null +++ b/pkgs/screenstub/default.nix @@ -0,0 +1,29 @@ +{ + fetchFromGitHub + , rustPlatform + , pkg-config + , lib + , libxcb + , udev + , python3 +}: rustPlatform.buildRustPackage rec { + pname = "screenstub"; + version = "2021-01-08"; + src = fetchFromGitHub { + owner = "arcnmx"; + repo = pname; + rev = "e379279fedaaa1d06b1d89da4cf54752814a456f"; + sha256 = "0qv15rpazrpdspfcvyizbjdrrm2nrqz0790pa8zvp5bjsw4mvwvx"; + }; + + patches = [ + ./main.patch + ]; + + nativeBuildInputs = [ pkg-config python3 ]; + buildInputs = [ libxcb udev ]; + + cargoSha256 = "0yijg5v731n49ygav2cfiawnw84hxd6kvik5hmz544vikxj96bj4"; + + doCheck = false; + } \ No newline at end of file diff --git a/pkgs/screenstub/main.patch b/pkgs/screenstub/main.patch new file mode 100644 index 00000000..7ed86bd0 --- /dev/null +++ b/pkgs/screenstub/main.patch @@ -0,0 +1,142 @@ +diff --git a/qemu/src/lib.rs b/qemu/src/lib.rs +index 6a84bd4..d83cc49 100644 +--- a/qemu/src/lib.rs ++++ b/qemu/src/lib.rs +@@ -137,7 +137,7 @@ impl Qemu { + match events.recv().await { + Ok(qapi::qmp::Event::DEVICE_DELETED { ref data, .. }) if data.device.as_ref() == Some(&id) => { + // work around qemu bug. without this delay, device_add will work but the new device might be immediately deleted +- sleep(Duration::from_millis(128)).await; ++ sleep(Duration::from_millis(256)).await; + + break Ok(()) + }, +diff --git a/src/main.rs b/src/main.rs +index 3dc30a2..ed87aaa 100644 +--- a/src/main.rs ++++ b/src/main.rs +@@ -161,8 +161,8 @@ async fn main_result(spawner: &Arc) -> Result { + }; + + let repeat = false; +- let bus = None; +- let mut route_keyboard = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-kbd".into(), bus.clone(), repeat); ++ //let bus = None; ++ let mut route_keyboard = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-kbd".into(), Some("pci.23".into()), repeat); + if let Some(builder) = route_keyboard.builder() { + builder + .name("screenstub-kbd") +@@ -171,7 +171,7 @@ async fn main_result(spawner: &Arc) -> Result { + } + let mut events_keyboard = route_keyboard.spawn(spawner, error_sender.clone()); + +- let mut route_relative = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-mouse".into(), bus.clone(), repeat); ++ let mut route_relative = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-mouse".into(), Some("pci.22".into()), repeat); + if let Some(builder) = route_relative.builder() { + builder + .name("screenstub-mouse") +@@ -180,7 +180,7 @@ async fn main_result(spawner: &Arc) -> Result { + } + let mut events_relative = route_relative.spawn(spawner, error_sender.clone()); + +- let mut route_absolute = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-tablet".into(), bus, repeat); ++ let mut route_absolute = Route::new(config.qemu.routing, qemu.clone(), "screenstub-route-tablet".into(), Some("pci.21".into()), repeat); + if let Some(builder) = route_absolute.builder() { + builder + .name("screenstub-tablet") +diff --git a/src/route.rs b/src/route.rs +index 0448b52..417c197 100644 +--- a/src/route.rs ++++ b/src/route.rs +@@ -180,12 +180,10 @@ pub struct RouteUInputVirtio { + + impl UInputCommands for RouteUInputVirtio { + fn command_create(&self, qemu: &Arc, path: &Path) -> Pin> + Send>> { +- let name = match self.bus.is_some() { +- true => "virtio-input-host-device", // TODO: double-check this, what is the virtio bus for? +- false => "virtio-input-host-pci", +- }; +- let command = qmp::device_add::new(name, Some(self.id.clone()), self.bus.clone(), vec![ ++ let name = "virtio-input-host-pci"; ++ let command = qmp::device_add::new(name,Some(self.id.clone()) , self.bus.clone(), vec![ + ("evdev".into(), Any::String(path.display().to_string())), ++ //("addr".into(), Any::String("3".to_string())) + ]); + let deadline = Instant::now() + Duration::from_millis(512); // HACK: wait for udev to see device and change permissions + let qemu = qemu.clone(); +@@ -213,12 +211,15 @@ pub struct RouteUInputInputLinux { + impl UInputCommands for RouteUInputInputLinux { + fn command_create(&self, qemu: &Arc, path: &Path) -> Pin> + Send>> { + let path = path.display(); +- let command = qmp::object_add::new(&self.id, "input-linux", vec![ ++ let command = qmp::object_add::new("input-linux", &self.id, vec![ + ("evdev".into(), Any::String(path.to_string())), + ("repeat".into(), Any::Bool(self.repeat)), + ]); + let qemu = qemu.clone(); ++ let id_ = self.id.clone(); + async move { ++ let _ = qemu.execute_qmp(qmp::object_del { id: id_ }).await; ++ tokio::time::sleep(Duration::from_millis(512)).await; + qemu.execute_qmp(command).map_ok(drop).await + }.boxed() + } +@@ -283,7 +284,7 @@ pub enum Route { + impl Route { + pub fn new(routing: ConfigQemuRouting, qemu: Arc, id: String, bus: Option, repeat: bool) -> Self { + match routing { +- ConfigQemuRouting::InputLinux => Route::InputLinux(RouteUInput::new_input_linux(qemu, id, repeat)), ++ ConfigQemuRouting::InputLinux => Route::InputLinux(RouteUInput::new_input_linux(qemu, id, false)), + ConfigQemuRouting::VirtioHost => Route::VirtioHost(RouteUInput::new_virtio_host(qemu, id, bus)), + ConfigQemuRouting::Qmp => Route::Qmp(RouteQmp::new(qemu)), + ConfigQemuRouting::Spice => unimplemented!("SPICE routing"), +diff --git a/x/src/lib.rs b/x/src/lib.rs +index a517922..c37b951 100644 +--- a/x/src/lib.rs ++++ b/x/src/lib.rs +@@ -88,7 +88,7 @@ pub struct XContext { + window: xcore::Window, + ext_input: xcore::QueryExtensionReply, + ext_test: xcore::QueryExtensionReply, +- ext_dpms: xcore::QueryExtensionReply, ++// ext_dpms: xcore::QueryExtensionReply, + ext_xkb: xcore::QueryExtensionReply, + setup: xcore::Setup, + +@@ -128,8 +128,8 @@ impl XContext { + .expect("XKB required"); + let ext_test = sink.extension(ExtensionKind::Test).await.await? + .expect("XTest required"); +- let ext_dpms = sink.extension(ExtensionKind::DPMS).await.await? +- .expect("DPMS required"); ++ // let ext_dpms = sink.extension(ExtensionKind::DPMS).await.await? ++// .expect("DPMS required"); + let _ = sink.execute(xinput::XIQueryVersionRequest { + major_opcode: ext_input.major_opcode, + major_version: 2, +@@ -211,7 +211,7 @@ impl XContext { + ext_input, + ext_test, + ext_xkb, +- ext_dpms, ++ // ext_dpms, + display, + + sink, +@@ -506,13 +506,14 @@ impl XContext { + + Ok(match event { + ExtensionEvent::Core(xcore::Events::VisibilityNotify(event)) => { +- let dpms_blank = { ++/* let dpms_blank = { + let info = self.sink.execute(dpms::InfoRequest { + major_opcode: self.ext_dpms.major_opcode, + }).await.await?; + + info.power_level.get() != dpms::DPMSMode::On +- }; ++ };*/ ++ let dpms_blank = false; + self.event_queue.push(if dpms_blank { + XEvent::Visible(false) + } else {