mirror of
https://github.com/nix-community/home-manager
synced 2024-11-15 23:59:45 +01:00
polybar: fix restart trigger
The old trigger would actually never cause a restart since the path
doesn't change. With this change the trigger is now using the actual
configuration path in the Nix store, which depends on the content.
(cherry picked from commit 65700a4fd1
)
This commit is contained in:
parent
6ee09246d9
commit
32c336c767
3 changed files with 16 additions and 12 deletions
|
@ -55,11 +55,17 @@ let
|
||||||
in "${key}=${value'}";
|
in "${key}=${value'}";
|
||||||
};
|
};
|
||||||
|
|
||||||
configFile = pkgs.writeText "polybar.conf" ''
|
configFile = let
|
||||||
|
isDeclarativeConfig = cfg.settings != opt.settings.default || cfg.config
|
||||||
|
!= opt.config.default || cfg.extraConfig != opt.extraConfig.default;
|
||||||
|
in if isDeclarativeConfig then
|
||||||
|
pkgs.writeText "polybar.conf" ''
|
||||||
${toPolybarIni cfg.config}
|
${toPolybarIni cfg.config}
|
||||||
${toPolybarIni (mapAttrs convertPolybarSection cfg.settings)}
|
${toPolybarIni (mapAttrs convertPolybarSection cfg.settings)}
|
||||||
${cfg.extraConfig}
|
${cfg.extraConfig}
|
||||||
'';
|
''
|
||||||
|
else
|
||||||
|
null;
|
||||||
|
|
||||||
in {
|
in {
|
||||||
options = {
|
options = {
|
||||||
|
@ -202,16 +208,14 @@ in {
|
||||||
meta.maintainers = with maintainers; [ h7x4 ];
|
meta.maintainers = with maintainers; [ h7x4 ];
|
||||||
|
|
||||||
home.packages = [ cfg.package ];
|
home.packages = [ cfg.package ];
|
||||||
xdg.configFile."polybar/config.ini" = let
|
xdg.configFile."polybar/config.ini" =
|
||||||
isDeclarativeConfig = cfg.settings != opt.settings.default || cfg.config
|
mkIf (configFile != null) { source = configFile; };
|
||||||
!= 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 = [ "${config.xdg.configHome}/polybar/config.ini" ];
|
X-Restart-Triggers = mkIf (configFile != null) "${configFile}";
|
||||||
};
|
};
|
||||||
|
|
||||||
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=.*/.config/polybar/config.ini'
|
assertFileRegex $serviceFile 'X-Restart-Triggers=/nix/store/.*-polybar.conf$'
|
||||||
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
|
||||||
|
|
|
@ -12,7 +12,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=.*/.config/polybar/config.ini'
|
assertFileNotRegex $serviceFile 'X-Restart-Triggers=/nix/store/.*-polybar.conf$'
|
||||||
assertFileRegex $serviceFile 'ExecStart=.*/bin/polybar-start'
|
assertFileRegex $serviceFile 'ExecStart=.*/bin/polybar-start'
|
||||||
|
|
||||||
assertPathNotExists home-files/.config/polybar/config.ini
|
assertPathNotExists home-files/.config/polybar/config.ini
|
||||||
|
|
Loading…
Reference in a new issue