diff --git a/modules/programs/hyprpanel/default.nix b/modules/programs/hyprpanel/default.nix index 2b4acb968..ea713fa70 100644 --- a/modules/programs/hyprpanel/default.nix +++ b/modules/programs/hyprpanel/default.nix @@ -89,30 +89,31 @@ in xdg.configFile.hyprpanel = lib.mkIf (cfg.settings != { }) { target = "hyprpanel/config.json"; - source = jsonFormat.generate "hyprpanel-config" ( - if cfg.settings ? theme && cfg.settings.theme ? name then - lib.warn '' - `settings.theme.name` option has been removed, because the - hyprpanel module has been ported to downstream home-manager and - implementing it would require IFD - (https://nix.dev/manual/nix/2.26/language/import-from-derivation) - - Replace it with: - ```nix - programs.hyprpanel = { - theme = { - # paste content of https://github.com/Jas-SinghFSU/HyprPanel/blob/2c0c66a/themes/${cfg.settings.theme.name}.json - }; - }; - ``` - '' cfg.settings - else - cfg.settings - ); + source = jsonFormat.generate "hyprpanel-config" cfg.settings; # hyprpanel replaces it with the same file, but without new line in the end force = true; }; + warnings = lib.optional (cfg.settings ? theme && cfg.settings.theme ? name) ( + lib.hm.deprecations.mkDeprecatedOptionValueWarning { + option = [ + "programs" + "hyprpanel" + "settings" + "theme" + "name" + ]; + old = "a named theme"; + replacement = "`programs.hyprpanel.settings.theme`"; + details = '' + Named theme loading was removed because it requires import-from-derivation. + + Paste theme contents from: + https://github.com/Jas-SinghFSU/HyprPanel/blob/2c0c66a/themes/${cfg.settings.theme.name}.json + ''; + } + ); + systemd.user.services.hyprpanel = lib.mkIf cfg.systemd.enable { Unit = { Description = "Bar/Panel for Hyprland with extensive customizability"; diff --git a/tests/modules/programs/hyprpanel/default.nix b/tests/modules/programs/hyprpanel/default.nix index dd73495f9..04e157c09 100644 --- a/tests/modules/programs/hyprpanel/default.nix +++ b/tests/modules/programs/hyprpanel/default.nix @@ -2,5 +2,6 @@ lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { hyprpanel-basic-config = ./basic-config.nix; + hyprpanel-deprecated-theme-name = ./deprecated-theme-name.nix; hyprpanel-with-hypridle = ./with-hypridle.nix; } diff --git a/tests/modules/programs/hyprpanel/deprecated-theme-name.nix b/tests/modules/programs/hyprpanel/deprecated-theme-name.nix new file mode 100644 index 000000000..892aca6db --- /dev/null +++ b/tests/modules/programs/hyprpanel/deprecated-theme-name.nix @@ -0,0 +1,26 @@ +{ config, ... }: + +{ + programs.hyprpanel = { + enable = true; + package = config.lib.test.mkStubPackage { name = "hyprpanel"; }; + settings.theme.name = "catppuccin_mocha"; + }; + + test.asserts.warnings.expected = [ + '' + Using `programs.hyprpanel.settings.theme.name` as a named theme is deprecated and will be + removed in a future release. Please use `programs.hyprpanel.settings.theme` instead. + + Named theme loading was removed because it requires import-from-derivation. + + Paste theme contents from: + https://github.com/Jas-SinghFSU/HyprPanel/blob/2c0c66a/themes/catppuccin_mocha.json + + '' + ]; + + nmt.script = '' + assertFileExists "home-files/.config/hyprpanel/config.json" + ''; +}