nix-files/hosts/common/programs/waybar/default.nix

121 lines
3.9 KiB
Nix
Raw Normal View History

{ config, lib, pkgs, ... }:
let
cfg = config.sane.programs.waybar;
mkEnableOption' = default: description: lib.mkOption {
type = lib.types.bool;
inherit default description;
};
in
{
sane.programs.waybar = {
configOption = with lib; mkOption {
type = types.submodule {
options = {
extraStyle = mkOption {
type = types.lines;
default = "";
description = ''
extra CSS rules to append to ~/.config/waybar/style.css
'';
};
fontSize = mkOption {
type = types.int;
default = 16;
description = ''
default font-size is about 14px, which is good for moby, but not quite for larger displays
'';
};
2024-03-01 05:20:28 +00:00
height = mkOption {
type = types.int;
default = 40;
description = ''
height of the top bar in px.
'';
};
persistWorkspaces = mkOption {
type = types.listOf types.str;
default = [];
description = ''
list of workspaces to always show, e.g. [ "1" "7" ]
'';
};
modules.windowTitle = mkEnableOption' true "display window title in center";
modules.media = mkEnableOption' true "display current track on right";
modules.perf = mkEnableOption' true "display RAM, CPU on right";
modules.network = mkEnableOption' true "display IP traffic on right";
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 = <multiple assignment>` 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: <https://github.com/Alexays/Waybar/wiki/Configuration>
example:
```nix
{
height = 40;
modules-left = [ "sway/workspaces" "sway/mode" ];
...
}
```
'';
};
};
};
};
# default waybar
2024-03-01 05:20:28 +00:00
config.top = pkgs.callPackage ./waybar-top.nix { } {
inherit (cfg.config) height modules persistWorkspaces;
2024-03-01 05:20:28 +00:00
};
packageUnwrapped = pkgs.waybar.override {
# not *required*, however this does cut down on some cross-compilation issues
# and also avoids building entirely unused dependencies
sway = config.sane.programs.sway.package.sway-unwrapped;
nixpkgs: 2024-05-16 -> 2024-05-23, nixpkgs-wayland, sops-nix, uninsane-dot-org ``` • Updated input 'nixpkgs-next-unpatched': 'github:nixos/nixpkgs/1887e39d7e68bb191eb804c0f976ad25b3980595' (2024-05-16) → 'github:nixos/nixpkgs/?' (2024-05-23) • Updated input 'nixpkgs-unpatched': 'github:nixos/nixpkgs/977a49df312d89b7dfbb3579bf13b7dfe23e7878' (2024-05-16) → 'github:nixos/nixpkgs/?' (2024-05-23) • Updated input 'nixpkgs-wayland': 'github:nix-community/nixpkgs-wayland/5e2c5345f3204c867c9d4183cbb68069d0f7a951' (2024-05-16) → 'github:nix-community/nixpkgs-wayland/?' (2024-05-23) • Updated input 'nixpkgs-wayland/lib-aggregate': 'github:nix-community/lib-aggregate/09883ca828e8cfaacdb09e29190a7b84ad1d9925' (2024-05-12) → 'github:nix-community/lib-aggregate/5fa64b174daa22fe0d20ebbcc0ec2c7905b503f1' (2024-05-19) • Updated input 'nixpkgs-wayland/lib-aggregate/nixpkgs-lib': 'github:nix-community/nixpkgs.lib/58e03b95f65dfdca21979a081aa62db0eed6b1d8' (2024-05-12) → 'github:nix-community/nixpkgs.lib/0df131b5ee4d928a4b664b6d0cd99cf134d6ab6b' (2024-05-19) • Updated input 'sops-nix': 'github:Mic92/sops-nix/b6cb5de2ce57acb10ecdaaf9bbd62a5ff24fa02e' (2024-05-12) → 'github:Mic92/sops-nix/b549832718b8946e875c016a4785d204fcfc2e53' (2024-05-22) • Updated input 'sops-nix/nixpkgs-stable': 'github:NixOS/nixpkgs/8e47858badee5594292921c2668c11004c3b0142' (2024-05-11) → 'github:NixOS/nixpkgs/e7cc61784ddf51c81487637b3031a6dd2d6673a2' (2024-05-18) • Updated input 'uninsane-dot-org': 'git+https://git.uninsane.org/colin/uninsane?ref=refs/heads/master&rev=af8420d1c256d990b5e24de14ad8592a5d85bf77' (2024-04-15) → 'git+https://git.uninsane.org/colin/uninsane?ref=refs/heads/master&rev=e6f88f563bdd1700c04018951de4f69862646dd1' (2024-05-16) ```
2024-05-23 11:20:09 +00:00
hyprlandSupport = false; #< doesn't cross. hyprland clowns are forking deps even like `wayland-scanner`, too much maintenance.
};
sandbox.method = "bwrap";
sandbox.net = "all"; #< to show net connection status and BW
sandbox.whitelistDbus = [
"user" #< for playerctl/media
"system" #< for modem (on phone)
];
sandbox.whitelistWayland = true;
sandbox.extraRuntimePaths = [
2024-03-23 11:33:58 +00:00
"sway"
];
sandbox.extraPaths = [
2024-05-27 00:38:30 +00:00
# for wifi status on phone
# "/dev/rfkill"
# for the battery indicator
"/sys/class/power_supply"
"/sys/devices"
];
fs.".config/waybar/config".symlink.target =
(pkgs.formats.json {}).generate "waybar-config.json" [
({ layer = "top"; } // cfg.config.top)
];
fs.".config/waybar/style.css".symlink.target = pkgs.substituteAll {
src = ./waybar-style.css;
inherit (cfg.config) extraStyle fontSize;
};
services.waybar = {
2024-06-14 03:42:28 +00:00
description = "waybar status/topbar for sway";
partOf = [ "graphical-session" ];
# env G_MESSAGES_DEBUG=all
command = "waybar";
};
};
}