1 { lib, pkgs, config, ... }:
4 cfg = config.programs.yabar;
6 mapExtra = v: lib.concatStringsSep "\n" (lib.mapAttrsToList (
7 key: val: "${key} = ${if (builtins.isString val) then "\"${val}\"" else "${builtins.toString val}"};"
10 listKeys = r: builtins.concatStringsSep "," (builtins.map (n: "\"${n}\"") (builtins.attrNames r));
13 bars = lib.mapAttrsToList (
17 position: "${cfg.position}";
21 block-list: [${listKeys cfg.indicators}]
23 ${builtins.concatStringsSep "\n" (lib.mapAttrsToList (
27 align: "${cfg.align}";
35 in pkgs.writeText "yabar.conf" ''
36 bar-list = [${listKeys cfg.bars}];
37 ${builtins.concatStringsSep "\n" bars}
41 options.programs.yabar = {
42 enable = lib.mkEnableOption "yabar, a status bar for X window managers";
44 package = lib.mkOption {
45 default = pkgs.yabar-unstable;
46 defaultText = lib.literalExpression "pkgs.yabar-unstable";
47 example = lib.literalExpression "pkgs.yabar";
48 type = lib.types.package;
50 # `yabar-stable` segfaults under certain conditions.
51 # remember to update yabar.passthru.tests if nixos switches back to it!
52 apply = x: if x == pkgs.yabar-unstable then x else lib.flip lib.warn x ''
53 It's not recommended to use `yabar' with `programs.yabar', the (old) stable release
54 tends to segfault under certain circumstances:
56 * https://github.com/geommer/yabar/issues/86
57 * https://github.com/geommer/yabar/issues/68
58 * https://github.com/geommer/yabar/issues/143
60 Most of them don't occur on master anymore, until a new release is published, it's recommended
61 to use `yabar-unstable'.
65 The package which contains the `yabar` binary.
67 Nixpkgs provides the `yabar` and `yabar-unstable`
68 derivations since 18.03, so it's possible to choose.
74 type = lib.types.attrsOf(lib.types.submodule {
77 default = "sans bold 9";
78 example = "Droid Sans, FontAwesome Bold 9";
82 The font that will be used to draw the status bar.
86 position = lib.mkOption {
89 type = lib.types.enum [ "top" "bottom" ];
92 The position where the bar will be rendered.
96 extra = lib.mkOption {
98 type = lib.types.attrsOf lib.types.str;
101 An attribute set which contains further attributes of a bar.
105 indicators = lib.mkOption {
107 type = lib.types.attrsOf(lib.types.submodule {
108 options.exec = lib.mkOption {
109 example = "YABAR_DATE";
110 type = lib.types.str;
112 The type of the indicator to be executed.
116 options.align = lib.mkOption {
119 type = lib.types.enum [ "left" "center" "right" ];
122 Whether to align the indicator at the left or right of the bar.
126 options.extra = lib.mkOption {
128 type = lib.types.attrsOf (lib.types.either lib.types.str lib.types.int);
131 An attribute set which contains further attributes of a indicator.
137 Indicators that should be rendered by yabar.
144 List of bars that should be rendered by yabar.
149 config = lib.mkIf cfg.enable {
150 systemd.user.services.yabar = {
151 description = "yabar service";
152 wantedBy = [ "graphical-session.target" ];
153 partOf = [ "graphical-session.target" ];
156 ${cfg.package}/bin/yabar -c ${configFile}
159 serviceConfig.Restart = "always";