From 04a165453ca69c02e2daf7d270b6b7e99bf0af96 Mon Sep 17 00:00:00 2001 From: Jorik Date: Thu, 31 Oct 2024 16:59:58 +0100 Subject: [PATCH] posting: init at 2.0.1 --- .../po/posting/allow-watchfiles-v22.patch | 17 ++ pkgs/by-name/po/posting/package.nix | 156 ++++++++++++++++++ 2 files changed, 173 insertions(+) create mode 100644 pkgs/by-name/po/posting/allow-watchfiles-v22.patch create mode 100644 pkgs/by-name/po/posting/package.nix diff --git a/pkgs/by-name/po/posting/allow-watchfiles-v22.patch b/pkgs/by-name/po/posting/allow-watchfiles-v22.patch new file mode 100644 index 0000000000000..f4b1360bc2e1e --- /dev/null +++ b/pkgs/by-name/po/posting/allow-watchfiles-v22.patch @@ -0,0 +1,17 @@ +diff --git a/pyproject.toml b/pyproject.toml +index cc30424..a5c6f26 100644 +--- a/pyproject.toml ++++ b/pyproject.toml +@@ -19,7 +19,8 @@ dependencies = [ + # pinned intentionally + "textual-autocomplete==3.0.0a12", + # pinned intentionally +- "watchfiles>=0.24.0", ++ ++ "watchfiles>=0.22.0", + ] + readme = "README.md" + requires-python = ">= 3.11" +-- +2.46.1 + diff --git a/pkgs/by-name/po/posting/package.nix b/pkgs/by-name/po/posting/package.nix new file mode 100644 index 0000000000000..df9e28b7fab4c --- /dev/null +++ b/pkgs/by-name/po/posting/package.nix @@ -0,0 +1,156 @@ +{ + lib, + fetchFromGitHub, + fetchPypi, + rustPlatform, + python3, +}: +let + py-pkgs = python3.pkgs; + + # Current nixpkgs version is too outdated + pydantic-settings = ( + py-pkgs.pydantic-settings.overrideAttrs (oldAttrs: rec { + version = "2.6.0"; + src = fetchFromGitHub { + owner = "pydantic"; + repo = "pydantic-settings"; + rev = "refs/tags/v${version}"; + hash = "sha256-gJThzYJg6OIkfmfi/4MVINsrvmg+Z+0xMhdlCj7Fn+w="; + }; + propagatedBuildInputs = [ + pydantic + py-pkgs.python-dotenv + ]; + }) + ); + + # Current nixpkgs version is too outdated + httpx = ( + py-pkgs.httpx.overrideAttrs (oldAttrs: rec { + version = "0.27.2"; + src = fetchFromGitHub { + owner = "encode"; + repo = oldAttrs.pname; + rev = "refs/tags/${version}"; + hash = "sha256-N0ztVA/KMui9kKIovmOfNTwwrdvSimmNkSvvC+3gpck="; + }; + nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ py-pkgs.zstandard ]; + }) + ); + + # Current nixpkgs version is too outdated + textual = ( + py-pkgs.textual.overrideAttrs (oldAttrs: rec { + version = "0.85.0"; + src = fetchFromGitHub { + owner = "Textualize"; + repo = "textual"; + rev = "refs/tags/v${version}"; + hash = "sha256-ROq/Pjq6XRgi9iqMlCzpLmgzJzLl21MI7148cOxHS3o="; + }; + }) + ); + + # Current nixpkgs version is too outdated + pydantic = ( + py-pkgs.pydantic.overrideAttrs (oldAttrs: rec { + version = "2.9.2"; + src = fetchFromGitHub { + owner = "pydantic"; + repo = "pydantic"; + rev = "refs/tags/v${version}"; + hash = "sha256-Eb/9k9bNizRyGhjbW/LAE/2R0Ino4DIRDy5ZrQuzJ7o="; + }; + propagatedBuildInputs = [ + pydantic-core + py-pkgs.annotated-types + py-pkgs.jsonschema + ]; + }) + ); + + # Exact version of core is required by pydantic + pydantic-core = ( + py-pkgs.pydantic-core.overrideAttrs (oldAttrs: rec { + version = "2.23.4"; + src = fetchFromGitHub { + owner = "pydantic"; + repo = "pydantic-core"; + rev = "refs/tags/v${version}"; + hash = "sha256-WSSwiqmdQN4zB7fqaniHyh4SHmrGeDHdCGpiSJZT7Mg="; + }; + + cargoDeps = rustPlatform.fetchCargoTarball { + inherit src; + name = "${oldAttrs.pname}-${version}"; + hash = "sha256-dX3wDnKQLmC+FabC0van3czkQLRcrBbtp9b90PgepZs="; + }; + + nativeBuildInputs = oldAttrs.nativeBuildInputs ++ [ py-pkgs.typing-extensions ]; + }) + ); + + # Not available in nixpkgs + textual-autocomplete = py-pkgs.buildPythonPackage rec { + pname = "textual_autocomplete"; + version = "3.0.0a12"; + pyproject = true; + # Alpha version of this package are only available on Pypi. + src = fetchPypi { + inherit pname version; + sha256 = "sha256-HSyeTSTH9XWryMYSy2q//0cG9qqrm5OVBrldroRUkwk="; + }; + + nativeBuildInputs = [ py-pkgs.poetry-core ]; + + dependencies = [ + textual + py-pkgs.typing-extensions + ]; + }; +in +python3.pkgs.buildPythonApplication rec { + pname = "posting"; + version = "2.0.1"; + pyproject = true; + + src = fetchFromGitHub { + owner = "darrenburns"; + repo = "posting"; + rev = "refs/tags/${version}"; + sha256 = "sha256-6KtC5VuG3x07VTenpyDAJr9KO4jdTCFk1u/pSoyYPsc="; + }; + + # We patch the pyproject.toml to allow a slightly outdated watchfiles dependency. + # The correct version is not in nixpkgs yet and overriding the version is not trivial. + # (i tried) + patches = [ ./allow-watchfiles-v22.patch ]; + + nativeBuildInputs = [ python3.pkgs.hatchling ]; + + propagatedBuildInputs = [ + py-pkgs.click + py-pkgs.xdg-base-dirs + py-pkgs.click-default-group + py-pkgs.pyperclip + py-pkgs.pyyaml + py-pkgs.python-dotenv + py-pkgs.watchfiles + + pydantic + pydantic-settings + textual + textual-autocomplete + httpx + ]; + + meta = { + description = "The modern API client that lives in your terminal."; + mainProgram = "posting"; + homepage = "https://posting.sh/"; + license = lib.licenses.asl20; + maintainers = with lib.maintainers; [ jorikvanveen ]; + platforms = lib.platforms.unix; + }; +}