nixos: update chrome desktop launchers
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
final: prev:
|
final: prev: {
|
||||||
let
|
|
||||||
# XXX: codex and claude-code are now provided by dedicated flakes in nix.nix:
|
# XXX: codex and claude-code are now provided by dedicated flakes in nix.nix:
|
||||||
# - inputs.codex-cli-nix (github:sadjow/codex-cli-nix)
|
# - inputs.codex-cli-nix (github:sadjow/codex-cli-nix)
|
||||||
# - inputs.claude-code-nix (github:sadjow/claude-code-nix)
|
# - inputs.claude-code-nix (github:sadjow/claude-code-nix)
|
||||||
@@ -30,49 +29,6 @@ let
|
|||||||
# hash = "sha256-OqvLiwB5TwZaxDvyN/+/+eueBdWNaYxd81cd5AZK/mA=";
|
# hash = "sha256-OqvLiwB5TwZaxDvyN/+/+eueBdWNaYxd81cd5AZK/mA=";
|
||||||
# npmDepsHash = "sha256-vy7osk3UAOEgsJx9jdcGe2wICOk5Urzxh1WLAHyHM+U=";
|
# npmDepsHash = "sha256-vy7osk3UAOEgsJx9jdcGe2wICOk5Urzxh1WLAHyHM+U=";
|
||||||
# };
|
# };
|
||||||
# Chrome 136+ ignores remote debugging switches on the default profile.
|
|
||||||
# Keep the wrapper in place, but do not inject remote debugging flags into
|
|
||||||
# the normal Chrome launcher. The supported path for a real profile is the
|
|
||||||
# Chrome remote debugging permission flow used by chrome-devtools-mcp
|
|
||||||
# --auto-connect.
|
|
||||||
chromeRemoteDebuggingFlags = [];
|
|
||||||
placeholder = null; # Dummy binding to keep let block valid
|
|
||||||
in
|
|
||||||
{
|
|
||||||
google-chrome = prev.symlinkJoin {
|
|
||||||
name = prev.google-chrome.name;
|
|
||||||
paths = [ prev.google-chrome ];
|
|
||||||
nativeBuildInputs = [ final.makeWrapper ];
|
|
||||||
postBuild = ''
|
|
||||||
rm "$out/bin/google-chrome" "$out/bin/google-chrome-stable"
|
|
||||||
|
|
||||||
makeWrapper ${prev.google-chrome}/bin/google-chrome "$out/bin/google-chrome" \
|
|
||||||
${final.lib.concatMapStringsSep " " (flag: "--add-flags ${final.lib.escapeShellArg flag}") chromeRemoteDebuggingFlags}
|
|
||||||
|
|
||||||
makeWrapper ${prev.google-chrome}/bin/google-chrome-stable "$out/bin/google-chrome-stable" \
|
|
||||||
${final.lib.concatMapStringsSep " " (flag: "--add-flags ${final.lib.escapeShellArg flag}") chromeRemoteDebuggingFlags}
|
|
||||||
|
|
||||||
for desktopName in google-chrome.desktop com.google.Chrome.desktop; do
|
|
||||||
desktopFile="$out/share/applications/$desktopName"
|
|
||||||
if [ -f "$desktopFile" ]; then
|
|
||||||
rm "$desktopFile"
|
|
||||||
cp "${prev.google-chrome}/share/applications/$desktopName" "$desktopFile"
|
|
||||||
substituteInPlace "$desktopFile" \
|
|
||||||
--replace-fail "${prev.google-chrome}/bin/google-chrome-stable" "$out/bin/google-chrome-stable"
|
|
||||||
${final.gnused}/bin/sed -i \
|
|
||||||
'/^\[Desktop Action new-window\]/,/^\[Desktop Action / s#^Exec=\(.*google-chrome-stable\)$#Exec=\1 --new-window#' \
|
|
||||||
"$desktopFile"
|
|
||||||
substituteInPlace "$desktopFile" \
|
|
||||||
--replace-fail "image/gif;" "" \
|
|
||||||
--replace-fail "image/jpeg;" "" \
|
|
||||||
--replace-fail "image/png;" "" \
|
|
||||||
--replace-fail "image/webp;" ""
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
'';
|
|
||||||
meta = prev.google-chrome.meta;
|
|
||||||
};
|
|
||||||
|
|
||||||
# Fix poetry pbs-installer version constraint issue
|
# Fix poetry pbs-installer version constraint issue
|
||||||
poetry = prev.poetry.overrideAttrs (oldAttrs: {
|
poetry = prev.poetry.overrideAttrs (oldAttrs: {
|
||||||
dontCheckRuntimeDeps = true;
|
dontCheckRuntimeDeps = true;
|
||||||
|
|||||||
@@ -25,28 +25,96 @@
|
|||||||
++ lib.optionals config.myModules.chrome-favicon-dbus.enable [
|
++ lib.optionals config.myModules.chrome-favicon-dbus.enable [
|
||||||
"--load-extension=${inputs.chrome-favicon-dbus}/extension"
|
"--load-extension=${inputs.chrome-favicon-dbus}/extension"
|
||||||
];
|
];
|
||||||
googleChrome = pkgs.symlinkJoin {
|
googleChromeWrapperArgs = lib.concatMapStringsSep " " (flag: "--add-flags ${lib.escapeShellArg flag}") chromeCommandLineFlags;
|
||||||
name = "google-chrome-wayland-fractional-scale-workaround";
|
googleChromeCommandWrappers = pkgs.runCommand "google-chrome-command-wrappers" {nativeBuildInputs = [pkgs.makeWrapper];} ''
|
||||||
paths = [pkgs.google-chrome];
|
mkdir -p "$out/bin"
|
||||||
nativeBuildInputs = [pkgs.makeWrapper];
|
makeWrapper ${pkgs.google-chrome}/bin/google-chrome "$out/bin/google-chrome" \
|
||||||
postBuild = ''
|
${googleChromeWrapperArgs}
|
||||||
wrapProgram "$out/bin/google-chrome-stable" \
|
makeWrapper ${pkgs.google-chrome}/bin/google-chrome-stable "$out/bin/google-chrome-stable" \
|
||||||
${lib.concatMapStringsSep " \\\n " (flag: "--add-flags ${lib.escapeShellArg flag}") chromeCommandLineFlags}
|
${googleChromeWrapperArgs}
|
||||||
|
'';
|
||||||
|
googleChromeProfileWindow = pkgs.writeShellApplication {
|
||||||
|
name = "google-chrome-profile-window";
|
||||||
|
runtimeInputs = [
|
||||||
|
googleChromeCommandWrappers
|
||||||
|
pkgs.gawk
|
||||||
|
pkgs.jq
|
||||||
|
pkgs.rofi
|
||||||
|
];
|
||||||
|
text = ''
|
||||||
|
if [ "$#" -gt 0 ]; then
|
||||||
|
exec google-chrome-stable "$@"
|
||||||
|
fi
|
||||||
|
|
||||||
desktop_file="$out/share/applications/google-chrome.desktop"
|
local_state="''${CHROME_USER_DATA_DIR:-$HOME/.config/google-chrome}/Local State"
|
||||||
rm "$desktop_file"
|
|
||||||
cp "${pkgs.google-chrome}/share/applications/google-chrome.desktop" "$desktop_file"
|
|
||||||
chmod u+w "$desktop_file"
|
|
||||||
|
|
||||||
substituteInPlace "$desktop_file" \
|
if [ ! -r "$local_state" ]; then
|
||||||
--replace-fail \
|
exec google-chrome-stable --new-window
|
||||||
"Exec=${pkgs.google-chrome}/bin/google-chrome-stable" \
|
fi
|
||||||
"Exec=$out/bin/google-chrome-stable"
|
|
||||||
${pkgs.gnused}/bin/sed -i \
|
profiles="$(
|
||||||
'/^\[Desktop Action new-window\]/,/^\[Desktop Action / s#^Exec=\(.*google-chrome-stable\)$#Exec=\1 --new-window#' \
|
jq -r '
|
||||||
"$desktop_file"
|
(.profile.info_cache // {})
|
||||||
|
| to_entries
|
||||||
|
| sort_by(.value.active_time // 0)
|
||||||
|
| reverse[]
|
||||||
|
| [.value.name, .value.user_name, .key]
|
||||||
|
| @tsv
|
||||||
|
' "$local_state" \
|
||||||
|
| awk -F '\t' '{
|
||||||
|
label = $1
|
||||||
|
if ($2 != "") {
|
||||||
|
label = label " <" $2 ">"
|
||||||
|
}
|
||||||
|
print label "\t" $3
|
||||||
|
}'
|
||||||
|
)"
|
||||||
|
|
||||||
|
if [ -z "$profiles" ]; then
|
||||||
|
exec google-chrome-stable --new-window
|
||||||
|
fi
|
||||||
|
|
||||||
|
selection="$(printf '%s\n' "$profiles" | rofi -dmenu -i -p 'Chrome profile' || true)"
|
||||||
|
if [ -z "$selection" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
profile_dir="$(printf '%s\n' "$selection" | awk -F '\t' '{print $NF}')"
|
||||||
|
if [ -z "$profile_dir" ]; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
exec google-chrome-stable --profile-directory="$profile_dir" --new-window
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
googleChromeDesktopEntries = pkgs.runCommand "google-chrome-desktop-entries" {nativeBuildInputs = [pkgs.gnused];} ''
|
||||||
|
mkdir -p "$out/share/applications"
|
||||||
|
|
||||||
|
for desktop_name in google-chrome.desktop com.google.Chrome.desktop; do
|
||||||
|
source_file="${pkgs.google-chrome}/share/applications/$desktop_name"
|
||||||
|
if [ -f "$source_file" ]; then
|
||||||
|
desktop_file="$out/share/applications/$desktop_name"
|
||||||
|
cp "$source_file" "$desktop_file"
|
||||||
|
chmod u+w "$desktop_file"
|
||||||
|
|
||||||
|
substituteInPlace "$desktop_file" \
|
||||||
|
--replace-fail "${pkgs.google-chrome}/bin/google-chrome-stable" "google-chrome-stable"
|
||||||
|
|
||||||
|
${pkgs.gnused}/bin/sed -i \
|
||||||
|
-e 's,application/pdf;,,g' \
|
||||||
|
-e 's,image/gif;,,g' \
|
||||||
|
-e 's,image/jpeg;,,g' \
|
||||||
|
-e 's,image/png;,,g' \
|
||||||
|
-e 's,image/webp;,,g' \
|
||||||
|
"$desktop_file"
|
||||||
|
|
||||||
|
${pkgs.gnused}/bin/sed -i \
|
||||||
|
-e 's#^Exec=.*google-chrome-stable *%U$#Exec=google-chrome-profile-window %U#' \
|
||||||
|
-e '/^\[Desktop Action new-window\]/,/^\[Desktop Action / s#^Exec=.*google-chrome-stable.*$#Exec=google-chrome-profile-window#' \
|
||||||
|
"$desktop_file"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
'';
|
||||||
rlruPackages = inputs.rlru.packages.${pkgs.stdenv.hostPlatform.system};
|
rlruPackages = inputs.rlru.packages.${pkgs.stdenv.hostPlatform.system};
|
||||||
rlruDioxusDesktopBase = rlruPackages.rlru-dioxus-desktop;
|
rlruDioxusDesktopBase = rlruPackages.rlru-dioxus-desktop;
|
||||||
rlruDioxusDesktop = pkgs.symlinkJoin {
|
rlruDioxusDesktop = pkgs.symlinkJoin {
|
||||||
@@ -92,7 +160,7 @@
|
|||||||
system.activationScripts.playwrightChromeCompat.text = lib.optionalString (pkgs.stdenv.hostPlatform.system == "x86_64-linux") ''
|
system.activationScripts.playwrightChromeCompat.text = lib.optionalString (pkgs.stdenv.hostPlatform.system == "x86_64-linux") ''
|
||||||
# Playwright's Chrome channel lookup expects the FHS path below.
|
# Playwright's Chrome channel lookup expects the FHS path below.
|
||||||
mkdir -p /opt/google/chrome
|
mkdir -p /opt/google/chrome
|
||||||
ln -sfn ${googleChrome}/bin/google-chrome-stable /opt/google/chrome/chrome
|
ln -sfn ${googleChromeCommandWrappers}/bin/google-chrome-stable /opt/google/chrome/chrome
|
||||||
'';
|
'';
|
||||||
|
|
||||||
services.gnome.at-spi2-core.enable = true;
|
services.gnome.at-spi2-core.enable = true;
|
||||||
@@ -243,7 +311,9 @@
|
|||||||
if pkgs.stdenv.hostPlatform.system == "x86_64-linux"
|
if pkgs.stdenv.hostPlatform.system == "x86_64-linux"
|
||||||
then
|
then
|
||||||
with pkgs; [
|
with pkgs; [
|
||||||
googleChrome
|
googleChromeCommandWrappers
|
||||||
|
googleChromeDesktopEntries
|
||||||
|
googleChromeProfileWindow
|
||||||
pommed_light
|
pommed_light
|
||||||
slack
|
slack
|
||||||
spicetify-cli
|
spicetify-cli
|
||||||
|
|||||||
@@ -256,7 +256,9 @@ in {
|
|||||||
"$desktop_file"
|
"$desktop_file"
|
||||||
|
|
||||||
${pkgs.gnused}/bin/sed -i \
|
${pkgs.gnused}/bin/sed -i \
|
||||||
'/^\[Desktop Action new-window\]/,/^\[Desktop Action / s#^Exec=\(.*google-chrome-stable\)$#Exec=\1 --new-window#' \
|
-e 's#^Exec=.*google-chrome-stable *%U$#Exec=google-chrome-profile-window %U#' \
|
||||||
|
-e '/^\[Desktop Action new-window\]/,/^\[Desktop Action / s#^Exec=.*google-chrome-stable.*$#Exec=google-chrome-profile-window#' \
|
||||||
|
-e '/^\[Desktop Action new-private-window\]/,/^\[Desktop Action / s#^Exec=.*google-chrome-stable.*$#Exec=google-chrome-stable --incognito#' \
|
||||||
"$desktop_file"
|
"$desktop_file"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -285,7 +287,7 @@ in {
|
|||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
|
|
||||||
home.activation.refreshKdeServiceCache = lib.hm.dag.entryAfter ["refreshChromeDesktopMimeCache"] ''
|
home.activation.refreshKdeServiceCache = lib.hm.dag.entryAfter ["refreshChromeDesktopLaunchers"] ''
|
||||||
${pkgs.kdePackages.kservice}/bin/kbuildsycoca6 --noincremental >/dev/null 2>&1 || true
|
${pkgs.kdePackages.kservice}/bin/kbuildsycoca6 --noincremental >/dev/null 2>&1 || true
|
||||||
'';
|
'';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user