Merge pull request #268619 from tweag/lib-descriptions
[NixPkgs.git] / pkgs / games / gogdl / default.nix
blobd5b3d0a5a5444cfe54c58f9688dc2d42e3d04360
1 { lib
2 , fetchpatch
3 , writeScript
4 , buildPythonApplication
5 , fetchFromGitHub
6 , pythonOlder
7 , setuptools
8 , requests
9 , cacert
12 buildPythonApplication rec {
13   pname = "gogdl";
14   version = "0.7.3";
15   format = "pyproject";
17   src = fetchFromGitHub {
18     owner = "Heroic-Games-Launcher";
19     repo = "heroic-gogdl";
20     rev = "89d15f1593cc26f15a5f8f409bb623764c095d37";
21     hash = "sha256-EECpXGVhcwihKB8fLObVvYzFD8uh7CxYKtFiGc0Jqbk=";
22   };
24   disabled = pythonOlder "3.8";
26   propagatedBuildInputs = [
27     setuptools
28     requests
29   ];
31   pythonImportsCheck = [ "gogdl" ];
33   meta = with lib; {
34     description = "GOG Downloading module for Heroic Games Launcher";
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   '';