From 4379addf9e9bb267a4cbee7ae60cffd3539e714c Mon Sep 17 00:00:00 2001 From: Colin Date: Tue, 27 Feb 2024 16:11:10 +0000 Subject: [PATCH] plumb my configured sway through to everywhere that wants `pkgs.sway`. kinda ugly. this lets me avoid having multiple versions of sway on my system. --- hosts/common/default.nix | 4 ++-- hosts/common/programs/grimshot.nix | 15 +++++++++++++- hosts/common/programs/sway/default.nix | 28 ++++++++++++-------------- hosts/modules/gui/sxmo/default.nix | 23 ++++++++++++++++++--- hosts/modules/gui/sxmo/waybar-top.nix | 10 +-------- 5 files changed, 50 insertions(+), 30 deletions(-) diff --git a/hosts/common/default.nix b/hosts/common/default.nix index 43003fd3..56f1167a 100644 --- a/hosts/common/default.nix +++ b/hosts/common/default.nix @@ -1,4 +1,4 @@ -{ lib, pkgs, ... }: +{ config, lib, pkgs, ... }: { imports = [ ./feeds.nix @@ -49,7 +49,7 @@ # this probably doesn't work if more than one sway session exists on the system. _notifyActiveSwaySock="$(echo /run/user/*/sway-ipc*.sock)" if [ -e "$_notifyActiveSwaySock" ]; then - SWAYSOCK="$_notifyActiveSwaySock" ${pkgs.sway}/bin/swaymsg -- exec \ + SWAYSOCK="$_notifyActiveSwaySock" ${config.sane.programs.sway.packageUnwrapped}/bin/swaymsg -- exec \ "${pkgs.libnotify}/bin/notify-send 'nixos activated' 'version: $(cat $systemConfig/nixos-version)'" fi ''; diff --git a/hosts/common/programs/grimshot.nix b/hosts/common/programs/grimshot.nix index fa700a9d..9d53fd61 100644 --- a/hosts/common/programs/grimshot.nix +++ b/hosts/common/programs/grimshot.nix @@ -1,6 +1,19 @@ -{ ... }: +{ config, pkgs, ... }: { sane.programs."sway-contrib.grimshot" = { + packageUnwrapped = pkgs.sway-contrib.grimshot.override { + # my `sway` is heavily patched to be cross compatible + sway-unwrapped = config.sane.programs.sway.package.sway-unwrapped; + }; + suggestedPrograms = [ + # runtime dependencies (grimshot is just a trivial shell script) + "grim" + "jq" + "libnotify" # only if invoked with `-n` + "slurp" + # "sway" + "wl-clipboard" + ]; sandbox.method = "bwrap"; sandbox.wrapperType = "wrappedDerivation"; sandbox.whitelistWayland = true; diff --git a/hosts/common/programs/sway/default.nix b/hosts/common/programs/sway/default.nix index 4552ca24..bcb550eb 100644 --- a/hosts/common/programs/sway/default.nix +++ b/hosts/common/programs/sway/default.nix @@ -26,25 +26,23 @@ let swayLauncher configuredSway ]; + passthru.sway-unwrapped = configuredSway; }; swayPackage = wrapSway ( - (pkgs.sway-unwrapped.override { + pkgs.sway-unwrapped.override { # wlroots seems to launch Xwayland itself, and i can't easily just do that myself externally. # so in order for the Xwayland it launches to be sandboxed, i need to patch the sandboxed version in here. - wlroots_0_16 = pkgs.wlroots_0_16.override { xwayland = config.sane.programs.xwayland.package; }; - }).overrideAttrs (_: { - # isNixOS = true; #< doesn't matter - # - # about xwayland: - # - required by many electron apps, though some electron apps support NIXOS_OZONE_WL=1 for native wayland. - # - when xwayland is enabled, KOreader incorrectly chooses the X11 backend - # -> slower; blurrier - # - xwayland uses a small amount of memory (like 30MiB, IIRC?) - # - # TODO: something else is dragging a xwayland-enabled wlroots into the environment, - # making this actually kinda wasteful. - enableXWayland = config.sane.programs.xwayland.enabled; - }) + wlroots_0_16 = pkgs.wlroots_0_16.override { + xwayland = config.sane.programs.xwayland.package; + }; + + # about xwayland: + # - required by many electron apps, though some electron apps support NIXOS_OZONE_WL=1 for native wayland. + # - when xwayland is enabled, KOreader incorrectly chooses the X11 backend + # -> slower; blurrier + # - xwayland uses a small amount of memory (like 30MiB, IIRC?) + enableXWayland = config.sane.programs.xwayland.enabled; + } ); in { diff --git a/hosts/modules/gui/sxmo/default.nix b/hosts/modules/gui/sxmo/default.nix index 7a794fd7..0462ad00 100644 --- a/hosts/modules/gui/sxmo/default.nix +++ b/hosts/modules/gui/sxmo/default.nix @@ -85,7 +85,9 @@ let }; rotate = pkgs.static-nix-shell.mkBash { pname = "sxmo_hook_rotate.sh"; - pkgs = [ "sway" ]; + pkgs = { + sway = config.sane.programs.sway.package.sway-unwrapped; + }; srcRoot = ./hooks; }; start = pkgs.static-nix-shell.mkBash { @@ -109,7 +111,10 @@ in }; sane.gui.sxmo.package = mkOption { type = types.package; - default = pkgs.sxmo-utils.override { preferSystemd = true; }; + default = pkgs.sxmo-utils.override { + preferSystemd = true; + sway = config.sane.programs.sway.package.sway-unwrapped; + }; description = '' sxmo base scripts and hooks collection. consider overriding the outputs under /share/sxmo/default_hooks @@ -243,6 +248,7 @@ in "sfeed" # want this here so that the user's ~/.sfeed/sfeedrc gets created # "superd" # make superctl (used by sxmo) be on PATH # "sway-autoscaler" + "waybar-sxmo-status" ]; persist.byStore.cryptClearOnBoot = [ @@ -252,6 +258,17 @@ in ".local/share/sxmo/notifications" # so i can see new SMS messages. not sure actually if this needs persisting or if it'll re-hydrate from modem. ]; }; + + sane.programs.waybar-sxmo-status = { + packageUnwrapped = pkgs.static-nix-shell.mkBash { + pname = "waybar-sxmo-status"; + srcRoot = ./.; + pkgs = { + sxmo-utils = package; + "sxmo-utils.runtimeDeps" = package.runtimeDeps; + }; + }; + }; } { @@ -267,7 +284,7 @@ in { sane.programs.sway.enableFor.user.colin = true; sane.programs.waybar.config = { - top = import ./waybar-top.nix { inherit pkgs; }; + top = import ./waybar-top.nix; # reset extra waybar style extra_style = ""; }; diff --git a/hosts/modules/gui/sxmo/waybar-top.nix b/hosts/modules/gui/sxmo/waybar-top.nix index 80959494..a5a99b00 100644 --- a/hosts/modules/gui/sxmo/waybar-top.nix +++ b/hosts/modules/gui/sxmo/waybar-top.nix @@ -1,14 +1,6 @@ # docs: https://github.com/Alexays/Waybar/wiki/Configuration # format specifiers: https://fmt.dev/latest/syntax.html#syntax # this is merged with the sway/waybar-top.nix defaults -{ pkgs }: -let - waybar-sxmo-status = pkgs.static-nix-shell.mkBash { - pname = "waybar-sxmo-status"; - srcRoot = ./.; - pkgs = [ "sxmo-utils" "sxmo-utils.runtimeDeps" ]; - }; -in { height = 26; @@ -43,7 +35,7 @@ in # so it works even without the "statusbar periodics" sxmo service running. interval = 2; format = "{}"; - exec = "${waybar-sxmo-status}/bin/waybar-sxmo-status modem-state modem-tech modem-signal wifi-status volume"; + exec = "waybar-sxmo-status modem-state modem-tech modem-signal wifi-status volume"; }; "custom/sxmo" = {