discord: add a script to disable breaking updates (#197248)
This commit is contained in:
parent
655b51eb18
commit
cdde640978
@ -0,0 +1,42 @@
|
||||
#!@pythonInterpreter@
|
||||
# slightly tweaked from the script created by @lionirdeadman
|
||||
# https://github.com/flathub/com.discordapp.Discord/blob/master/disable-breaking-updates.py
|
||||
"""
|
||||
Disable breaking updates which will prompt users to download a deb or tar file
|
||||
and lock them out of Discord making the program unusable.
|
||||
|
||||
This will dramatically improve the experience :
|
||||
|
||||
1) The maintainer doesn't need to be worried at all times of an update which will break Discord.
|
||||
2) People will not be locked out of the program while the maintainer runs to update it.
|
||||
|
||||
"""
|
||||
|
||||
import json
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
XDG_CONFIG_HOME = os.environ.get("XDG_CONFIG_HOME") or os.path.join(
|
||||
os.path.expanduser("~"), ".config"
|
||||
)
|
||||
|
||||
settings_path = Path(f"{XDG_CONFIG_HOME}/@configDirName@/settings.json")
|
||||
settings_path_temp = Path(f"{XDG_CONFIG_HOME}/@configDirName@/settings.json.tmp")
|
||||
try:
|
||||
with settings_path.open(encoding="utf-8") as settings_file:
|
||||
settings = json.load(settings_file)
|
||||
|
||||
if settings.get("SKIP_HOST_UPDATE"):
|
||||
print("[Nix] Disabling updates already done")
|
||||
else:
|
||||
skip_host_update = {"SKIP_HOST_UPDATE": True}
|
||||
settings.update(skip_host_update)
|
||||
|
||||
with settings_path_temp.open("w", encoding="utf-8") as settings_file_temp:
|
||||
json.dump(settings, settings_file_temp, indent=2)
|
||||
|
||||
settings_path_temp.rename(settings_path)
|
||||
print("[Nix] Disabled updates")
|
||||
|
||||
except IOError:
|
||||
print("[Nix] settings.json doesn't yet exist, can't disable it yet")
|
@ -4,9 +4,22 @@
|
||||
, glib, gtk3, libcxx, libdrm, libnotify, libpulseaudio, libuuid, libX11
|
||||
, libXScrnSaver, libXcomposite, libXcursor, libXdamage, libXext, libXfixes
|
||||
, libXi, libXrandr, libXrender, libXtst, libxcb, libxshmfence, mesa, nspr, nss
|
||||
, pango, systemd, libappindicator-gtk3, libdbusmenu, writeScript
|
||||
, pango, systemd, libappindicator-gtk3, libdbusmenu, writeScript, python3, runCommand
|
||||
, common-updater-scripts, withOpenASAR ? false }:
|
||||
|
||||
let
|
||||
disableBreakingUpdates = runCommand "disable-breaking-updates.py"
|
||||
{
|
||||
pythonInterpreter = "${python3.interpreter}";
|
||||
configDirName = lib.toLower binaryName;
|
||||
} ''
|
||||
mkdir -p $out/bin
|
||||
cp ${./disable-breaking-updates.py} $out/bin/disable-breaking-updates.py
|
||||
substituteAllInPlace $out/bin/disable-breaking-updates.py
|
||||
chmod +x $out/bin/disable-breaking-updates.py
|
||||
'';
|
||||
in
|
||||
|
||||
stdenv.mkDerivation rec {
|
||||
inherit pname version src meta;
|
||||
|
||||
@ -85,7 +98,8 @@ stdenv.mkDerivation rec {
|
||||
"''${gappsWrapperArgs[@]}" \
|
||||
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
|
||||
--prefix XDG_DATA_DIRS : "${gtk3}/share/gsettings-schemas/${gtk3.name}/" \
|
||||
--prefix LD_LIBRARY_PATH : ${libPath}:$out/opt/${binaryName}
|
||||
--prefix LD_LIBRARY_PATH : ${libPath}:$out/opt/${binaryName} \
|
||||
--run "${lib.getExe disableBreakingUpdates}"
|
||||
|
||||
ln -s $out/opt/${binaryName}/${binaryName} $out/bin/
|
||||
# Without || true the install would fail on case-insensitive filesystems
|
||||
@ -115,7 +129,10 @@ stdenv.mkDerivation rec {
|
||||
mimeTypes = [ "x-scheme-handler/discord" ];
|
||||
};
|
||||
|
||||
passthru.updateScript = writeScript "discord-update-script" ''
|
||||
passthru = {
|
||||
# make it possible to run disableBreakingUpdates standalone
|
||||
inherit disableBreakingUpdates;
|
||||
updateScript = writeScript "discord-update-script" ''
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p curl gnugrep common-updater-scripts
|
||||
set -eou pipefail;
|
||||
@ -126,4 +143,5 @@ stdenv.mkDerivation rec {
|
||||
version=''${version%%/*.tar.gz}
|
||||
update-source-version ${pname} "$version" --file=./pkgs/applications/networking/instant-messengers/discord/default.nix
|
||||
'';
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user