nixpkgs/pkgs/games/gogdl/default.nix
stuebinm ff1a94e523 treewide: add meta.mainProgram to packages with a single binary
The nixpkgs-unstable channel's programs.sqlite was used to identify
packages producing exactly one binary, and these automatically added
to their package definitions wherever possible.
2024-03-19 03:14:51 +01:00

68 lines
1.7 KiB
Nix

{ lib
, fetchpatch
, writeScript
, buildPythonApplication
, fetchFromGitHub
, pythonOlder
, setuptools
, requests
, cacert
}:
buildPythonApplication rec {
pname = "gogdl";
version = "1.0.1";
format = "pyproject";
src = fetchFromGitHub {
owner = "Heroic-Games-Launcher";
repo = "heroic-gogdl";
rev = "10b4a19e0fbe9bc3db6b9ce3ea49fd17c9f1d37d";
hash = "sha256-po9To5WfT0L2j48Q84ygbbIqtTfXP9uQPrl4Uu+CWGk=";
};
disabled = pythonOlder "3.8";
propagatedBuildInputs = [
setuptools
requests
];
pythonImportsCheck = [ "gogdl" ];
meta = with lib; {
description = "GOG Downloading module for Heroic Games Launcher";
mainProgram = "gogdl";
homepage = "https://github.com/Heroic-Games-Launcher/heroic-gogdl";
license = with licenses; [ gpl3 ];
maintainers = with maintainers; [ aidalgol ];
};
# Upstream no longer create git tags when bumping the version, so we have to
# extract it from the source code on the main branch.
passthru.updateScript = writeScript "gogdl-update-script" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl gnused jq common-updater-scripts
set -eou pipefail;
owner=Heroic-Games-Launcher
repo=heroic-gogdl
path='gogdl/__init__.py'
version=$(
curl --cacert "${cacert}/etc/ssl/certs/ca-bundle.crt" \
https://raw.githubusercontent.com/$owner/$repo/main/$path |
sed -n 's/^\s*version\s*=\s*"\([0-9]\.[0-9]\.[0-9]\)"\s*$/\1/p')
commit=$(curl --cacert "${cacert}/etc/ssl/certs/ca-bundle.crt" \
https://api.github.com/repos/$owner/$repo/commits?path=$path |
jq -r '.[0].sha')
update-source-version \
${pname} \
"$version" \
--file=./pkgs/games/gogdl/default.nix \
--rev=$commit
'';
}