about summary refs log tree commit diff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--modules/common/nix.nix147
-rw-r--r--modules/firefox/default.nix6
-rw-r--r--overlays.nix4
-rw-r--r--packages/telegram-desktop.patch296
-rw-r--r--packages/vesktop.patch (renamed from patches/vesktop-no-anime.patch)0
-rw-r--r--patches/telegram-desktop-no-ads.patch45
6 files changed, 375 insertions, 123 deletions
diff --git a/modules/common/nix.nix b/modules/common/nix.nix
index 01b3f01..efd06bd 100644
--- a/modules/common/nix.nix
+++ b/modules/common/nix.nix
@@ -22,93 +22,98 @@ in
     default = [ ];
   };
 
-  config =
-    let
+  config = {
+    _module.args = {
       pkgsLocal = packages.useNixpkgs "${config.my.home}/src/nixpkgs"; # Impure!
-    in
-    {
-      _module.args = {
-        inherit pkgsLocal;
-      };
-
-      hm = {
-        # Used primarily in conjunction with the "nixfiles" script.
-        home.file.".nix-defexpr/default.nix".text =
-          let
-            hostname = strings.escapeNixIdentifier this.hostname;
-          in
-          optionalString this.isHeadful ''
-            let
-              self = builtins.getFlake "nixfiles";
-              configurations = self.nixosConfigurations;
-              local = configurations.${hostname};
-            in rec {
-              inherit self;
-              inherit (self) inputs lib;
-              inherit (lib) my;
-              this = my.configurations.${hostname};
-              inherit (local) config;
-              inherit (local.config.system.build) toplevel vm vmWithBootLoader manual;
-              pretty = expr: lib.trace (lib.generators.toPretty {} expr) {};
-            } // configurations // local._module.args
-          '';
-
-        programs.bash.shellAliases.nix = "nix --verbose --print-build-logs";
-      };
+    };
 
-      nix =
+    hm = {
+      # Used primarily in conjunction with the "nixfiles" script.
+      home.file.".nix-defexpr/default.nix".text =
         let
-          notSelfInputs = filterAttrs (n: _: n != "self") inputs;
+          hostname = strings.escapeNixIdentifier this.hostname;
         in
-        {
-          nixPath = mapAttrsToList (n: v: "${n}=${v}") notSelfInputs ++ [
-            "nixfiles=${config.my.home}/src/nixfiles"
-          ];
+        optionalString this.isHeadful ''
+          let
+            self = builtins.getFlake "nixfiles";
+            configurations = self.nixosConfigurations;
+            local = configurations.${hostname};
+          in rec {
+            inherit self;
+            inherit (self) inputs lib;
+            inherit (lib) my;
+            this = my.configurations.${hostname};
+            inherit (local) config;
+            inherit (local.config.system.build) toplevel vm vmWithBootLoader manual;
+            pretty = expr: lib.trace (lib.generators.toPretty {} expr) {};
+          } // configurations // local._module.args
+        '';
 
-          registry = mapAttrs (_: flake: { inherit flake; }) notSelfInputs // {
-            nixfiles.flake = inputs.self;
-          };
+      programs.bash.shellAliases.nix = "nix --verbose --print-build-logs";
+    };
 
-          settings = {
-            warn-dirty = false;
+    nix =
+      let
+        notSelfInputs = filterAttrs (n: _: n != "self") inputs;
+      in
+      {
+        nixPath = mapAttrsToList (n: v: "${n}=${v}") notSelfInputs ++ [
+          "nixfiles=${config.my.home}/src/nixfiles"
+        ];
 
-            keep-going = true;
+        registry = mapAttrs (_: flake: { inherit flake; }) notSelfInputs // {
+          nixfiles.flake = inputs.self;
+        };
 
-            substituters = [
-              "https://azahi.cachix.org"
-              "https://nix-community.cachix.org"
-            ];
+        settings = {
+          warn-dirty = false;
 
-            trusted-substituters = [ "https://azahi.cachix.org" ];
-            trusted-public-keys = [ "azahi.cachix.org-1:2bayb+iWYMAVw3ZdEpVg+NPOHCXncw7WMQ0ElX1GO3s=" ];
+          keep-going = true;
 
-            trusted-users = [
-              "root"
-              my.username
-            ];
-          };
-        };
+          substituters = [
+            "https://azahi.cachix.org"
+            "https://nix-community.cachix.org"
+          ];
 
-      nixpkgs = {
-        config.allowUnfreePredicate = p: elem (getName p) cfg.allowedUnfreePackages;
+          trusted-substituters = [ "https://azahi.cachix.org" ];
+          trusted-public-keys = [ "azahi.cachix.org-1:2bayb+iWYMAVw3ZdEpVg+NPOHCXncw7WMQ0ElX1GO3s=" ];
 
-        overlays = [ inputs.self.overlays.default ];
-      };
+          trusted-users = [
+            "root"
+            my.username
+          ];
 
-      environment = {
-        defaultPackages = [ ];
-        systemPackages =
-          with pkgs;
-          optionals this.isHeadful [
-            nix-tree
-            nixfiles
+          experimental-features = mkForce [
+            "auto-allocate-uids"
+            "cgroups"
+            "fetch-closure"
+            "flakes"
+            "nix-command"
+            "recursive-nix"
           ];
-        variables = {
-          NIXFILES = optionalString this.isHeadful "${config.my.home}/src/nixfiles";
-          NIX_SHELL_PRESERVE_PROMPT = "1";
         };
       };
 
-      system.stateVersion = this.stateVersion or trivial.release;
+    nixpkgs = {
+      config.allowUnfreePredicate = p: elem (getName p) cfg.allowedUnfreePackages;
+
+      overlays = [ inputs.self.overlays.default ];
     };
+
+    environment = {
+      defaultPackages = [ ];
+      systemPackages =
+        with pkgs;
+        optionals this.isHeadful [
+          nix-tree
+          nixfiles
+        ];
+      variables = {
+        NIXFILES = optionalString this.isHeadful "${config.my.home}/src/nixfiles";
+        NIX_SHELL_PRESERVE_PROMPT = "1";
+      };
+    };
+
+    system.stateVersion = this.stateVersion or trivial.release;
+  };
 }
diff --git a/modules/firefox/default.nix b/modules/firefox/default.nix
index d51bd66..7b69da4 100644
--- a/modules/firefox/default.nix
+++ b/modules/firefox/default.nix
@@ -141,11 +141,7 @@ in
               force = true;
 
               default = "DuckDuckGo";
-              order = [
-                "DuckDuckGo"
-                "Yandex"
-                "Google"
-              ];
+              order = [ "DuckDuckGo" ];
 
               engines =
                 let
diff --git a/overlays.nix b/overlays.nix
index e0cbf24..5e7ce81 100644
--- a/overlays.nix
+++ b/overlays.nix
@@ -70,13 +70,13 @@ with packages;
       (prev.telegram-desktop.override (finalAttrs: {
         stdenv = final.useMoldLinker finalAttrs.stdenv;
       })).overrideAttrs
-        (_: super: { patches = (super.patches or [ ]) ++ [ ./patches/telegram-desktop-no-ads.patch ]; });
+        (_: super: { patches = (super.patches or [ ]) ++ [ ./packages/telegram-desktop.patch ]; });
 
     vesktop =
       (prev.vesktop.overrideAttrs (
         _: super: {
           nativeBuildInputs = super.nativeBuildInputs ++ [ final.imagemagick ];
-          patches = (super.patches or [ ]) ++ [ ./patches/vesktop-no-anime.patch ];
+          patches = (super.patches or [ ]) ++ [ ./packages/vesktop.patch ];
           postInstall =
             (super.postInstall or "")
             + ''
diff --git a/packages/telegram-desktop.patch b/packages/telegram-desktop.patch
new file mode 100644
index 0000000..8fe272b
--- /dev/null
+++ b/packages/telegram-desktop.patch
@@ -0,0 +1,296 @@
+diff --git i/Telegram/SourceFiles/core/click_handler_types.cpp w/Telegram/SourceFiles/core/click_handler_types.cpp
+index 9b03e0b74..25af14f67 100644
+--- i/Telegram/SourceFiles/core/click_handler_types.cpp
++++ w/Telegram/SourceFiles/core/click_handler_types.cpp
+@@ -345,9 +345,7 @@ void MonospaceClickHandler::onClick(ClickContext context) const {
+ 	if (const auto controller = my.sessionWindow.get()) {
+ 		auto &data = controller->session().data();
+ 		const auto item = data.message(my.itemId);
+-		const auto hasCopyRestriction = item
+-			&& (!item->history()->peer->allowsForwarding()
+-				|| item->forbidsForward());
++		const auto hasCopyRestriction = false;
+ 		if (hasCopyRestriction) {
+ 			controller->showToast(item->history()->peer->isBroadcast()
+ 				? tr::lng_error_nocopy_channel(tr::now)
+diff --git i/Telegram/SourceFiles/data/components/sponsored_messages.cpp w/Telegram/SourceFiles/data/components/sponsored_messages.cpp
+index c20ec967e..bb3de6794 100644
+--- i/Telegram/SourceFiles/data/components/sponsored_messages.cpp
++++ w/Telegram/SourceFiles/data/components/sponsored_messages.cpp
+@@ -193,7 +193,7 @@ void SponsoredMessages::inject(
+ }
+ 
+ bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
+-	return history->peer->isChannel();
++	return false;
+ }
+ 
+ void SponsoredMessages::request(not_null<History*> history, Fn<void()> done) {
+diff --git i/Telegram/SourceFiles/data/data_channel.cpp w/Telegram/SourceFiles/data/data_channel.cpp
+index 2f7694395..4468729e1 100644
+--- i/Telegram/SourceFiles/data/data_channel.cpp
++++ w/Telegram/SourceFiles/data/data_channel.cpp
+@@ -884,7 +884,7 @@ void ChannelData::clearInvitePeek() {
+ }
+ 
+ TimeId ChannelData::invitePeekExpires() const {
+-	return _invitePeek ? _invitePeek->expires : 0;
++	return 0;
+ }
+ 
+ QString ChannelData::invitePeekHash() const {
+diff --git i/Telegram/SourceFiles/data/data_stories.cpp w/Telegram/SourceFiles/data/data_stories.cpp
+index 668ec4c45..0a738e229 100644
+--- i/Telegram/SourceFiles/data/data_stories.cpp
++++ w/Telegram/SourceFiles/data/data_stories.cpp
+@@ -442,70 +442,7 @@ Story *Stories::parseAndApply(
+ 		not_null<PeerData*> peer,
+ 		const MTPDstoryItem &data,
+ 		TimeId now) {
+-	const auto media = ParseMedia(_owner, data.vmedia());
+-	if (!media) {
+-		return nullptr;
+-	}
+-	const auto expires = data.vexpire_date().v;
+-	const auto expired = (expires <= now);
+-	if (expired && !data.is_pinned() && !hasArchive(peer)) {
+-		return nullptr;
+-	}
+-	const auto id = data.vid().v;
+-	const auto fullId = FullStoryId{ peer->id, id };
+-	auto &stories = _stories[peer->id];
+-	const auto i = stories.find(id);
+-	if (i != end(stories)) {
+-		const auto result = i->second.get();
+-		const auto mediaChanged = (result->media() != *media);
+-		result->applyChanges(*media, data, now);
+-		const auto j = _pollingSettings.find(result);
+-		if (j != end(_pollingSettings)) {
+-			maybeSchedulePolling(result, j->second, now);
+-		}
+-		if (mediaChanged) {
+-			_preloaded.remove(fullId);
+-			if (_preloading && _preloading->id() == fullId) {
+-				_preloading = nullptr;
+-				rebuildPreloadSources(StorySourcesList::NotHidden);
+-				rebuildPreloadSources(StorySourcesList::Hidden);
+-				continuePreloading();
+-			}
+-			_owner->refreshStoryItemViews(fullId);
+-		}
+-		return result;
+-	}
+-	const auto wasDeleted = _deleted.remove(fullId);
+-	const auto result = stories.emplace(id, std::make_unique<Story>(
+-		id,
+-		peer,
+-		StoryMedia{ *media },
+-		data,
+-		now
+-	)).first->second.get();
+-
+-	if (const auto archive = lookupArchive(peer)) {
+-		const auto added = archive->ids.list.emplace(id).second;
+-		if (added) {
+-			if (archive->total >= 0 && id > archive->lastId) {
+-				++archive->total;
+-			}
+-			_archiveChanged.fire_copy(peer->id);
+-		}
+-	}
+-
+-	if (expired) {
+-		_expiring.remove(expires, fullId);
+-		applyExpired(fullId);
+-	} else {
+-		registerExpiring(expires, fullId);
+-	}
+-
+-	if (wasDeleted) {
+-		_owner->refreshStoryItemViews(fullId);
+-	}
+-
+-	return result;
++	return nullptr;
+ }
+ 
+ StoryIdDates Stories::parseAndApply(
+diff --git i/Telegram/SourceFiles/history/history_inner_widget.cpp w/Telegram/SourceFiles/history/history_inner_widget.cpp
+index 1a302bd10..44ecffbed 100644
+--- i/Telegram/SourceFiles/history/history_inner_widget.cpp
++++ w/Telegram/SourceFiles/history/history_inner_widget.cpp
+@@ -558,14 +558,7 @@ void HistoryInner::setupSharingDisallowed() {
+ }
+ 
+ bool HistoryInner::hasSelectRestriction() const {
+-	if (!_sharingDisallowed.current()) {
+-		return false;
+-	} else if (const auto chat = _peer->asChat()) {
+-		return !chat->canDeleteMessages();
+-	} else if (const auto channel = _peer->asChannel()) {
+-		return !channel->canDeleteMessages();
+-	}
+-	return true;
++	return false;
+ }
+ 
+ void HistoryInner::messagesReceived(
+@@ -2844,12 +2837,12 @@ void HistoryInner::showContextMenu(QContextMenuEvent *e, bool showFromTouch) {
+ }
+ 
+ bool HistoryInner::hasCopyRestriction(HistoryItem *item) const {
+-	return !_peer->allowsForwarding() || (item && item->forbidsForward());
++	return false;
+ }
+ 
+ bool HistoryInner::hasCopyMediaRestriction(
+ 		not_null<HistoryItem*> item) const {
+-	return hasCopyRestriction(item) || item->forbidsSaving();
++	return false;
+ }
+ 
+ bool HistoryInner::showCopyRestriction(HistoryItem *item) {
+diff --git i/Telegram/SourceFiles/history/history_item.cpp w/Telegram/SourceFiles/history/history_item.cpp
+index d9c306013..5fcd7d02b 100644
+--- i/Telegram/SourceFiles/history/history_item.cpp
++++ w/Telegram/SourceFiles/history/history_item.cpp
+@@ -2243,11 +2243,6 @@ bool HistoryItem::forbidsForward() const {
+ }
+ 
+ bool HistoryItem::forbidsSaving() const {
+-	if (forbidsForward()) {
+-		return true;
+-	} else if (const auto invoice = _media ? _media->invoice() : nullptr) {
+-		return HasExtendedMedia(*invoice);
+-	}
+ 	return false;
+ }
+ 
+diff --git i/Telegram/SourceFiles/history/view/history_view_list_widget.cpp w/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
+index 4155adf9b..1775ef4f4 100644
+--- i/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
++++ w/Telegram/SourceFiles/history/view/history_view_list_widget.cpp
+@@ -1515,13 +1515,11 @@ bool ListWidget::isEmpty() const {
+ }
+ 
+ bool ListWidget::hasCopyRestriction(HistoryItem *item) const {
+-	return _delegate->listCopyRestrictionType(item)
+-		!= CopyRestrictionType::None;
++	return false;
+ }
+ 
+ bool ListWidget::hasCopyMediaRestriction(not_null<HistoryItem*> item) const {
+-	return _delegate->listCopyMediaRestrictionType(item)
+-		!= CopyRestrictionType::None;
++	return false;
+ }
+ 
+ bool ListWidget::showCopyRestriction(HistoryItem *item) {
+@@ -1547,21 +1545,6 @@ bool ListWidget::showCopyMediaRestriction(not_null<HistoryItem*> item) {
+ }
+ 
+ bool ListWidget::hasCopyRestrictionForSelected() const {
+-	if (hasCopyRestriction()) {
+-		return true;
+-	}
+-	if (_selected.empty()) {
+-		if (_selectedTextItem && _selectedTextItem->forbidsForward()) {
+-			return true;
+-		}
+-	}
+-	for (const auto &[itemId, selection] : _selected) {
+-		if (const auto item = session().data().message(itemId)) {
+-			if (item->forbidsForward()) {
+-				return true;
+-			}
+-		}
+-	}
+ 	return false;
+ }
+ 
+@@ -1580,8 +1563,7 @@ bool ListWidget::showCopyRestrictionForSelected() {
+ }
+ 
+ bool ListWidget::hasSelectRestriction() const {
+-	return _delegate->listSelectRestrictionType()
+-		!= CopyRestrictionType::None;
++	return false;
+ }
+ 
+ Element *ListWidget::lookupItemByY(int y) const {
+diff --git i/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp w/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
+index 92bd21800..297ddf1f2 100644
+--- i/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
++++ w/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp
+@@ -1240,15 +1240,14 @@ void TopBarWidget::updateMembersShowArea() {
+ }
+ 
+ bool TopBarWidget::showSelectedState() const {
+-	return (_selectedCount > 0)
+-		&& (_canDelete || _canForward || _canSendNow);
++	return _selectedCount > 0;
+ }
+ 
+ void TopBarWidget::showSelected(SelectedState state) {
+ 	auto canDelete = (state.count > 0 && state.count == state.canDeleteCount);
+ 	auto canForward = (state.count > 0 && state.count == state.canForwardCount);
+ 	auto canSendNow = (state.count > 0 && state.count == state.canSendNowCount);
+-	auto count = (!canDelete && !canForward && !canSendNow) ? 0 : state.count;
++	auto count = state.count;
+ 	if (_selectedCount == count
+ 		&& _canDelete == canDelete
+ 		&& _canForward == canForward
+diff --git i/Telegram/SourceFiles/info/media/info_media_provider.cpp w/Telegram/SourceFiles/info/media/info_media_provider.cpp
+index 2fc69733e..2e830b73e 100644
+--- i/Telegram/SourceFiles/info/media/info_media_provider.cpp
++++ w/Telegram/SourceFiles/info/media/info_media_provider.cpp
+@@ -88,14 +88,7 @@ Type Provider::type() {
+ }
+ 
+ bool Provider::hasSelectRestriction() {
+-	if (_peer->allowsForwarding()) {
+-		return false;
+-	} else if (const auto chat = _peer->asChat()) {
+-		return !chat->canDeleteMessages();
+-	} else if (const auto channel = _peer->asChannel()) {
+-		return !channel->canDeleteMessages();
+-	}
+-	return true;
++	return false;
+ }
+ 
+ rpl::producer<bool> Provider::hasSelectRestrictionChanges() {
+diff --git i/Telegram/SourceFiles/main/main_domain.h w/Telegram/SourceFiles/main/main_domain.h
+index 2e69222b9..b3e08fd66 100644
+--- i/Telegram/SourceFiles/main/main_domain.h
++++ w/Telegram/SourceFiles/main/main_domain.h
+@@ -31,8 +31,8 @@ public:
+ 		std::unique_ptr<Account> account;
+ 	};
+ 
+-	static constexpr auto kMaxAccounts = 3;
+-	static constexpr auto kPremiumMaxAccounts = 6;
++	static constexpr auto kMaxAccounts = 255;
++	static constexpr auto kPremiumMaxAccounts = 255;
+ 
+ 	explicit Domain(const QString &dataName);
+ 	~Domain();
+diff --git i/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp w/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
+index c6a7e9c6e..88c4d66ef 100644
+--- i/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
++++ w/Telegram/SourceFiles/media/view/media_view_overlay_widget.cpp
+@@ -1033,13 +1033,7 @@ QSize OverlayWidget::flipSizeByRotation(QSize size) const {
+ }
+ 
+ bool OverlayWidget::hasCopyMediaRestriction(bool skipPremiumCheck) const {
+-	if (const auto story = _stories ? _stories->story() : nullptr) {
+-		return skipPremiumCheck
+-			? !story->canDownloadIfPremium()
+-			: !story->canDownloadChecked();
+-	}
+-	return (_history && !_history->peer->allowsForwarding())
+-		|| (_message && _message->forbidsSaving());
++	return false;
+ }
+ 
+ bool OverlayWidget::showCopyMediaRestriction(bool skipPRemiumCheck) {
diff --git a/patches/vesktop-no-anime.patch b/packages/vesktop.patch
index 5fd97ef..5fd97ef 100644
--- a/patches/vesktop-no-anime.patch
+++ b/packages/vesktop.patch
diff --git a/patches/telegram-desktop-no-ads.patch b/patches/telegram-desktop-no-ads.patch
deleted file mode 100644
index 2a88cbf..0000000
--- a/patches/telegram-desktop-no-ads.patch
+++ /dev/null
@@ -1,45 +0,0 @@
-diff --git i/Telegram/SourceFiles/data/components/sponsored_messages.cpp w/Telegram/SourceFiles/data/components/sponsored_messages.cpp
-index a60d7c3fd..070694b64 100644
---- i/Telegram/SourceFiles/data/components/sponsored_messages.cpp
-+++ w/Telegram/SourceFiles/data/components/sponsored_messages.cpp
-@@ -185,39 +185,7 @@ bool SponsoredMessages::canHaveFor(not_null<History*> history) const {
- }
- 
- void SponsoredMessages::request(not_null<History*> history, Fn<void()> done) {
--	if (!canHaveFor(history)) {
--		return;
--	}
--	auto &request = _requests[history];
--	if (request.requestId || TooEarlyForRequest(request.lastReceived)) {
--		return;
--	}
--	{
--		const auto it = _data.find(history);
--		if (it != end(_data)) {
--			auto &list = it->second;
--			// Don't rebuild currently displayed messages.
--			const auto proj = [](const Entry &e) {
--				return e.item != nullptr;
--			};
--			if (ranges::any_of(list.entries, proj)) {
--				return;
--			}
--		}
--	}
--	const auto channel = history->peer->asChannel();
--	Assert(channel != nullptr);
--	request.requestId = _session->api().request(
--		MTPchannels_GetSponsoredMessages(
--			channel->inputChannel)
--	).done([=](const MTPmessages_sponsoredMessages &result) {
--		parse(history, result);
--		if (done) {
--			done();
--		}
--	}).fail([=] {
--		_requests.remove(history);
--	}).send();
-+	return;
- }
- 
- void SponsoredMessages::parse(

Consider giving Nix/NixOS a try! <3