chromium: install plasma browser integration
Reuse existing plasmaSupport option to install browser integration package.
This commit is contained in:
@@ -80,7 +80,19 @@ let
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "Whether to enable the 'Use QT' theme for ${name}.";
|
||||
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.
|
||||
'';
|
||||
};
|
||||
}
|
||||
// {
|
||||
@@ -103,7 +115,7 @@ let
|
||||
default = [ ];
|
||||
example = literalExpression ''
|
||||
[
|
||||
pkgs.kdePackages.plasma-browser-integration
|
||||
pkgs.keepassxc
|
||||
]
|
||||
'';
|
||||
description = ''
|
||||
@@ -257,9 +269,15 @@ let
|
||||
value.source = pkg;
|
||||
};
|
||||
|
||||
plasmaSupportEnabled = pkgs.stdenv.isLinux && (cfg.plasmaSupport or false);
|
||||
|
||||
nativeMessagingHosts = lib.unique (
|
||||
cfg.nativeMessagingHosts ++ lib.optional plasmaSupportEnabled cfg.plasmaBrowserIntegrationPackage
|
||||
);
|
||||
|
||||
nativeMessagingHostsJoined = pkgs.symlinkJoin {
|
||||
name = "${effectiveBrowser}-native-messaging-hosts";
|
||||
paths = cfg.nativeMessagingHosts;
|
||||
paths = nativeMessagingHosts;
|
||||
};
|
||||
|
||||
in
|
||||
@@ -290,12 +308,12 @@ let
|
||||
programs.${browser}.finalPackage =
|
||||
if cfg.package == null then
|
||||
null
|
||||
else if cfg.commandLineArgs != [ ] || (cfg.plasmaSupport or false) then
|
||||
else if cfg.commandLineArgs != [ ] || plasmaSupportEnabled then
|
||||
cfg.package.override (
|
||||
lib.optionalAttrs (cfg.commandLineArgs != [ ]) {
|
||||
commandLineArgs = lib.concatStringsSep " " cfg.commandLineArgs;
|
||||
}
|
||||
// lib.optionalAttrs (cfg.plasmaSupport or false) {
|
||||
// lib.optionalAttrs plasmaSupportEnabled {
|
||||
plasmaSupport = true;
|
||||
inherit (pkgs) kdePackages;
|
||||
}
|
||||
@@ -310,7 +328,7 @@ let
|
||||
lib.optionalAttrs supportsUserExtensions (lib.listToAttrs (map extensionJson cfg.extensions))
|
||||
// lib.listToAttrs (map dictionary cfg.dictionaries)
|
||||
// {
|
||||
"${configDir}/NativeMessagingHosts" = lib.mkIf (cfg.nativeMessagingHosts != [ ]) {
|
||||
"${configDir}/NativeMessagingHosts" = lib.mkIf (nativeMessagingHosts != [ ]) {
|
||||
source = "${nativeMessagingHostsJoined}/etc/chromium/native-messaging-hosts";
|
||||
recursive = true;
|
||||
};
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
{ config, lib, ... }:
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
chromePackage =
|
||||
let
|
||||
@@ -29,6 +34,20 @@ let
|
||||
};
|
||||
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";
|
||||
in
|
||||
{
|
||||
programs.google-chrome = {
|
||||
@@ -39,6 +58,7 @@ in
|
||||
"--ignore-gpu-blocklist"
|
||||
];
|
||||
plasmaSupport = true;
|
||||
inherit plasmaBrowserIntegrationPackage;
|
||||
};
|
||||
|
||||
nmt.script = ''
|
||||
@@ -53,7 +73,20 @@ in
|
||||
"${config.programs.google-chrome.finalPackage}/override-info" \
|
||||
${builtins.toFile "google-chrome-override-info" ''
|
||||
commandLineArgs=--enable-logging=stderr --ignore-gpu-blocklist
|
||||
plasmaSupport=true
|
||||
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"
|
||||
''
|
||||
}
|
||||
'';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user