polybar: don't generate config if no options are set (#3383)
* polybar: don't generate config if no options are set
* polybar: add h7x4 as maintainer
(cherry picked from commit 64f7a77517
)
This commit is contained in:
parent
3bf287ef12
commit
6ee09246d9
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -263,6 +263,9 @@ Makefile @thiagokokada
|
||||||
/modules/programs/pls.nix @arjan-s
|
/modules/programs/pls.nix @arjan-s
|
||||||
/tests/modules/programs/pls @arjan-s
|
/tests/modules/programs/pls @arjan-s
|
||||||
|
|
||||||
|
/modules/programs/polybar.nix @h7x4
|
||||||
|
/tests/modules/programs/polybar @h7x4
|
||||||
|
|
||||||
/modules/programs/powerline-go.nix @DamienCassou
|
/modules/programs/powerline-go.nix @DamienCassou
|
||||||
|
|
||||||
/modules/programs/pubs.nix @loicreynier
|
/modules/programs/pubs.nix @loicreynier
|
||||||
|
|
|
@ -1,10 +1,11 @@
|
||||||
{ config, lib, pkgs, ... }:
|
{ config, options, lib, pkgs, ... }:
|
||||||
|
|
||||||
with lib;
|
with lib;
|
||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
cfg = config.services.polybar;
|
cfg = config.services.polybar;
|
||||||
|
opt = options.services.polybar;
|
||||||
|
|
||||||
eitherStrBoolIntList = with types;
|
eitherStrBoolIntList = with types;
|
||||||
either str (either bool (either int (listOf str)));
|
either str (either bool (either int (listOf str)));
|
||||||
|
@ -198,15 +199,19 @@ in {
|
||||||
lib.platforms.linux)
|
lib.platforms.linux)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
meta.maintainers = with maintainers; [ h7x4 ];
|
||||||
|
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
xdg.configFile."polybar/config.ini".source = configFile;
|
xdg.configFile."polybar/config.ini" = let
|
||||||
|
isDeclarativeConfig = cfg.settings != opt.settings.default || cfg.config
|
||||||
|
!= opt.config.default || cfg.extraConfig != opt.extraConfig.default;
|
||||||
|
in mkIf isDeclarativeConfig { source = configFile; };
|
||||||
|
|
||||||
systemd.user.services.polybar = {
|
systemd.user.services.polybar = {
|
||||||
Unit = {
|
Unit = {
|
||||||
Description = "Polybar status bar";
|
Description = "Polybar status bar";
|
||||||
PartOf = [ "tray.target" ];
|
PartOf = [ "tray.target" ];
|
||||||
X-Restart-Triggers =
|
X-Restart-Triggers = [ "${config.xdg.configHome}/polybar/config.ini" ];
|
||||||
[ "${config.xdg.configFile."polybar/config.ini".source}" ];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Service = {
|
Service = {
|
||||||
|
|
|
@ -47,7 +47,7 @@
|
||||||
serviceFile=home-files/.config/systemd/user/polybar.service
|
serviceFile=home-files/.config/systemd/user/polybar.service
|
||||||
|
|
||||||
assertFileExists $serviceFile
|
assertFileExists $serviceFile
|
||||||
assertFileRegex $serviceFile 'X-Restart-Triggers=.*polybar\.conf'
|
assertFileRegex $serviceFile 'X-Restart-Triggers=.*/.config/polybar/config.ini'
|
||||||
assertFileRegex $serviceFile 'ExecStart=.*/bin/polybar-start'
|
assertFileRegex $serviceFile 'ExecStart=.*/bin/polybar-start'
|
||||||
|
|
||||||
assertFileExists home-files/.config/polybar/config.ini
|
assertFileExists home-files/.config/polybar/config.ini
|
||||||
|
|
|
@ -1 +1,4 @@
|
||||||
{ polybar-basic-configuration = ./basic-configuration.nix; }
|
{
|
||||||
|
polybar-basic-configuration = ./basic-configuration.nix;
|
||||||
|
polybar-empty-configuration = ./empty-configuration.nix;
|
||||||
|
}
|
||||||
|
|
21
tests/modules/services/polybar/empty-configuration.nix
Normal file
21
tests/modules/services/polybar/empty-configuration.nix
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{ config, pkgs, ... }:
|
||||||
|
|
||||||
|
{
|
||||||
|
config = {
|
||||||
|
services.polybar = {
|
||||||
|
enable = true;
|
||||||
|
package = config.lib.test.mkStubPackage { };
|
||||||
|
script = "polybar bar &";
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
serviceFile=home-files/.config/systemd/user/polybar.service
|
||||||
|
|
||||||
|
assertFileExists $serviceFile
|
||||||
|
assertFileRegex $serviceFile 'X-Restart-Triggers=.*/.config/polybar/config.ini'
|
||||||
|
assertFileRegex $serviceFile 'ExecStart=.*/bin/polybar-start'
|
||||||
|
|
||||||
|
assertPathNotExists home-files/.config/polybar/config.ini
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
}
|
Loading…
Reference in a new issue