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.
This commit is contained in:
Colin 2024-02-27 16:11:10 +00:00
parent 5c7eceeb55
commit 4379addf9e
5 changed files with 50 additions and 30 deletions

View File

@ -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
'';

View File

@ -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;

View File

@ -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
{

View File

@ -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 = "";
};

View File

@ -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" = {