1 { lib, pkgs, config, ... }:
6 cfg = config.programs.yabar;
8 mapExtra = v: lib.concatStringsSep "\n" (mapAttrsToList (
9 key: val: "${key} = ${if (isString val) then "\"${val}\"" else "${builtins.toString val}"};"
12 listKeys = r: concatStringsSep "," (map (n: "\"${n}\"") (attrNames r));
15 bars = mapAttrsToList (
19 position: "${cfg.position}";
23 block-list: [${listKeys cfg.indicators}]
25 ${concatStringsSep "\n" (mapAttrsToList (
29 align: "${cfg.align}";
37 in pkgs.writeText "yabar.conf" ''
38 bar-list = [${listKeys cfg.bars}];
39 ${concatStringsSep "\n" bars}
43 options.programs.yabar = {
44 enable = mkEnableOption (lib.mdDoc "yabar");
47 default = pkgs.yabar-unstable;
48 defaultText = literalExpression "pkgs.yabar-unstable";
49 example = literalExpression "pkgs.yabar";
52 # `yabar-stable` segfaults under certain conditions.
53 apply = x: if x == pkgs.yabar-unstable then x else flip warn x ''
54 It's not recommended to use `yabar' with `programs.yabar', the (old) stable release
55 tends to segfault under certain circumstances:
57 * https://github.com/geommer/yabar/issues/86
58 * https://github.com/geommer/yabar/issues/68
59 * https://github.com/geommer/yabar/issues/143
61 Most of them don't occur on master anymore, until a new release is published, it's recommended
62 to use `yabar-unstable'.
65 description = lib.mdDoc ''
66 The package which contains the `yabar` binary.
68 Nixpkgs provides the `yabar` and `yabar-unstable`
69 derivations since 18.03, so it's possible to choose.
75 type = types.attrsOf(types.submodule {
78 default = "sans bold 9";
79 example = "Droid Sans, FontAwesome Bold 9";
82 description = lib.mdDoc ''
83 The font that will be used to draw the status bar.
90 type = types.enum [ "top" "bottom" ];
92 description = lib.mdDoc ''
93 The position where the bar will be rendered.
99 type = types.attrsOf types.str;
101 description = lib.mdDoc ''
102 An attribute set which contains further attributes of a bar.
106 indicators = mkOption {
108 type = types.attrsOf(types.submodule {
109 options.exec = mkOption {
110 example = "YABAR_DATE";
112 description = lib.mdDoc ''
113 The type of the indicator to be executed.
117 options.align = mkOption {
120 type = types.enum [ "left" "center" "right" ];
122 description = lib.mdDoc ''
123 Whether to align the indicator at the left or right of the bar.
127 options.extra = mkOption {
129 type = types.attrsOf (types.either types.str types.int);
131 description = lib.mdDoc ''
132 An attribute set which contains further attributes of a indicator.
137 description = lib.mdDoc ''
138 Indicators that should be rendered by yabar.
144 description = lib.mdDoc ''
145 List of bars that should be rendered by yabar.
150 config = mkIf cfg.enable {
151 systemd.user.services.yabar = {
152 description = "yabar service";
153 wantedBy = [ "graphical-session.target" ];
154 partOf = [ "graphical-session.target" ];
157 ${cfg.package}/bin/yabar -c ${configFile}
160 serviceConfig.Restart = "always";