diff --git a/modules/programs/chromium.nix b/modules/programs/chromium.nix index 071bd8f1b..838e88e77 100644 --- a/modules/programs/chromium.nix +++ b/modules/programs/chromium.nix @@ -74,27 +74,26 @@ let ''; }; } - // lib.optionalAttrs (lib.elem browser plasmaSupportedBrowsers) { - plasmaSupport = mkOption { - inherit visible; - type = types.bool; - default = false; - example = true; - description = "Whether to enable the 'Use QT' theme for ${name} on Linux."; - }; + // + lib.optionalAttrs (pkgs.stdenv.hostPlatform.isLinux && lib.elem browser plasmaSupportedBrowsers) + { + plasmaSupport = mkOption { + inherit visible; + type = types.bool; + default = false; + example = true; + description = "Whether to enable the 'Use QT' theme for ${name} on Linux."; + }; - plasmaBrowserIntegrationPackage = mkOption { - inherit visible; - type = types.package; - default = pkgs.kdePackages.plasma-browser-integration; - defaultText = literalExpression "pkgs.kdePackages.plasma-browser-integration"; - example = literalExpression "pkgs.kdePackages.plasma-browser-integration"; - description = '' - Package to use for the Plasma browser integration native messaging - host on Linux. - ''; - }; - } + plasmaBrowserIntegrationPackage = + lib.mkPackageOption pkgs.kdePackages "plasma-browser-integration" { + extraDescription = "Used for the native messaging host on Linux."; + pkgsText = "pkgs.kdePackages"; + } + // { + inherit visible; + }; + } // { dictionaries = mkOption { inherit visible; @@ -269,7 +268,8 @@ let value.source = pkg; }; - plasmaSupportEnabled = pkgs.stdenv.isLinux && (cfg.plasmaSupport or false); + plasmaSupportEnabled = + pkgs.stdenv.isLinux && lib.elem browser plasmaSupportedBrowsers && cfg.plasmaSupport; nativeMessagingHosts = lib.unique ( cfg.nativeMessagingHosts ++ lib.optional plasmaSupportEnabled cfg.plasmaBrowserIntegrationPackage diff --git a/tests/modules/programs/chromium/plasma-support-command-line-args.nix b/tests/modules/programs/chromium/plasma-support-command-line-args.nix index 0d871e3f7..b7374ea3e 100644 --- a/tests/modules/programs/chromium/plasma-support-command-line-args.nix +++ b/tests/modules/programs/chromium/plasma-support-command-line-args.nix @@ -48,6 +48,18 @@ let "Library/Application Support/Google/Chrome/NativeMessagingHosts" else ".config/google-chrome/NativeMessagingHosts"; + + nativeHostAssertion = + if pkgs.stdenv.hostPlatform.isLinux then + '' + assertFileExists \ + "home-files/${nativeHostsDir}/org.kde.plasma.browser_integration.json" + '' + else + '' + assertPathNotExists \ + "home-files/${nativeHostsDir}/org.kde.plasma.browser_integration.json" + ''; in { programs.google-chrome = { @@ -57,6 +69,8 @@ in "--enable-logging=stderr" "--ignore-gpu-blocklist" ]; + } + // lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { plasmaSupport = true; inherit plasmaBrowserIntegrationPackage; }; @@ -76,17 +90,6 @@ in plasmaSupport=${lib.boolToString pkgs.stdenv.hostPlatform.isLinux} ''} - ${ - if pkgs.stdenv.hostPlatform.isLinux then - '' - assertFileExists \ - "home-files/${nativeHostsDir}/org.kde.plasma.browser_integration.json" - '' - else - '' - assertPathNotExists \ - "home-files/${nativeHostsDir}/org.kde.plasma.browser_integration.json" - '' - } + ${nativeHostAssertion} ''; }