mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-27 17:33:09 +00:00
swaytools: init at 0.1.0
This commit is contained in:
parent
a31699dce9
commit
e93bb42cd7
22
pkgs/tools/wayland/swaytools/default.nix
Normal file
22
pkgs/tools/wayland/swaytools/default.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{ lib, python3Packages, slurp }:
|
||||
|
||||
python3Packages.buildPythonApplication rec {
|
||||
pname = "swaytools";
|
||||
version = "0.1.0";
|
||||
|
||||
src = python3Packages.fetchPypi {
|
||||
inherit pname version;
|
||||
sha256 = "1eb89259cbe027a0fa6bfc06ecf94e89b15e6f7b4965104e5b661c916ce7408c";
|
||||
};
|
||||
|
||||
propagatedBuildInputs = [ slurp ];
|
||||
|
||||
passthru.updateScript = ./update.py;
|
||||
|
||||
meta = with lib; {
|
||||
homepage = "https://github.com/tmccombs/swaytools";
|
||||
description = "Collection of simple tools for sway (and i3)";
|
||||
license = licenses.gpl3Only;
|
||||
maintainers = with maintainers; [ atila ];
|
||||
};
|
||||
}
|
58
pkgs/tools/wayland/swaytools/update.py
Executable file
58
pkgs/tools/wayland/swaytools/update.py
Executable file
@ -0,0 +1,58 @@
|
||||
#!/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)
|
@ -2642,6 +2642,8 @@ with pkgs;
|
||||
|
||||
swayr = callPackage ../tools/wayland/swayr { };
|
||||
|
||||
swaytools = callPackage ../tools/wayland/swaytools { };
|
||||
|
||||
wayland-utils = callPackage ../tools/wayland/wayland-utils { };
|
||||
|
||||
wayland-proxy-virtwl = callPackage ../tools/wayland/wayland-proxy-virtwl { };
|
||||
|
Loading…
Reference in New Issue
Block a user