diff options
Diffstat (limited to 'nixpkgs/pkgs/applications/misc/bottles')
-rw-r--r-- | nixpkgs/pkgs/applications/misc/bottles/default.nix | 19 | ||||
-rwxr-xr-x | nixpkgs/pkgs/applications/misc/bottles/update.py | 65 |
2 files changed, 79 insertions, 5 deletions
diff --git a/nixpkgs/pkgs/applications/misc/bottles/default.nix b/nixpkgs/pkgs/applications/misc/bottles/default.nix index 865e3a849a1d..b0b1718c87b5 100644 --- a/nixpkgs/pkgs/applications/misc/bottles/default.nix +++ b/nixpkgs/pkgs/applications/misc/bottles/default.nix @@ -4,7 +4,7 @@ , python3Packages, gettext , appstream-glib, gdk-pixbuf, glib, gobject-introspection, gspell, gtk3, gtksourceview4, gnome , steam, xdg-utils, pciutils, cabextract, wineWowPackages -, freetype, p7zip, gamemode +, freetype, p7zip, gamemode, mangohud , bottlesExtraLibraries ? pkgs: [ ] # extra packages to add to steam.run multiPkgs , bottlesExtraPkgs ? pkgs: [ ] # extra packages to add to steam.run targetPkgs }: @@ -12,7 +12,7 @@ let steam-run = (steam.override { # required by wine runner `caffe` - extraLibraries = pkgs: with pkgs; [ libunwind libusb1 ] + extraLibraries = pkgs: with pkgs; [ libunwind libusb1 gnutls ] ++ bottlesExtraLibraries pkgs; extraPkgs = pkgs: [ ] ++ bottlesExtraPkgs pkgs; @@ -20,8 +20,10 @@ let in python3Packages.buildPythonApplication rec { pname = "bottles"; - version = "2022.2.28-trento-1"; - sha256 = "tE6YuuZZcs3RKxs1S6OoGt0CXz3oHUi/sopFN0iywds="; + version = "2022.3.14-trento-3"; + sha256 = "0wdqj9l69a9pnray2zcfgl2yw0hmrh23njbgwgqccimch014ckdq"; + # Note: Update via pkgs/applications/misc/bottles/update.py + # mostly copypasted from pkgs/applications/networking/instant-messengers/telegram/tdesktop/update.py src = fetchFromGitHub { owner = "bottlesdevs"; @@ -80,6 +82,7 @@ python3Packages.buildPythonApplication rec { freetype p7zip gamemode # programs.gamemode.enable + mangohud ]; format = "other"; @@ -89,13 +92,19 @@ python3Packages.buildPythonApplication rec { preConfigure = '' patchShebangs build-aux/meson/postinstall.py substituteInPlace src/backend/wine/winecommand.py \ - --replace '= f"{Paths.runners}' '= f"${steam-run}/bin/steam-run {Paths.runners}' + --replace \ + 'self.__get_runner()' \ + '(lambda r: (f"${steam-run}/bin/steam-run {r}", r)[r == "wine" or r == "wine64"])(self.__get_runner())' ''; preFixup = '' makeWrapperArgs+=("''${gappsWrapperArgs[@]}") ''; + passthru = { + updateScript = ./update.py; + }; + meta = with lib; { description = "An easy-to-use wineprefix manager"; homepage = "https://usebottles.com/"; diff --git a/nixpkgs/pkgs/applications/misc/bottles/update.py b/nixpkgs/pkgs/applications/misc/bottles/update.py new file mode 100755 index 000000000000..6adacd7d0e07 --- /dev/null +++ b/nixpkgs/pkgs/applications/misc/bottles/update.py @@ -0,0 +1,65 @@ +#! /usr/bin/env nix-shell +#! nix-shell -i python3 -p python3 nix nix-prefetch-git + +import fileinput +import json +import os +import re +import subprocess + +from datetime import datetime +from urllib.request import urlopen, Request + + +DIR = os.path.dirname(os.path.abspath(__file__)) +HEADERS = {'Accept': 'application/vnd.github.v3+json'} + + +def github_api_request(endpoint): + base_url = 'https://api.github.com/' + request = Request(base_url + endpoint, headers=HEADERS) + with urlopen(request) as http_response: + return json.loads(http_response.read().decode('utf-8')) + + +def get_commit_date(repo, sha): + url = f'https://api.github.com/repos/{repo}/commits/{sha}' + request = Request(url, headers=HEADERS) + with urlopen(request) as http_response: + commit = json.loads(http_response.read().decode()) + date = commit['commit']['committer']['date'].rstrip('Z') + date = datetime.fromisoformat(date).date().isoformat() + return 'unstable-' + date + + +def nix_prefetch_git(url, rev): + """Prefetches the requested Git revision (incl. submodules) of the given repository URL.""" + print(f'nix-prefetch-git {url} {rev}') + out = subprocess.check_output(['nix-prefetch-git', '--quiet', '--url', url, '--rev', rev, '--fetch-submodules']) + return json.loads(out)['sha256'] + + +def nix_prefetch_url(url, unpack=False): + """Prefetches the content of the given URL.""" + print(f'nix-prefetch-url {url}') + options = ['--type', 'sha256'] + if unpack: + options += ['--unpack'] + out = subprocess.check_output(['nix-prefetch-url'] + options + [url]) + return out.decode('utf-8').rstrip() + + +def update_file(relpath, version, sha256): + file_path = os.path.join(DIR, relpath) + with fileinput.FileInput(file_path, inplace=True) as f: + for line in f: + result = line + result = re.sub(r'^ version = ".+";', f' version = "{version}";', result) + result = re.sub(r'^ sha256 = ".+";', f' sha256 = "{sha256}";', result) + print(result, end='') + + +if __name__ == "__main__": + bottles_version = github_api_request('repos/bottlesdevs/Bottles/releases/latest')['tag_name'] + bottles_hash = nix_prefetch_git('https://github.com/bottlesdevs/Bottles.git', bottles_version) + update_file('default.nix', bottles_version, bottles_hash) |