mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-19 08:36:41 +01:00
Merge pull request #170293 from AtilaSaraiva/swaytools
swaytools: 0.1.0 -> 0.1.1
This commit is contained in:
commit
fbcf1314af
3 changed files with 9 additions and 67 deletions
|
@ -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)";
|
||||
|
|
|
@ -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)
|
|
@ -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 { };
|
||||
|
||||
|
|
Loading…
Reference in a new issue