nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{ lib
2, writeScript
3, buildPythonApplication
4, fetchFromGitHub
5, pythonOlder
6, setuptools
7, requests
8, cacert
9}:
10
11buildPythonApplication rec {
12 pname = "gogdl";
13 version = "0.7.2";
14 format = "pyproject";
15
16 src = fetchFromGitHub {
17 owner = "Heroic-Games-Launcher";
18 repo = "heroic-gogdl";
19 rev = "d7f29dfef5818e8b323d04761e18a9abb750f93e";
20 hash = "sha256-9dAenawt9h/sz5paVYoqk+nmzPrInlqyh1EgshI25CE=";
21 };
22
23 disabled = pythonOlder "3.8";
24
25 propagatedBuildInputs = [
26 setuptools
27 requests
28 ];
29
30 pythonImportsCheck = [ "gogdl" ];
31
32 meta = with lib; {
33 description = "GOG Downloading module for Heroic Games Launcher";
34 homepage = "https://github.com/Heroic-Games-Launcher/heroic-gogdl";
35 license = with licenses; [ gpl3 ];
36 maintainers = with maintainers; [ aidalgol ];
37 };
38
39 # Upstream no longer create git tags when bumping the version, so we have to
40 # extract it from the source code on the main branch.
41 passthru.updateScript = writeScript "gogdl-update-script" ''
42 #!/usr/bin/env nix-shell
43 #!nix-shell -i bash -p curl gnused jq common-updater-scripts
44 set -eou pipefail;
45
46 owner=Heroic-Games-Launcher
47 repo=heroic-gogdl
48 path='gogdl/__init__.py'
49
50 version=$(
51 curl --cacert "${cacert}/etc/ssl/certs/ca-bundle.crt" \
52 https://raw.githubusercontent.com/$owner/$repo/main/$path |
53 sed -n 's/^\s*version\s*=\s*"\([0-9]\.[0-9]\.[0-9]\)"\s*$/\1/p')
54
55 commit=$(curl --cacert "${cacert}/etc/ssl/certs/ca-bundle.crt" \
56 https://api.github.com/repos/$owner/$repo/commits?path=$path |
57 jq -r '.[0].sha')
58
59 update-source-version \
60 ${pname} \
61 "$version" \
62 --file=./pkgs/games/gogdl/default.nix \
63 --rev=$commit
64 '';
65}