1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 03:29:45 +01:00

eww: added improvements

eww: added config options & made all config options all optional

eww: added tests

eww: fix nullOr type

eww: fix configScss and configYuck home files

eww: fix configYuck home file

eww: fix xdg.configfile

eww: fix service tests

eww: added enable options and removed deprecation for config dir

ewww: added myself to maintainers

I did this as @mainrs seems to not be very much active as based on his
commits and pr comments previously.

cc @rycee: should I remove him as a maintainer on this package?

eww: removed a re-define in bash completion

eww: fix yuck conf

chore: removed enable options from all config options

eww: added config next to yuck and scss
This commit is contained in:
eveeifyeve 2024-10-20 21:30:14 +11:00
parent 122f70545b
commit 115bb77f08
5 changed files with 167 additions and 23 deletions

View file

@ -3,12 +3,10 @@
with lib; with lib;
let let
cfg = config.programs.eww; cfg = config.programs.eww;
ewwCmd = "${cfg.package}/bin/eww"; ewwCmd = "${cfg.package}/bin/eww";
in { in {
meta.maintainers = [ hm.maintainers.mainrs ]; meta.maintainers = [ hm.maintainers.mainrs maintainers.eveeifyeve ];
options.programs.eww = { options.programs.eww = {
enable = mkEnableOption "eww"; enable = mkEnableOption "eww";
@ -23,8 +21,46 @@ in {
''; '';
}; };
yuckConfig = mkOption {
type = types.nullOr types.lines;
default = null;
example = ''
(defwindow example
:monitor 0
:geometry (geometry :x "0%"
:y "20px"
:width "90%"
:height "30px"
:anchor "top center")
:stacking "fg"
:reserve (struts :distance "40px" :side "top")
:windowtype "dock"
:wm-ignore false
"example content")
'';
description = ''
The content that gets symlinked to
{file} `$XDG_CONFIG_HOME/eww/eww.yuck`.
'';
};
scssConfig = mkOption {
type = types.nullOr types.lines;
default = null;
example = ''
window {
background: pink;
}
'';
description = ''
The directory that gets symlinked to
{file} `$XDG_CONFIG_HOME/eww/eww.scss`.
'';
};
configDir = mkOption { configDir = mkOption {
type = types.path; type = types.nullOr types.path;
default = null;
example = literalExpression "./eww-config-dir"; example = literalExpression "./eww-config-dir";
description = '' description = ''
The directory that gets symlinked to The directory that gets symlinked to
@ -32,6 +68,21 @@ in {
''; '';
}; };
systemd.enable = mkEnableOption "Launches Eww Daemon";
systemd.target = mkOption {
type = types.str;
default = "graphical-session.target";
example = "sway-session.target";
description = ''
The systemd target that will automatically start the Eww service.
When setting this value to `"sway-session.target"`,
make sure to also enable {option}`wayland.windowManager.sway.systemd.enable`,
otherwise the service may never be started.
'';
};
enableBashIntegration = mkEnableOption "Bash integration" // { enableBashIntegration = mkEnableOption "Bash integration" // {
default = true; default = true;
}; };
@ -45,26 +96,66 @@ in {
}; };
}; };
config = mkIf cfg.enable { config = mkIf cfg.enable (mkMerge [
home.packages = [ cfg.package ]; {
xdg.configFile."eww".source = cfg.configDir; assertions =
let message = "You can have either yuck & scss or configDir enabled";
in [
{
assertion = !(cfg.scssConfig == null && cfg.configDir == null);
inherit message;
}
{
assertion = !(cfg.yuckConfig == null && cfg.configDir == null);
inherit message;
}
];
programs.bash.initExtra = mkIf cfg.enableBashIntegration '' home.packages = [ cfg.package ];
if [[ $TERM != "dumb" ]]; then
eval "$(${ewwCmd} shell-completions --shell bash)"
fi
'';
programs.zsh.initExtra = mkIf cfg.enableZshIntegration '' programs.bash.initExtra = mkIf cfg.enableBashIntegration ''
if [[ $TERM != "dumb" ]]; then if [[ $TERM != "dumb" ]]; then
eval "$(${ewwCmd} shell-completions --shell zsh)" eval "$(${ewwCmd} shell-completions --shell bash)"
fi fi
''; '';
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration '' programs.zsh.initExtra = mkIf cfg.enableZshIntegration ''
if test "$TERM" != "dumb" if [[ $TERM != "dumb" ]]; then
eval "$(${ewwCmd} shell-completions --shell fish)" eval "$(${ewwCmd} shell-completions --shell zsh)"
end fi
''; '';
};
programs.fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
if test "$TERM" != "dumb"
eval "$(${ewwCmd} shell-completions --shell fish)"
end
'';
}
(mkIf cfg.configDir
== null { xdg.configFile."eww".source = cfg.configDir; })
(mkIf cfg.yuckConfig == null { xdg.configFile."eww/eww.yuck".text = cfg.yuckConfig; })
(mkIf cfg.scssConfig == null { xdg.configFile."eww/eww.scss".text = cfg.scssConfig; })
(mkIf cfg.systemd.enable {
systemd.user.services.eww = {
Unit = {
Description = "ElKowars wacky widgets daemon";
Documentation = "https://elkowar.github.io/eww/";
After = [ "graphical-session.target" ];
PartOf = [ "graphical-session.target" ];
};
Service = {
ExecStart = "${cfg.package} daemon --no-daemonize";
ExecStop = "${cfg.package} kill";
ExecReload = "${cfg.package} reload";
};
Install = { WantedBy = [ cfg.systemd.target ]; };
};
})
]);
} }

View file

@ -194,6 +194,7 @@ in import nmtSrc {
./modules/programs/beets # One test relies on services.mpd ./modules/programs/beets # One test relies on services.mpd
./modules/programs/bemenu ./modules/programs/bemenu
./modules/programs/boxxy ./modules/programs/boxxy
./modules/programs/eww
./modules/programs/firefox/firefox.nix ./modules/programs/firefox/firefox.nix
./modules/programs/firefox/floorp.nix ./modules/programs/firefox/floorp.nix
./modules/programs/foot ./modules/programs/foot

View file

@ -0,0 +1,38 @@
{ config, pkgs, ... }:
{
config = {
programs.eww = {
enable = true;
systemd.enable = true;
configYuck = ''
(defwindow example
:monitor 0
:geometry (geometry :x "0%"
:y "20px"
:width "90%"
:height "30px"
:anchor "top center")
:stacking "fg"
:reserve (struts :distance "40px" :side "top")
:windowtype "dock"
:wm-ignore false
"example content")
'';
configScss = ''
window {
background: pink;
}
'';
};
test.stubs.eww = { name = "eww"; };
nmt.script = ''
assertFileExists home-files/.config/eww/eww.yuck
assertFileExists home-files/.config/eww/eww.scss
serviceFile=$(normalizeStorePaths home-files/.config/systemd/user/eww.service)
assertFileContent "$serviceFile" ${./basic-configuration.service}
'';
};
}

View file

@ -0,0 +1,13 @@
[Install]
WantedBy=graphical-session.target
[Service]
ExecReload=@eww@ reload
ExecStart=@eww@ daemon --no-daemonize
ExecStop=@eww@ kill
[Unit]
After=graphical-session.target
Description=ElKowars wacky widgets daemon
Documentation=https://elkowar.github.io/eww/
PartOf=graphical-session.target

View file

@ -0,0 +1 @@
{ eww-basic-configuration = ./basic-configuration.nix; }