From 0a4952e086b93ece70f282c39fa4d3f9ccd2f92d Mon Sep 17 00:00:00 2001 From: aleksana Date: Wed, 13 Mar 2024 19:01:04 +0800 Subject: [PATCH] devtoolbox: init at 1.1.1 --- .../devtoolbox/incompatible_ruamel_yaml.patch | 65 ++++++++++ pkgs/by-name/de/devtoolbox/package.nix | 118 ++++++++++++++++++ 2 files changed, 183 insertions(+) create mode 100644 pkgs/by-name/de/devtoolbox/incompatible_ruamel_yaml.patch create mode 100644 pkgs/by-name/de/devtoolbox/package.nix diff --git a/pkgs/by-name/de/devtoolbox/incompatible_ruamel_yaml.patch b/pkgs/by-name/de/devtoolbox/incompatible_ruamel_yaml.patch new file mode 100644 index 00000000000000..3bd6389e613252 --- /dev/null +++ b/pkgs/by-name/de/devtoolbox/incompatible_ruamel_yaml.patch @@ -0,0 +1,65 @@ +diff --git a/src/services/json_yaml.py b/src/services/json_yaml.py +index 619f69f..45fa8b8 100644 +--- a/src/services/json_yaml.py ++++ b/src/services/json_yaml.py +@@ -3,9 +3,9 @@ + # SPDX-License-Identifier: GPL-3.0-or-later + + from gi.repository import Gio, GObject +-from ruamel import yaml ++from ruamel.yaml import YAML + import json +- ++from io import StringIO + + class JsonYamlService(): + +@@ -25,15 +25,15 @@ class JsonYamlService(): + task.return_value(outcome) + + def _convert_json_to_yaml(self, json_str:str, indents:int) -> str: +- return yaml.dump( +- json.loads(json_str), +- indent=indents, +- default_flow_style=False +- ) ++ output_buffer = StringIO() ++ yaml = YAML(typ='unsafe', pure=True) ++ yaml.dump(json.loads(json_str), output_buffer) ++ return output_buffer.getvalue() + + def _convert_yaml_to_json(self, yaml_str:str, indents:int) -> str: ++ yaml = YAML(typ='rt') + return json.dumps( +- yaml.load(yaml_str, Loader=yaml.Loader), ++ yaml.load(yaml_str), + indent=indents, + ensure_ascii=False + ) +diff --git a/src/utils.py b/src/utils.py +index e2aecb1..b7a6821 100644 +--- a/src/utils.py ++++ b/src/utils.py +@@ -3,7 +3,7 @@ + # SPDX-License-Identifier: GPL-3.0-or-later + + from gi.repository import Gdk, GLib +-from ruamel import yaml ++from ruamel.yaml import YAML, YAMLError + from enum import Enum + from lxml import etree + from crontab import CronSlices +@@ -52,10 +52,11 @@ class Utils: + + @staticmethod + def is_yaml(test_input) -> bool: ++ yaml = YAML(typ='rt') + try: +- yaml.load(test_input, Loader=yaml.Loader) ++ yaml.load(test_input) + return True +- except yaml.YAMLError: ++ except YAMLError: + return False + + @staticmethod diff --git a/pkgs/by-name/de/devtoolbox/package.nix b/pkgs/by-name/de/devtoolbox/package.nix new file mode 100644 index 00000000000000..68e2c1924b575d --- /dev/null +++ b/pkgs/by-name/de/devtoolbox/package.nix @@ -0,0 +1,118 @@ +{ lib +, python3Packages +, fetchFromGitHub +, meson +, ninja +, pkg-config +, gobject-introspection +, blueprint-compiler +, wrapGAppsHook4 +, desktop-file-utils +, libadwaita +, gtksourceview5 +, webkitgtk_6_0 +, gcr_4 +, gdk-pixbuf +}: + +python3Packages.buildPythonApplication rec { + pname = "devtoolbox"; + version = "1.1.1"; + pyproject = false; + + src = fetchFromGitHub { + owner = "aleiepure"; + repo = "devtoolbox"; + rev = "v${version}"; + hash = "sha256-QFGEA+VhhRlvcch2AJrEzvRJGCSqtvZdMXWUvdAGkoU="; + }; + + # Upstream is using an incompatible version of ruamel.yaml + # May be removed in next update + patches = [ ./incompatible_ruamel_yaml.patch ]; + + nativeBuildInputs = [ + meson + ninja + pkg-config + gobject-introspection + blueprint-compiler + wrapGAppsHook4 + desktop-file-utils + ]; + + buildInputs = [ + libadwaita + gtksourceview5 + webkitgtk_6_0 + gcr_4 + gdk-pixbuf + ]; + + propagatedBuildInputs = with python3Packages; [ + pygobject3 + ruamel-yaml + lxml + python-crontab + jwt + jsonschema + pytz + tzlocal + python-lorem + uuid6 + textstat + markdown2 + daltonlens + asn1crypto + qrcode + sqlparse + jsbeautifier + cssbeautifier + humanize + croniter + python-dateutil + ]; + + dontWrapGApps = true; + + # Contains an unusable devtoolbox-run-script + postInstall = '' + rm -r $out/devtoolbox + ''; + + preFixup = '' + makeWrapperArgs+=("''${gappsWrapperArgs[@]}") + ''; + + meta = with lib; { + description = "Development tools at your fingertips"; + longDescription = '' + If you're tired of endlessly looking online for the right + tool, or to find again that website of which you don't + recall the name to do a quick conversion, this is the + right app for you. This is a collection of powerful yet + simple-to-use tools and utilities to solve the most common + daily development problems: + + - JSON to YAML converter and vice-versa + - CRON expressions parser + - Formatters for common languages + - Hash generators + - Regex tester + - Markdown Previewer + - Image converters + - Much more... + ''; + homepage = "https://github.com/aleiepure/devtoolbox"; + license = with licenses; [ + gpl3Plus + cc0 + lgpl3Only + mit + unlicense + ]; + mainProgram = "devtoolbox"; + maintainers = with maintainers; [ aleksana ]; + platforms = platforms.linux; # webkitgtk_6_0 is broken on darwin + }; +}