87 lines
2.4 KiB
Nix
87 lines
2.4 KiB
Nix
# Home Manager module for barbar.
|
|
#
|
|
# imports = [ inputs.barbar.homeManagerModules.default ];
|
|
#
|
|
# Generates barbar.toml from `programs.barbar.settings` and runs the bar as a
|
|
# systemd user service bound to the graphical session.
|
|
self:
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.programs.barbar;
|
|
toml = pkgs.formats.toml { };
|
|
configFile = toml.generate "barbar.toml" cfg.settings;
|
|
in
|
|
{
|
|
options.programs.barbar = {
|
|
enable = lib.mkEnableOption "barbar, a Wayland layer-shell status bar";
|
|
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
|
defaultText = lib.literalExpression "barbar.packages.\${system}.default";
|
|
description = "The barbar package to run.";
|
|
};
|
|
|
|
settings = lib.mkOption {
|
|
type = toml.type;
|
|
default.order = {
|
|
left = [ ];
|
|
middle = [ ];
|
|
right = [ ];
|
|
};
|
|
defaultText = lib.literalExpression ''{ order = { left = [ ]; middle = [ ]; right = [ ]; }; }'';
|
|
description = ''
|
|
Contents of barbar.toml, written verbatim. Only `order` is required by
|
|
barbar; `[display]`, `[modules.*]` and `[services.*]` are optional.
|
|
See test.toml in the barbar repo for the full schema.
|
|
'';
|
|
example = lib.literalExpression ''
|
|
{
|
|
display = {
|
|
monitor = "DP-2";
|
|
height = 24;
|
|
};
|
|
order = {
|
|
left = [ "workspaces" "weather" ];
|
|
middle = [ ];
|
|
right = [ "clock" ];
|
|
};
|
|
modules.clock.show_seconds = false;
|
|
}
|
|
'';
|
|
};
|
|
|
|
systemd.enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Run barbar as a systemd user service.";
|
|
};
|
|
|
|
systemd.target = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "graphical-session.target";
|
|
description = "Systemd target the bar is bound to.";
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
systemd.user.services.barbar = lib.mkIf cfg.systemd.enable {
|
|
Unit = {
|
|
Description = "barbar status bar";
|
|
After = [ cfg.systemd.target ];
|
|
PartOf = [ cfg.systemd.target ];
|
|
};
|
|
Service = {
|
|
ExecStart = "${lib.getExe' cfg.package "core"} --config ${configFile}";
|
|
Restart = "on-failure";
|
|
};
|
|
Install.WantedBy = [ cfg.systemd.target ];
|
|
};
|
|
};
|
|
}
|