From f27475e3ed162ee31e6d303b1bce732b75e3e8d9 Mon Sep 17 00:00:00 2001 From: Ulysses Zhan Date: Thu, 31 Oct 2024 19:03:40 -0700 Subject: [PATCH] gnomeExtensions.lunar-calendar: fix usability --- .../gnome/extensions/extensionOverrides.nix | 33 +++++++++++++++++++ .../lunarcal_at_ailin.nemui.patch | 31 +++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 pkgs/desktops/gnome/extensions/extensionOverridesPatches/lunarcal_at_ailin.nemui.patch diff --git a/pkgs/desktops/gnome/extensions/extensionOverrides.nix b/pkgs/desktops/gnome/extensions/extensionOverrides.nix index 8275885597e0..b3f1929c3cef 100644 --- a/pkgs/desktops/gnome/extensions/extensionOverrides.nix +++ b/pkgs/desktops/gnome/extensions/extensionOverrides.nix @@ -1,5 +1,7 @@ { lib +, fetchFromGitLab , fetchzip +, cpio , ddcutil , easyeffects , gjs @@ -18,6 +20,8 @@ , procps , smartmontools , replaceVars +, stdenvNoCC +, substituteAll , touchegg , util-linux , vte @@ -110,6 +114,35 @@ super: lib.trivial.pipe super [ ]; })) + (patchExtension "lunarcal@ailin.nemui" (old: let + chinese-calendar = stdenvNoCC.mkDerivation (finalAttrs: { + pname = "chinese-calendar"; + version = "20240107"; + nativeBuildInputs = [ + cpio # used in install.sh + ]; + src = fetchFromGitLab { + domain = "gitlab.gnome.org"; + owner = "Nei"; + repo = "ChineseCalendar"; + tag = finalAttrs.version; + hash = "sha256-z8Af9e70bn3ztUZteIEt/b3nJIFosbnoy8mwKMM6Dmc="; + }; + installPhase = '' + runHook preInstall + HOME=$out ./install.sh + runHook postInstall + ''; + }); + in { + patches = [ + (substituteAll { + src = ./extensionOverridesPatches/lunarcal_at_ailin.nemui.patch; + chinese_calendar_path = chinese-calendar; + }) + ]; + })) + (patchExtension "pano@elhan.io" (final: prev: { version = "v23-alpha3"; src = fetchzip { diff --git a/pkgs/desktops/gnome/extensions/extensionOverridesPatches/lunarcal_at_ailin.nemui.patch b/pkgs/desktops/gnome/extensions/extensionOverridesPatches/lunarcal_at_ailin.nemui.patch new file mode 100644 index 000000000000..3c0b462f59f3 --- /dev/null +++ b/pkgs/desktops/gnome/extensions/extensionOverridesPatches/lunarcal_at_ailin.nemui.patch @@ -0,0 +1,31 @@ +diff --git a/backend/ytliu0-loader.js b/backend/ytliu0-loader.js +index 4862c17..25fe9e8 100644 +--- a/backend/ytliu0-loader.js ++++ b/backend/ytliu0-loader.js +@@ -8,7 +8,11 @@ import GLib from 'gi://GLib' + // Code from gnome-shell 44 : extenstionUtils.js:installImporter + let custom_importer + const origSearchPath = imports.searchPath.slice() +-imports.searchPath = [GLib.get_user_data_dir(), ...GLib.get_system_data_dirs()] ++imports.searchPath = [ ++ GLib.get_user_data_dir(), ++ ...GLib.get_system_data_dirs(), ++ '@chinese_calendar_path@/.local/share' ++] + try { + // importing a "subdir" creates a new importer object that doesn't affect + // the global one +diff --git a/backend/ytliu0.js b/backend/ytliu0.js +index 94abd2c..df6241b 100644 +--- a/backend/ytliu0.js ++++ b/backend/ytliu0.js +@@ -60,7 +60,8 @@ class LunarDateX { + const [ok, file] = this._holidayData.load_from_dirs(holiday_fn, [ + GLib.get_user_config_dir(), + GLib.get_user_data_dir(), +- ...GLib.get_system_data_dirs() ++ ...GLib.get_system_data_dirs(), ++ '@chinese_calendar_path@/.config' + ], GLib.KeyFileFlags.KEEP_TRANSLATIONS) + if (this._notifyHoliday) + this._notifyHoliday()