From 6bb0d9ac4547cbda1815621705a15ef4398d40db Mon Sep 17 00:00:00 2001 From: Kaeeraa Date: Sun, 5 Jan 2025 21:01:18 +0300 Subject: [PATCH] release v5.8.6 (#40) Co-authored-by: hand7s <117505144+s0me1newithhand7s@users.noreply.github.com> Co-authored-by: github-actions[bot] Co-authored-by: Yaroslav Malykh <37468176+fisuri@users.noreply.github.com> --- .github/workflows/treefmt.yml | 31 +++- .github/workflows/update-flake-lock.yml | 12 +- .markdownlint.json | 6 +- default.nix | 56 +++--- flake.nix | 31 ++-- nix/sources.json | 24 +-- nix/sources.nix | 221 +++++++++++++++--------- patch/cstring.patch | 12 ++ patch/desktop.patch | 13 -- treefmt.toml | 27 ++- 10 files changed, 260 insertions(+), 173 deletions(-) create mode 100644 patch/cstring.patch delete mode 100644 patch/desktop.patch diff --git a/.github/workflows/treefmt.yml b/.github/workflows/treefmt.yml index 9d8242e..7f6dcfd 100644 --- a/.github/workflows/treefmt.yml +++ b/.github/workflows/treefmt.yml @@ -1,23 +1,46 @@ name: Format Code -on: [push, pull_request] +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + workflow_dispatch: jobs: format: runs-on: ubuntu-latest - permissions: - contents: write - id-token: write + permissions: write-all steps: - name: Checkout repository uses: actions/checkout@v4 + with: + token: ${{ secrets.GITHUB_TOKEN }} - uses: ahmadnassri/action-workflow-queue@v1 - name: Install Nix uses: DeterminateSystems/nix-installer-action@main - uses: DeterminateSystems/magic-nix-cache-action@main - name: Install formatting tools run: nix-env -f "" -iA nixfmt-rfc-style treefmt yamlfmt jsonfmt markdownlint-cli + - name: Add new branch + run: git checkout -b treefmt-code - name: Run treefmt uses: isbecker/treefmt-action@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} version: 'latest' fail_on_change: 'false' + - name: Commit changes + run: | + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" + if ! git diff --quiet; then + git add . + git commit -m "refactor(*): automated formatting" + fi + - name: Push changes + uses: ad-m/github-push-action@master + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + branch: master + + + diff --git a/.github/workflows/update-flake-lock.yml b/.github/workflows/update-flake-lock.yml index e15fa4e..177d661 100644 --- a/.github/workflows/update-flake-lock.yml +++ b/.github/workflows/update-flake-lock.yml @@ -2,13 +2,14 @@ name: update-flake-lock on: workflow_dispatch: # allows manual triggering schedule: - - cron: '0 0 * * 0' # runs weekly on Sunday at 00:00 + - cron: "0 0 * * 0" # runs weekly on Sunday at 00:00 jobs: lockfile: runs-on: ubuntu-latest permissions: contents: read id-token: write + pull-requests: write steps: - name: Checkout repository uses: actions/checkout@v4 @@ -19,8 +20,13 @@ jobs: - name: Update flake.lock uses: DeterminateSystems/update-flake-lock@main with: - pr-title: "Update flake.lock" # Title of PR to be created - pr-reviewers: kaeeraa,s0me1newithhand7s + pr-title: "chore(flake.lock): Update flake.lock" # Title of PR to be created + pr-reviewers: s0me1newithhand7s pr-labels: | # Labels to be set on the PR low-prior automated + dependencies + nixpkgs-update + pr-body: | # Body of PR to be created + This PR updates the flake.lock file using [update-flake-lock](https://github.com/DeterminateSystems/update-flake-lock). + token: ${{ secrets.LOCK_UPDATE }} diff --git a/.markdownlint.json b/.markdownlint.json index f830962..958784c 100644 --- a/.markdownlint.json +++ b/.markdownlint.json @@ -1,5 +1,5 @@ { - "default": true, - "MD033": false, - "MD013": false + "default": true, + "MD033": false, + "MD013": false } diff --git a/default.nix b/default.nix index 206493e..57c67ef 100644 --- a/default.nix +++ b/default.nix @@ -1,6 +1,7 @@ { lib, fetchFromGitHub, + fetchpatch, callPackage, pkg-config, cmake, @@ -30,7 +31,7 @@ range-v3, tl-expected, hunspell, - webkitgtk_6_0, + webkitgtk_4_1, jemalloc, rnnoise, protobuf, @@ -62,7 +63,6 @@ sources ? import ./nix/sources.nix, system ? builtins.currentSystem, }: - let tg_owt = callPackage ./lib/tg_owt.nix { inherit stdenv; # oh no, stdenv @@ -72,7 +72,7 @@ let in stdenv.mkDerivation (finalAttrs: { pname = "ayugram-desktop"; - version = "5.6.3"; + version = "5.8.3"; src = fetchFromGitHub { owner = "AyuGram"; @@ -80,34 +80,36 @@ stdenv.mkDerivation (finalAttrs: { rev = "v${finalAttrs.version}"; fetchSubmodules = true; - hash = "sha256-Hon5qVJeQF/6y55lVKB0O87Du+DvCUYVdMjibgU0YM4="; + hash = "sha256-bgfqYI77kxHmFZB6LCdLzeIFv6bfsXXJrrkbz5MD6Q0="; }; patches = - [ ./patch/desktop.patch ] + [ + ./patch/cstring.patch + (fetchpatch { + url = "https://github.com/AyuGram/AyuGramDesktop/commit/8847034217487d992cd070c0ab791baa213b4141.patch"; + hash = "sha256-8q+K06wmG6TuBRomDSS9zWuM3PYQfMHpmIokw+bC3EY="; + }) + ] ++ lib.optionals stdenv.isDarwin [ ./patch/macos.patch - ./patch/macos-opengl.patch ]; - postPatch = - lib.optionalString stdenv.isLinux '' - for file in \ - Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.cpp \ - Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.cpp \ - Telegram/ThirdParty/libtgvoip/os/linux/AudioPulse.cpp \ - Telegram/lib_webview/webview/platform/linux/webview_linux_webkitgtk_library.cpp - do - substituteInPlace "$file" \ - --replace '"libasound.so.2"' '"${alsa-lib}/lib/libasound.so.2"' \ - --replace '"libpulse.so.0"' '"${libpulseaudio}/lib/libpulse.so.0"' \ - --replace '"libwebkitgtk-6.0.so.4"' '"${webkitgtk_6_0}/lib/libwebkitgtk-6.0.so.4"' - done - '' - + lib.optionalString stdenv.isDarwin '' - substituteInPlace Telegram/lib_webrtc/webrtc/platform/mac/webrtc_environment_mac.mm \ - --replace kAudioObjectPropertyElementMain kAudioObjectPropertyElementMaster - ''; + postPatch = lib.optionalString stdenv.hostPlatform.isLinux '' + substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioInputALSA.cpp \ + --replace-fail '"libasound.so.2"' '"${lib.getLib alsa-lib}/lib/libasound.so.2"' + substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioOutputALSA.cpp \ + --replace-fail '"libasound.so.2"' '"${lib.getLib alsa-lib}/lib/libasound.so.2"' + substituteInPlace Telegram/ThirdParty/libtgvoip/os/linux/AudioPulse.cpp \ + --replace-fail '"libpulse.so.0"' '"${lib.getLib libpulseaudio}/lib/libpulse.so.0"' + ''; + + qtWrapperArgs = lib.optionals stdenv.hostPlatform.isLinux [ + "--prefix" + "LD_LIBRARY_PATH" + ":" + (lib.makeLibraryPath [ webkitgtk_4_1 ]) + ]; # We want to run wrapProgram manually (with additional parameters) dontWrapGApps = true; @@ -172,7 +174,7 @@ stdenv.mkDerivation (finalAttrs: { libpulseaudio pipewire hunspell - webkitgtk_6_0 + webkitgtk_4_1 jemalloc tg_owt glib @@ -254,6 +256,10 @@ stdenv.mkDerivation (finalAttrs: { ln -s $out/Applications/${finalAttrs.meta.mainProgram}.app/Contents/MacOS/${finalAttrs.meta.mainProgram} $out/bin/${finalAttrs.meta.mainProgram} ''; + preFixup = '' + qtWrapperArgs+=("''${gappsWrapperArgs[@]}") + ''; + # This is necessary to run Telegram in a pure environment. # We also use gappsWrapperArgs from wrapGAppsHook. postFixup = diff --git a/flake.nix b/flake.nix index 4f2f510..c326929 100644 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,15 @@ url = "github:nixos/nixpkgs/nixos-unstable"; }; }; + nixConfig = { + sandbox = true; + extra-substituters = [ + "https://cache.garnix.io" + ]; + extra-trusted-public-keys = [ + "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" + ]; + }; outputs = { self, @@ -21,28 +30,24 @@ ] (system: function nixpkgs.legacyPackages.${system}); in { + overlays.ayugaram-desktop = ( + final: _prev: { + ayugram-desktop = self.packages; + } + ); nixosModules = { - default = self.nixosModules; + ayugram-desktop = self.overlays; + default = self.overlays; }; homeManagerModules = { - default = self.nixosModules; + ayugram-desktop = self.overlays; + default = self.overlays; }; packages = forAllSystems (pkgs: { ayugram-desktop = pkgs.libsForQt5.callPackage ./default.nix { }; }); - - nixConfig = { - sandbox = nixpkgs.stdenv.isLinux; - extra-substituters = [ - "https://cache.garnix.io" - ]; - extra-trusted-public-keys = [ - "cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g=" - ]; - }; }; - } diff --git a/nix/sources.json b/nix/sources.json index 4a7d648..93c2d92 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -1,14 +1,14 @@ { - "nixpkgs": { - "branch": "master", - "description": "Nix Packages collection & NixOS", - "homepage": "", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "5785b6bb5eaae44e627d541023034e1601455827", - "sha256": "19zq0d0n2j47kqg8i3wana4vqv5xn5qvvm5bv7wh3fp4yd8x7r18", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/5785b6bb5eaae44e627d541023034e1601455827.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" - } + "nixpkgs": { + "branch": "master", + "description": "Nix Packages collection & NixOS", + "homepage": "", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "5785b6bb5eaae44e627d541023034e1601455827", + "sha256": "19zq0d0n2j47kqg8i3wana4vqv5xn5qvvm5bv7wh3fp4yd8x7r18", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5785b6bb5eaae44e627d541023034e1601455827.tar.gz", + "url_template": "https://github.com///archive/.tar.gz" + } } diff --git a/nix/sources.nix b/nix/sources.nix index fe3dadf..0f0ef7e 100644 --- a/nix/sources.nix +++ b/nix/sources.nix @@ -6,131 +6,171 @@ let # The fetchers. fetch_ fetches specs of type . # - fetch_file = pkgs: name: spec: + fetch_file = + pkgs: name: spec: let name' = sanitizeName name + "-src"; in if spec.builtin or true then - builtins_fetchurl { inherit (spec) url sha256; name = name'; } + builtins_fetchurl { + inherit (spec) url sha256; + name = name'; + } else - pkgs.fetchurl { inherit (spec) url sha256; name = name'; }; + pkgs.fetchurl { + inherit (spec) url sha256; + name = name'; + }; - fetch_tarball = pkgs: name: spec: + fetch_tarball = + pkgs: name: spec: let name' = sanitizeName name + "-src"; in if spec.builtin or true then - builtins_fetchTarball { name = name'; inherit (spec) url sha256; } + builtins_fetchTarball { + name = name'; + inherit (spec) url sha256; + } else - pkgs.fetchzip { name = name'; inherit (spec) url sha256; }; + pkgs.fetchzip { + name = name'; + inherit (spec) url sha256; + }; - fetch_git = name: spec: + fetch_git = + name: spec: let ref = spec.ref or ( - if spec ? branch then "refs/heads/${spec.branch}" else - if spec ? tag then "refs/tags/${spec.tag}" else - abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!" + if spec ? branch then + "refs/heads/${spec.branch}" + else if spec ? tag then + "refs/tags/${spec.tag}" + else + abort "In git source '${name}': Please specify `ref`, `tag` or `branch`!" ); submodules = spec.submodules or false; submoduleArg = let nixSupportsSubmodules = builtins.compareVersions builtins.nixVersion "2.4" >= 0; emptyArgWithWarning = - if submodules - then - builtins.trace - ( - "The niv input \"${name}\" uses submodules " - + "but your nix's (${builtins.nixVersion}) builtins.fetchGit " - + "does not support them" - ) - { } - else { }; + if submodules then + builtins.trace ( + "The niv input \"${name}\" uses submodules " + + "but your nix's (${builtins.nixVersion}) builtins.fetchGit " + + "does not support them" + ) { } + else + { }; in - if nixSupportsSubmodules - then { inherit submodules; } - else emptyArgWithWarning; + if nixSupportsSubmodules then { inherit submodules; } else emptyArgWithWarning; in - builtins.fetchGit - ({ url = spec.repo; inherit (spec) rev; inherit ref; } // submoduleArg); + builtins.fetchGit ( + { + url = spec.repo; + inherit (spec) rev; + inherit ref; + } + // submoduleArg + ); fetch_local = spec: spec.path; - fetch_builtin-tarball = name: throw - ''[${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=tarball -a builtin=true''; + fetch_builtin-tarball = + name: + throw '' + [${name}] The niv type "builtin-tarball" is deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=tarball -a builtin=true''; - fetch_builtin-url = name: throw - ''[${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. - $ niv modify ${name} -a type=file -a builtin=true''; + fetch_builtin-url = + name: + throw '' + [${name}] The niv type "builtin-url" will soon be deprecated. You should instead use `builtin = true`. + $ niv modify ${name} -a type=file -a builtin=true''; # # Various helpers # # https://github.com/NixOS/nixpkgs/pull/83241/files#diff-c6f540a4f3bfa4b0e8b6bafd4cd54e8bR695 - sanitizeName = name: - ( - concatMapStrings (s: if builtins.isList s then "-" else s) - ( - builtins.split "[^[:alnum:]+._?=-]+" - ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) - ) - ); + sanitizeName = + name: + (concatMapStrings (s: if builtins.isList s then "-" else s) ( + builtins.split "[^[:alnum:]+._?=-]+" ((x: builtins.elemAt (builtins.match "\\.*(.*)" x) 0) name) + )); # The set of packages used when specs are fetched using non-builtins. - mkPkgs = sources: system: + mkPkgs = + sources: system: let - sourcesNixpkgs = - import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; + sourcesNixpkgs = import (builtins_fetchTarball { inherit (sources.nixpkgs) url sha256; }) { inherit system; }; hasNixpkgsPath = builtins.any (x: x.prefix == "nixpkgs") builtins.nixPath; hasThisAsNixpkgsPath = == ./.; in - if builtins.hasAttr "nixpkgs" sources - then sourcesNixpkgs - else if hasNixpkgsPath && ! hasThisAsNixpkgsPath then + if builtins.hasAttr "nixpkgs" sources then + sourcesNixpkgs + else if hasNixpkgsPath && !hasThisAsNixpkgsPath then import { } else - abort - '' - Please specify either (through -I or NIX_PATH=nixpkgs=...) or - add a package called "nixpkgs" to your sources.json. - ''; + abort '' + Please specify either (through -I or NIX_PATH=nixpkgs=...) or + add a package called "nixpkgs" to your sources.json. + ''; # The actual fetching function. - fetch = pkgs: name: spec: + fetch = + pkgs: name: spec: - if ! builtins.hasAttr "type" spec then + if !builtins.hasAttr "type" spec then abort "ERROR: niv spec ${name} does not have a 'type' attribute" - else if spec.type == "file" then fetch_file pkgs name spec - else if spec.type == "tarball" then fetch_tarball pkgs name spec - else if spec.type == "git" then fetch_git name spec - else if spec.type == "local" then fetch_local spec - else if spec.type == "builtin-tarball" then fetch_builtin-tarball name - else if spec.type == "builtin-url" then fetch_builtin-url name + else if spec.type == "file" then + fetch_file pkgs name spec + else if spec.type == "tarball" then + fetch_tarball pkgs name spec + else if spec.type == "git" then + fetch_git name spec + else if spec.type == "local" then + fetch_local spec + else if spec.type == "builtin-tarball" then + fetch_builtin-tarball name + else if spec.type == "builtin-url" then + fetch_builtin-url name else abort "ERROR: niv spec ${name} has unknown type ${builtins.toJSON spec.type}"; # If the environment variable NIV_OVERRIDE_${name} is set, then use # the path directly as opposed to the fetched source. - replace = name: drv: + replace = + name: drv: let saneName = stringAsChars (c: if (builtins.match "[a-zA-Z0-9]" c) == null then "_" else c) name; ersatz = builtins.getEnv "NIV_OVERRIDE_${saneName}"; in - if ersatz == "" then drv else - # this turns the string into an actual Nix path (for both absolute and - # relative paths) - if builtins.substring 0 1 ersatz == "/" then /. + ersatz else /. + builtins.getEnv "PWD" + "/${ersatz}"; + if ersatz == "" then + drv + else + # this turns the string into an actual Nix path (for both absolute and + # relative paths) + if builtins.substring 0 1 ersatz == "/" then + /. + ersatz + else + /. + builtins.getEnv "PWD" + "/${ersatz}"; # Ports of functions for older nix versions # a Nix version of mapAttrs if the built-in doesn't exist - mapAttrs = builtins.mapAttrs or ( - f: set: with builtins; - listToAttrs (map (attr: { name = attr; value = f attr set.${attr}; }) (attrNames set)) - ); + mapAttrs = + builtins.mapAttrs or ( + f: set: + with builtins; + listToAttrs ( + map (attr: { + name = attr; + value = f attr set.${attr}; + }) (attrNames set) + ) + ); # https://github.com/NixOS/nixpkgs/blob/0258808f5744ca980b9a1f24fe0b1e6f0fecee9c/lib/lists.nix#L295 range = first: last: if first > last then [ ] else builtins.genList (n: first + n) (last - first + 1); @@ -147,7 +187,12 @@ let optionalAttrs = cond: as: if cond then as else { }; # fetchTarball version that is compatible between all the versions of Nix - builtins_fetchTarball = { url, name ? null, sha256 }@attrs: + builtins_fetchTarball = + { + url, + name ? null, + sha256, + }@attrs: let inherit (builtins) lessThan nixVersion fetchTarball; in @@ -157,7 +202,12 @@ let fetchTarball attrs; # fetchurl version that is compatible between all the versions of Nix - builtins_fetchurl = { url, name ? null, sha256 }@attrs: + builtins_fetchurl = + { + url, + name ? null, + sha256, + }@attrs: let inherit (builtins) lessThan nixVersion fetchurl; in @@ -167,26 +217,25 @@ let fetchurl attrs; # Create the final "sources" from the config - mkSources = config: - mapAttrs - ( - name: spec: - if builtins.hasAttr "outPath" spec - then - abort - "The values in sources.json should not have an 'outPath' attribute" - else - spec // { outPath = replace name (fetch config.pkgs name spec); } - ) - config.sources; + mkSources = + config: + mapAttrs ( + name: spec: + if builtins.hasAttr "outPath" spec then + abort "The values in sources.json should not have an 'outPath' attribute" + else + spec // { outPath = replace name (fetch config.pkgs name spec); } + ) config.sources; # The "config" used by the fetchers mkConfig = - { sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null - , sources ? if sourcesFile == null then { } else builtins.fromJSON (builtins.readFile sourcesFile) - , system ? builtins.currentSystem - , pkgs ? mkPkgs sources system - }: rec { + { + sourcesFile ? if builtins.pathExists ./sources.json then ./sources.json else null, + sources ? if sourcesFile == null then { } else builtins.fromJSON (builtins.readFile sourcesFile), + system ? builtins.currentSystem, + pkgs ? mkPkgs sources system, + }: + rec { # The sources, i.e. the attribute set of spec name to spec inherit sources; diff --git a/patch/cstring.patch b/patch/cstring.patch new file mode 100644 index 0000000..5dad5d1 --- /dev/null +++ b/patch/cstring.patch @@ -0,0 +1,12 @@ +diff --git a/Telegram/lib_tl/tl/tl_basic_types.h b/Telegram/lib_tl/tl/tl_basic_types.h +index 5eadf62..e9b6da5 100644 +--- a/Telegram/lib_tl/tl/tl_basic_types.h ++++ b/Telegram/lib_tl/tl/tl_basic_types.h +@@ -11,6 +11,7 @@ + #include "base/bytes.h" + + #include ++#include + + namespace tl { + namespace details { diff --git a/patch/desktop.patch b/patch/desktop.patch deleted file mode 100644 index a2d897c..0000000 --- a/patch/desktop.patch +++ /dev/null @@ -1,13 +0,0 @@ -diff --git a/lib/xdg/com.ayugram.desktop.desktop b/lib/xdg/com.ayugram.desktop.desktop -index 3c5f7bde0..3e9e6f707 100644 ---- a/lib/xdg/com.ayugram.desktop.desktop -+++ b/lib/xdg/com.ayugram.desktop.desktop -@@ -2,7 +2,7 @@ - Name=AyuGram Desktop - Comment=Desktop version of AyuGram - ToS breaking Telegram client - TryExec=ayugram-desktop --Exec=DESKTOPINTEGRATION=1 ayugram-desktop -- %u -+Exec=ayugram-desktop -- %u - Icon=ayugram - Terminal=false - StartupWMClass=AyuGram diff --git a/treefmt.toml b/treefmt.toml index eab9ffe..9aa8a5b 100644 --- a/treefmt.toml +++ b/treefmt.toml @@ -1,26 +1,25 @@ -# One CLI to format the code tree - https://git.numtide.com/numtide/treefmt +# One CLI to format the code tree - https://github.com/numtide/treefmt [formatter.nix] -command = "nixfmt" -options = [ "-w 120", "-v" ] -includes = [ "*.nix" ] -excludes = [ "*.yaml", "*.yml", "*.json", "*.md" ] +command = "nixfmt" +options = ["-w 120", "-v"] +includes = ["*.nix"] +excludes = ["*.yaml", "*.yml", "*.json", "*.md", ".github/**"] [formatter.yaml] -command = "yamlfmt" -options = [ "" ] -includes = [ "*.yaml", "*.yml" ] -excludes = [ "*.nix", "*.json", "*.md" ] +command = "yamlfmt" +options = [""] +includes = ["*.yaml", "*.yml"] +excludes = ["*.nix", "*.json", "*.md", ".github/**"] [formatter.json] -command = "jsonfmt" -options = [ "-w" ] -includes = [ "*.json" ] -excludes = [ "*.nix", "*.yaml", "*.yml", "*.md" ] +command = "jsonfmt" +options = ["-w"] +includes = ["*.json"] +excludes = ["*.nix", "*.yaml", "*.yml", "*.md", ".github/**"] # [formatter.md] # command = "markdownlint" # options = [ "--disable", "MD013", "MD033", "--", "--fix"] # includes = [ "*.md" ] # excludes = [] -