158 lines
4 KiB
Nix
158 lines
4 KiB
Nix
self:
|
|
{
|
|
config,
|
|
lib,
|
|
pkgs,
|
|
...
|
|
}:
|
|
let
|
|
cfg = config.programs.nova-shell;
|
|
|
|
stylixAvailable = config ? lib && config.lib ? stylix;
|
|
|
|
stylixTheme =
|
|
let
|
|
c = config.lib.stylix.colors.withHashtag;
|
|
f = config.stylix.fonts;
|
|
in
|
|
{
|
|
colors = {
|
|
inherit (c)
|
|
base00
|
|
base01
|
|
base02
|
|
base03
|
|
base04
|
|
base05
|
|
base06
|
|
base07
|
|
base08
|
|
base09
|
|
base0A
|
|
base0B
|
|
base0C
|
|
base0D
|
|
base0E
|
|
base0F
|
|
;
|
|
};
|
|
fontFamily = f.sansSerif.name;
|
|
fontSize = f.sizes.desktop;
|
|
barOpacity = 1.0 - config.stylix.opacity.desktop;
|
|
iconFontFamily = "Symbols Nerd Font";
|
|
};
|
|
in
|
|
{
|
|
options.programs.nova-shell = {
|
|
enable = lib.mkEnableOption "nova-shell Quickshell bar";
|
|
|
|
package = lib.mkOption {
|
|
type = lib.types.package;
|
|
default = self.packages.${pkgs.stdenv.hostPlatform.system}.default;
|
|
description = "nova-shell package to use.";
|
|
};
|
|
|
|
modules = lib.mkOption {
|
|
description = "Enable or disable individual bar modules.";
|
|
default = { };
|
|
type = lib.types.submodule {
|
|
options = lib.genAttrs
|
|
[
|
|
"workspaces"
|
|
"tray"
|
|
"windowTitle"
|
|
"clock"
|
|
"notifications"
|
|
"mpris"
|
|
"volume"
|
|
"bluetooth"
|
|
"backlight"
|
|
"network"
|
|
"powerProfile"
|
|
"idleInhibitor"
|
|
"weather"
|
|
"temperature"
|
|
"cpu"
|
|
"memory"
|
|
"disk"
|
|
"battery"
|
|
"wlogout"
|
|
]
|
|
(name: lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Enable the ${name} module.";
|
|
});
|
|
};
|
|
};
|
|
|
|
weatherArgs = lib.mkOption {
|
|
type = lib.types.listOf lib.types.str;
|
|
default = [ "--nerd" ];
|
|
description = "Arguments passed to wttrbar.";
|
|
example = [
|
|
"--nerd"
|
|
"--location"
|
|
"Berlin"
|
|
];
|
|
};
|
|
|
|
theme = lib.mkOption {
|
|
type = lib.types.attrsOf lib.types.anything;
|
|
default = { };
|
|
description = ''
|
|
Theme overrides written to `$XDG_CONFIG_HOME/nova-shell/theme.json`.
|
|
Keys: colors (base00-base0F), fontFamily, iconFontFamily, fontSize,
|
|
barOpacity, barHeight, barPadding, barSpacing, moduleSpacing, radius.
|
|
Automatically populated from stylix when it is available.
|
|
'';
|
|
};
|
|
|
|
systemd = {
|
|
enable = lib.mkOption {
|
|
type = lib.types.bool;
|
|
default = true;
|
|
description = "Run nova-shell as a systemd user service.";
|
|
};
|
|
target = lib.mkOption {
|
|
type = lib.types.str;
|
|
default = "graphical-session.target";
|
|
description = "Systemd target to bind the service to.";
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
home.packages =
|
|
[
|
|
self.packages.${pkgs.stdenv.hostPlatform.system}.nova-shell-cli
|
|
pkgs.nerd-fonts.symbols-only
|
|
]
|
|
++ lib.optional cfg.modules.weather pkgs.wttrbar;
|
|
|
|
xdg.configFile."nova-shell/modules.json".source =
|
|
(pkgs.formats.json { }).generate "nova-shell-modules.json"
|
|
(cfg.modules // { weatherArgs = cfg.weatherArgs; });
|
|
|
|
xdg.configFile."nova-shell/theme.json".source =
|
|
let
|
|
stylixDefaults = if stylixAvailable then stylixTheme else { };
|
|
finalTheme = lib.recursiveUpdate stylixDefaults cfg.theme;
|
|
in
|
|
(pkgs.formats.json { }).generate "nova-shell-theme.json" finalTheme;
|
|
|
|
systemd.user.services.nova-shell = lib.mkIf cfg.systemd.enable {
|
|
Unit = {
|
|
Description = "nova-shell Quickshell bar";
|
|
PartOf = [ cfg.systemd.target ];
|
|
After = [ cfg.systemd.target ];
|
|
};
|
|
Service = {
|
|
ExecStart = lib.getExe cfg.package;
|
|
Restart = "on-failure";
|
|
Slice = "session.slice";
|
|
};
|
|
Install.WantedBy = [ cfg.systemd.target ];
|
|
};
|
|
};
|
|
}
|