2021-01-31 13:40:19 +01:00
|
|
|
{ lib
|
|
|
|
, fetchFromGitHub
|
|
|
|
, python3
|
|
|
|
, writeText
|
|
|
|
, writeShellScript
|
|
|
|
, sqlite
|
|
|
|
}:
|
2017-07-25 09:04:28 +02:00
|
|
|
let
|
2021-01-31 13:40:19 +01:00
|
|
|
pypkgs = python3.pkgs;
|
|
|
|
|
2017-07-25 09:04:28 +02:00
|
|
|
dbSql = writeText "create_pykms_db.sql" ''
|
|
|
|
CREATE TABLE clients(
|
|
|
|
clientMachineId TEXT,
|
|
|
|
machineName TEXT,
|
|
|
|
applicationId TEXT,
|
|
|
|
skuId TEXT,
|
|
|
|
licenseStatus TEXT,
|
|
|
|
lastRequestTime INTEGER,
|
|
|
|
kmsEpid TEXT,
|
|
|
|
requestCount INTEGER
|
|
|
|
);
|
|
|
|
'';
|
|
|
|
|
2021-01-31 13:40:19 +01:00
|
|
|
dbScript = writeShellScript "create_pykms_db.sh" ''
|
2019-07-05 03:46:13 +02:00
|
|
|
set -eEuo pipefail
|
2017-07-25 09:04:28 +02:00
|
|
|
|
2021-01-31 13:40:19 +01:00
|
|
|
db=''${1:-/var/lib/pykms/clients.db}
|
2017-07-25 09:04:28 +02:00
|
|
|
|
|
|
|
if [ ! -e $db ] ; then
|
2021-01-31 13:40:19 +01:00
|
|
|
${lib.getBin sqlite}/bin/sqlite3 $db < ${dbSql}
|
2017-07-25 09:04:28 +02:00
|
|
|
fi
|
2021-01-31 13:40:19 +01:00
|
|
|
'';
|
2017-07-25 09:04:28 +02:00
|
|
|
|
2021-01-31 13:40:19 +01:00
|
|
|
in
|
|
|
|
pypkgs.buildPythonApplication rec {
|
2019-08-15 14:41:18 +02:00
|
|
|
pname = "pykms";
|
2021-01-31 13:40:19 +01:00
|
|
|
version = "unstable-2021-01-25";
|
2017-07-25 09:04:28 +02:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2022-06-27 00:20:04 +02:00
|
|
|
owner = "Py-KMS-Organization";
|
2021-01-31 13:40:19 +01:00
|
|
|
repo = "py-kms";
|
2022-06-27 00:20:04 +02:00
|
|
|
rev = "1435c86fe4f11aa7fd42d77fa61715ca3015eeab";
|
|
|
|
hash = "sha256-9KiMbS0uKTbWSZVIv5ziIeR9c8+EKfKd20yPmjCX7GQ=";
|
2017-07-25 09:04:28 +02:00
|
|
|
};
|
|
|
|
|
2023-07-25 15:27:31 +02:00
|
|
|
sourceRoot = "${src.name}/py-kms";
|
2017-07-25 09:04:28 +02:00
|
|
|
|
2022-06-27 00:20:04 +02:00
|
|
|
propagatedBuildInputs = with pypkgs; [ systemd pytz tzlocal dnspython ];
|
2020-02-29 11:19:01 +01:00
|
|
|
|
2019-07-05 03:46:13 +02:00
|
|
|
postPatch = ''
|
|
|
|
siteDir=$out/${python3.sitePackages}
|
|
|
|
|
|
|
|
substituteInPlace pykms_DB2Dict.py \
|
2017-07-25 09:04:28 +02:00
|
|
|
--replace "'KmsDataBase.xml'" "'$siteDir/KmsDataBase.xml'"
|
|
|
|
'';
|
|
|
|
|
2019-07-05 03:46:13 +02:00
|
|
|
format = "other";
|
2017-07-25 09:04:28 +02:00
|
|
|
|
|
|
|
# there are no tests
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2019-07-05 03:46:13 +02:00
|
|
|
mkdir -p $siteDir
|
2017-07-25 09:04:28 +02:00
|
|
|
|
2022-06-27 00:20:04 +02:00
|
|
|
PYTHONPATH="$PYTHONPATH:$siteDir"
|
|
|
|
|
2017-07-25 09:04:28 +02:00
|
|
|
mv * $siteDir
|
2019-07-05 03:46:13 +02:00
|
|
|
for b in Client Server ; do
|
2021-01-31 13:40:19 +01:00
|
|
|
makeWrapper ${python3.interpreter} $out/bin/''${b,,} \
|
|
|
|
--argv0 pykms-''${b,,} \
|
2022-06-27 00:20:04 +02:00
|
|
|
--add-flags $siteDir/pykms_$b.py \
|
|
|
|
--set PYTHONPATH $PYTHONPATH
|
2017-07-25 09:04:28 +02:00
|
|
|
done
|
|
|
|
|
2019-07-05 03:46:13 +02:00
|
|
|
install -Dm755 ${dbScript} $out/libexec/create_pykms_db.sh
|
2017-07-25 09:04:28 +02:00
|
|
|
|
2019-07-05 03:46:13 +02:00
|
|
|
install -Dm644 ../README.md -t $out/share/doc/pykms
|
2017-07-25 09:04:28 +02:00
|
|
|
|
2021-01-31 13:40:19 +01:00
|
|
|
${python3.interpreter} -m compileall $siteDir
|
2017-07-25 09:04:28 +02:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2017-07-25 09:04:28 +02:00
|
|
|
description = "Windows KMS (Key Management Service) server written in Python";
|
2022-06-27 00:20:04 +02:00
|
|
|
homepage = "https://github.com/Py-KMS-Organization/py-kms";
|
2021-01-31 13:40:19 +01:00
|
|
|
license = licenses.unlicense;
|
2022-06-27 00:20:04 +02:00
|
|
|
maintainers = with maintainers; [ peterhoeg zopieux ];
|
2017-07-25 09:04:28 +02:00
|
|
|
};
|
|
|
|
}
|