From 4a3d24be3fc301d922fa843bb00737050aac3451 Mon Sep 17 00:00:00 2001 From: Colin Date: Thu, 15 Feb 2024 07:18:12 +0000 Subject: [PATCH] waybar: migrate all config to "sane.programs" --- hosts/common/programs/default.nix | 2 +- hosts/common/programs/waybar.nix | 25 ------- hosts/common/programs/waybar/default.nix | 74 +++++++++++++++++++ .../programs/waybar}/waybar-media | 0 .../programs/waybar}/waybar-style.css | 0 .../programs/waybar}/waybar-top.nix | 0 hosts/modules/gui/sway/default.nix | 44 ----------- hosts/modules/gui/sxmo/default.nix | 8 +- 8 files changed, 80 insertions(+), 73 deletions(-) delete mode 100644 hosts/common/programs/waybar.nix create mode 100644 hosts/common/programs/waybar/default.nix rename hosts/{modules/gui/sway => common/programs/waybar}/waybar-media (100%) rename hosts/{modules/gui/sway => common/programs/waybar}/waybar-style.css (100%) rename hosts/{modules/gui/sway => common/programs/waybar}/waybar-top.nix (100%) diff --git a/hosts/common/programs/default.nix b/hosts/common/programs/default.nix index bb5c2e82..ca3665ea 100644 --- a/hosts/common/programs/default.nix +++ b/hosts/common/programs/default.nix @@ -86,7 +86,7 @@ ./tor-browser.nix ./tuba.nix ./vlc.nix - ./waybar.nix + ./waybar ./waylock.nix ./wike.nix ./wine.nix diff --git a/hosts/common/programs/waybar.nix b/hosts/common/programs/waybar.nix deleted file mode 100644 index d9dbcdfc..00000000 --- a/hosts/common/programs/waybar.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ config, ... }: -let - cfg = config.sane.programs.waybar; -in -{ - sane.programs.waybar = { - sandbox.method = "bwrap"; - sandbox.wrapperType = "wrappedDerivation"; - sandbox.net = "all"; #< to show net connection status and BW - sandbox.whitelistDbus = [ "user" ]; - sandbox.whitelistWayland = true; - sandbox.extraRuntimePaths = [ "/" ]; #< needs to talk to sway IPC. TODO: give the sway IPC a predictable name. - sandbox.extraHomePaths = [ ".config/waybar" ]; #< TODO: migrate config files to this file and then safe to remove - - services.waybar = { - description = "sway header bar"; - wantedBy = [ "graphical-session.target" ]; - serviceConfig.ExecStart = "${cfg.package}/bin/waybar"; - serviceConfig.Type = "simple"; - serviceConfig.Restart = "on-failure"; - serviceConfig.RestartSec = "10s"; - # environment.G_MESSAGES_DEBUG = "all"; - }; - }; -} diff --git a/hosts/common/programs/waybar/default.nix b/hosts/common/programs/waybar/default.nix new file mode 100644 index 00000000..8134fbc0 --- /dev/null +++ b/hosts/common/programs/waybar/default.nix @@ -0,0 +1,74 @@ +{ config, lib, pkgs, ... }: +let + cfg = config.sane.programs.waybar; +in +{ + sane.programs.waybar = { + configOption = with lib; mkOption { + type = types.submodule { + options = { + extra_style = mkOption { + type = types.lines; + default = '' + /* default font-size is about 14px, which is good for moby, but not quite for larger displays */ + window#waybar { + font-size: 16px; + } + ''; + description = '' + extra CSS rules to append to ~/.config/waybar/style.css + ''; + }; + top = mkOption { + type = types.submodule { + # `attrsOf types.anything` (v.s. plain `attrs`) causes merging of the toplevel items. + # this allows for `waybar.top.x = lib.mkDefault a;` with `waybar.top.x = b;` to resolve to `b`. + # but note that `waybar.top.x.y = ` won't be handled as desired. + freeformType = types.attrsOf types.anything; + }; + default = {}; + description = '' + Waybar configuration for the bar at the top of the display. + see: + example: + ```nix + { + height = 40; + modules-left = [ "sway/workspaces" "sway/mode" ]; + ... + } + ``` + ''; + }; + }; + }; + }; + + # default waybar + config.top = import ./waybar-top.nix { inherit lib pkgs; }; + + sandbox.method = "bwrap"; + sandbox.wrapperType = "wrappedDerivation"; + sandbox.net = "all"; #< to show net connection status and BW + sandbox.whitelistDbus = [ "user" ]; + sandbox.whitelistWayland = true; + sandbox.extraRuntimePaths = [ "/" ]; #< needs to talk to sway IPC. TODO: give the sway IPC a predictable name. + + fs.".config/waybar/config".symlink.target = + (pkgs.formats.json {}).generate "waybar-config.json" [ + ({ layer = "top"; } // cfg.config.top) + ]; + fs.".config/waybar/style.css".symlink.text = + (builtins.readFile ./waybar-style.css) + cfg.config.extra_style; + + services.waybar = { + description = "sway header bar"; + wantedBy = [ "graphical-session.target" ]; + serviceConfig.ExecStart = "${cfg.package}/bin/waybar"; + serviceConfig.Type = "simple"; + serviceConfig.Restart = "on-failure"; + serviceConfig.RestartSec = "10s"; + # environment.G_MESSAGES_DEBUG = "all"; + }; + }; +} diff --git a/hosts/modules/gui/sway/waybar-media b/hosts/common/programs/waybar/waybar-media similarity index 100% rename from hosts/modules/gui/sway/waybar-media rename to hosts/common/programs/waybar/waybar-media diff --git a/hosts/modules/gui/sway/waybar-style.css b/hosts/common/programs/waybar/waybar-style.css similarity index 100% rename from hosts/modules/gui/sway/waybar-style.css rename to hosts/common/programs/waybar/waybar-style.css diff --git a/hosts/modules/gui/sway/waybar-top.nix b/hosts/common/programs/waybar/waybar-top.nix similarity index 100% rename from hosts/modules/gui/sway/waybar-top.nix rename to hosts/common/programs/waybar/waybar-top.nix diff --git a/hosts/modules/gui/sway/default.nix b/hosts/modules/gui/sway/default.nix index 7d5da8a9..d417d183 100644 --- a/hosts/modules/gui/sway/default.nix +++ b/hosts/modules/gui/sway/default.nix @@ -121,40 +121,6 @@ in description = "command to run when user wants to take a screenshot"; }; }; - # TODO: move to hosts/common/programs/waybar.nix - sane.gui.sway.waybar.extra_style = mkOption { - type = types.lines; - default = '' - /* default font-size is about 14px, which is good for moby, but not quite for larger displays */ - window#waybar { - font-size: 16px; - } - ''; - description = '' - extra CSS rules to append to ~/.config/waybar/style.css - ''; - }; - sane.gui.sway.waybar.top = mkOption { - type = types.submodule { - # `attrsOf types.anything` (v.s. plain `attrs`) causes merging of the toplevel items. - # this allows for `waybar.top.x = lib.mkDefault a;` with `waybar.top.x = b;` to resolve to `b`. - # but note that `waybar.top.x.y = ` won't be handled as desired. - freeformType = types.attrsOf types.anything; - }; - default = {}; - description = '' - Waybar configuration for the bar at the top of the display. - see: - example: - ```nix - { - height = 40; - modules-left = [ "sway/workspaces" "sway/mode" ]; - ... - } - ``` - ''; - }; }; config = lib.mkMerge [ @@ -203,9 +169,6 @@ in secrets.".config/sane-sway/snippets.txt" = ../../../../secrets/common/snippets.txt.bin; }; - - # default waybar - sane.gui.sway.waybar.top = import ./waybar-top.nix { inherit lib pkgs; }; } (lib.mkIf cfg.enable { @@ -354,13 +317,6 @@ in [preferred] default=wlr;gtk ''; - ".config/waybar/config".symlink.target = - (pkgs.formats.json {}).generate "waybar-config.json" [ - ({ layer = "top"; } // cfg.waybar.top) - ]; - - ".config/waybar/style.css".symlink.text = - (builtins.readFile ./waybar-style.css) + cfg.waybar.extra_style; ".config/sway/config".symlink.target = pkgs.callPackage ./sway-config.nix { inherit config; diff --git a/hosts/modules/gui/sxmo/default.nix b/hosts/modules/gui/sxmo/default.nix index 97cbdd99..43d06b90 100644 --- a/hosts/modules/gui/sxmo/default.nix +++ b/hosts/modules/gui/sxmo/default.nix @@ -294,14 +294,16 @@ in (lib.mkIf cfg.enable (lib.mkMerge [ { + sane.programs.waybar.config = { + top = import ./waybar-top.nix { inherit pkgs; }; + # reset extra waybar style + extra_style = ""; + }; sane.gui.sway = { enable = true; # we manage the greeter ourselves (TODO: merge this into sway config as well) # EXCEPT for the unl0kr case, since that works well on both mobile and desktop! useGreeter = cfg.greeter == "unl0kr"; - waybar.top = import ./waybar-top.nix { inherit pkgs; }; - # reset extra waybar style - waybar.extra_style = ""; config = { # N.B. missing from upstream sxmo config here is: # - `bindsym $mod+g exec sxmo_hook_locker.sh`