From c6ecf3733804e7ff62f92650b45d6f7837c4a40d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81tila=20Saraiva?= Date: Mon, 25 Apr 2022 14:13:06 -0300 Subject: [PATCH] swaytools: 0.1.0 -> 0.1.1 --- pkgs/tools/wayland/swaytools/default.nix | 16 +++---- pkgs/tools/wayland/swaytools/update.py | 58 ------------------------ pkgs/top-level/all-packages.nix | 2 +- 3 files changed, 9 insertions(+), 67 deletions(-) delete mode 100755 pkgs/tools/wayland/swaytools/update.py diff --git a/pkgs/tools/wayland/swaytools/default.nix b/pkgs/tools/wayland/swaytools/default.nix index 4c254c9a5932..e4584436c4eb 100644 --- a/pkgs/tools/wayland/swaytools/default.nix +++ b/pkgs/tools/wayland/swaytools/default.nix @@ -1,18 +1,18 @@ -{ lib, python3Packages, slurp }: +{ lib, buildPythonApplication, fetchFromGitHub, slurp }: -python3Packages.buildPythonApplication rec { +buildPythonApplication rec { pname = "swaytools"; - version = "0.1.0"; + version = "0.1.1"; - src = python3Packages.fetchPypi { - inherit pname version; - sha256 = "1eb89259cbe027a0fa6bfc06ecf94e89b15e6f7b4965104e5b661c916ce7408c"; + src = fetchFromGitHub { + owner = "tmccombs"; + repo = "swaytools"; + rev = version; + sha256 = "sha256-6Ec7MPqBia0PW+pBTAItLusWMg1wlFfEaxoh20/2uHg="; }; propagatedBuildInputs = [ slurp ]; - passthru.updateScript = ./update.py; - meta = with lib; { homepage = "https://github.com/tmccombs/swaytools"; description = "Collection of simple tools for sway (and i3)"; diff --git a/pkgs/tools/wayland/swaytools/update.py b/pkgs/tools/wayland/swaytools/update.py deleted file mode 100755 index 141566848e38..000000000000 --- a/pkgs/tools/wayland/swaytools/update.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env nix-shell -#!nix-shell -i python -p python39Packages.requests python39Packages.pip python39Packages.packaging - -import requests -import json -import subprocess -try: - from packaging.version import parse -except ImportError: - from pip._vendor.packaging.version import parse - - -URL_PATTERN = 'https://pypi.python.org/pypi/{package}/json' - -def findLine(key,derivation): - count = 0 - lines = [] - for line in derivation: - if key in line: - lines.append(count) - count += 1 - return lines - -def get_version(package, url_pattern=URL_PATTERN): - """Return version of package on pypi.python.org using json.""" - req = requests.get(url_pattern.format(package=package)) - version = parse('0') - if req.status_code == requests.codes.ok: - j = json.loads(req.text.encode(req.encoding)) - releases = j.get('releases', []) - for release in releases: - ver = parse(release) - if not ver.is_prerelease: - if ver > version: - version = ver - sha256 = j["releases"][release][-1]["digests"]["sha256"] - return version, sha256 - - -if __name__ == '__main__': - - nixpkgs = subprocess.check_output(["git", "rev-parse", "--show-toplevel"]).decode("utf-8").strip('\n') - swaytoolsFolder = "/pkgs/tools/wayland/swaytools/" - with open(nixpkgs + swaytoolsFolder + "default.nix", 'r') as arq: - derivation = arq.readlines() - - version, sha256 = get_version('swaytools') - - key = "version = " - line = findLine(key,derivation)[0] - derivation[line] = f' version = "{version}";\n' - - key = "sha256 = " - line = findLine(key,derivation)[0] - derivation[line] = f' sha256 = "{sha256}";\n' - - with open(nixpkgs + swaytoolsFolder + "default.nix", 'w') as arq: - arq.writelines(derivation) diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index e8e0de86d1ff..bd53de8e2866 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -3014,7 +3014,7 @@ with pkgs; swaysome = callPackage ../tools/wayland/swaysome { }; - swaytools = callPackage ../tools/wayland/swaytools { }; + swaytools = python3Packages.callPackage ../tools/wayland/swaytools { }; wayland-utils = callPackage ../tools/wayland/wayland-utils { };