gBar/module.nix
Edvin Källström 3b6bafe91a
Add a home-manager nix module (#11)
Add a home-manager module to simplify installation and config management
on nix systems. This greatly reduces the setup time and
makes it integrate better with other programs on nix, mainly Hyprland
which this module is based on.
2023-03-13 21:00:08 +01:00

54 lines
1.4 KiB
Nix

# Based on Hyprland's home-manager and NixOS module
self:
{ config
, lib
, pkgs
, ...
}: let
cfg = config.programs.gBar;
defaultGBarPackage = self.defaultPackage.x86_64-linux;
in {
options.programs.gBar = {
enable = lib.mkEnableOption "Wether to enable gBar, a blazingly fast statusbar written in c++";
package = lib.mkOption {
type = lib.types.nullOr lib.types.package;
default = defaultGBarPackage;
defaultText = lib.literalExpression "<gBar flake>.packages.<system>.default";
example = lib.literalExpression "<gBar flake>.packages.<system>.default.override { }";
description = ''
gBar package to use.
'';
};
extraConfig = lib.mkOption {
type = lib.types.nullOr lib.types.lines;
default = null;
description = ''
Configuration to write to ~/.config/gBar/config, if none nothing happens
'';
};
extraCSS = lib.mkOption {
type = lib.types.nullOr lib.types.lines;
default = null;
description = ''
Configuration to write to ~/.config/gBar/config, if none nothing happens
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = lib.optional (cfg.package != null) cfg.package;
xdg.configFile."gBar/config" = lib.mkIf (cfg.extraConfig != null) {
text = cfg.extraConfig;
};
xdg.configFile."gBar/style.css" = lib.mkIf (cfg.extraCSS != null) {
text = cfg.extraCSS;
};
};
}