Files
home-manager/tests/modules/programs/chromium/plasma-support-command-line-args.nix
Austin Horstman a28e848a01 chromium: address plasma integration review
Hide the Plasma integration options on non-Linux platforms so the Chromium module does not need fallback access for platform-specific options.

Switch the integration package option to mkPackageOption and document the kdePackages default path with pkgsText. Also tighten the focused NMT test so Darwin does not set the Linux-only option while still asserting that no native host file is produced there.
2026-04-27 11:45:48 -05:00

96 lines
2.5 KiB
Nix

{
config,
lib,
pkgs,
...
}:
let
chromePackage =
let
mkPackage =
{
commandLineArgs ? "",
name,
plasmaSupport ? false,
}:
config.lib.test.mkStubPackage {
inherit name;
buildScript = ''
mkdir -p $out
cat > $out/override-info <<EOF
commandLineArgs=${commandLineArgs}
plasmaSupport=${lib.boolToString plasmaSupport}
EOF
'';
extraAttrs = {
override =
args:
mkPackage {
commandLineArgs = args.commandLineArgs or "";
name = "google-chrome-overridden";
plasmaSupport = args.plasmaSupport or false;
};
};
};
in
mkPackage { name = "google-chrome"; };
plasmaBrowserIntegrationPackage = config.lib.test.mkStubPackage {
name = "plasma-browser-integration";
buildScript = ''
mkdir -p $out/etc/chromium/native-messaging-hosts
echo test > $out/etc/chromium/native-messaging-hosts/org.kde.plasma.browser_integration.json
'';
};
nativeHostsDir =
if pkgs.stdenv.hostPlatform.isDarwin then
"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 = {
enable = true;
package = chromePackage;
commandLineArgs = [
"--enable-logging=stderr"
"--ignore-gpu-blocklist"
];
}
// lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux {
plasmaSupport = true;
inherit plasmaBrowserIntegrationPackage;
};
nmt.script = ''
package=${config.programs.google-chrome.package}
finalPackage=${config.programs.google-chrome.finalPackage}
if [[ "$package" == "$finalPackage" ]]; then
fail "Expected finalPackage ($finalPackage) to differ from package ($package)"
fi
assertFileContent \
"${config.programs.google-chrome.finalPackage}/override-info" \
${builtins.toFile "google-chrome-override-info" ''
commandLineArgs=--enable-logging=stderr --ignore-gpu-blocklist
plasmaSupport=${lib.boolToString pkgs.stdenv.hostPlatform.isLinux}
''}
${nativeHostAssertion}
'';
}