mirror of
https://github.com/nix-community/home-manager
synced 2024-11-30 06:59:45 +01:00
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
This commit is contained in:
parent
bf99255fc9
commit
64f7a77517
5 changed files with 38 additions and 6 deletions
3
.github/CODEOWNERS
vendored
3
.github/CODEOWNERS
vendored
|
@ -263,6 +263,9 @@ Makefile @thiagokokada
|
|||
/modules/programs/pls.nix @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/pubs.nix @loicreynier
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
{ config, options, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.services.polybar;
|
||||
opt = options.services.polybar;
|
||||
|
||||
eitherStrBoolIntList = with types;
|
||||
either str (either bool (either int (listOf str)));
|
||||
|
@ -198,15 +199,19 @@ in {
|
|||
lib.platforms.linux)
|
||||
];
|
||||
|
||||
meta.maintainers = with maintainers; [ h7x4 ];
|
||||
|
||||
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 = {
|
||||
Unit = {
|
||||
Description = "Polybar status bar";
|
||||
PartOf = [ "tray.target" ];
|
||||
X-Restart-Triggers =
|
||||
[ "${config.xdg.configFile."polybar/config.ini".source}" ];
|
||||
X-Restart-Triggers = [ "${config.xdg.configHome}/polybar/config.ini" ];
|
||||
};
|
||||
|
||||
Service = {
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
serviceFile=home-files/.config/systemd/user/polybar.service
|
||||
|
||||
assertFileExists $serviceFile
|
||||
assertFileRegex $serviceFile 'X-Restart-Triggers=.*polybar\.conf'
|
||||
assertFileRegex $serviceFile 'X-Restart-Triggers=.*/.config/polybar/config.ini'
|
||||
assertFileRegex $serviceFile 'ExecStart=.*/bin/polybar-start'
|
||||
|
||||
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