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