1
0
Fork 0
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:
h7x4 2022-11-27 01:17:28 +01:00 committed by GitHub
parent bf99255fc9
commit 64f7a77517
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 38 additions and 6 deletions

3
.github/CODEOWNERS vendored
View file

@ -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

View file

@ -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 = {

View file

@ -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

View file

@ -1 +1,4 @@
{ polybar-basic-configuration = ./basic-configuration.nix; } {
polybar-basic-configuration = ./basic-configuration.nix;
polybar-empty-configuration = ./empty-configuration.nix;
}

View 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
'';
};
}