2021-01-11 07:54:33 +00:00
|
|
|
{ lib, stdenv, runtimeShell, fetchFromGitHub, python3, writeText, writeScript
|
2017-07-25 08:04:28 +01:00
|
|
|
, coreutils, sqlite }:
|
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
with python3.pkgs;
|
2018-01-27 07:01:24 +00:00
|
|
|
|
2017-07-25 08:04:28 +01:00
|
|
|
let
|
|
|
|
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-15 09:19:50 +00:00
|
|
|
dbScript = writeScript "create_pykms_db.sh" (with lib; ''
|
2019-07-05 02:46:13 +01:00
|
|
|
#!${runtimeShell}
|
2017-07-25 08:04:28 +01:00
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
set -eEuo pipefail
|
2017-07-25 08:04:28 +01:00
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
db=$1
|
2017-07-25 08:04:28 +01:00
|
|
|
|
|
|
|
if [ ! -e $db ] ; then
|
|
|
|
${getBin sqlite}/bin/sqlite3 $db < ${dbSql}
|
|
|
|
fi
|
|
|
|
'');
|
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
in buildPythonApplication rec {
|
2019-08-15 13:41:18 +01:00
|
|
|
pname = "pykms";
|
2019-07-05 02:46:13 +01:00
|
|
|
version = "20190611";
|
2017-07-25 08:04:28 +01:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
2019-07-05 02:46:13 +01:00
|
|
|
owner = "SystemRage";
|
2017-07-25 08:04:28 +01:00
|
|
|
repo = "py-kms";
|
2019-07-05 02:46:13 +01:00
|
|
|
rev = "dead208b1593655377fe8bc0d74cc4bead617103";
|
|
|
|
sha256 = "065qpkfqrahsam1rb43vnasmzrangan5z1pr3p6s0sqjz5l2jydp";
|
2017-07-25 08:04:28 +01:00
|
|
|
};
|
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
sourceRoot = "source/py-kms";
|
2017-07-25 08:04:28 +01:00
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
propagatedBuildInputs = [ systemd pytz tzlocal ];
|
2017-07-25 08:04:28 +01:00
|
|
|
|
2020-02-29 10:19:01 +00:00
|
|
|
# Fix https://github.com/SystemRage/py-kms/issues/64 :
|
|
|
|
patches = [ ./log-to-current-directory-by-default.patch ];
|
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
postPatch = ''
|
|
|
|
siteDir=$out/${python3.sitePackages}
|
|
|
|
|
|
|
|
substituteInPlace pykms_DB2Dict.py \
|
2017-07-25 08:04:28 +01:00
|
|
|
--replace "'KmsDataBase.xml'" "'$siteDir/KmsDataBase.xml'"
|
|
|
|
'';
|
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
format = "other";
|
2017-07-25 08:04:28 +01:00
|
|
|
|
|
|
|
# there are no tests
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
mkdir -p $siteDir
|
2017-07-25 08:04:28 +01:00
|
|
|
|
|
|
|
mv * $siteDir
|
2019-07-05 02:46:13 +01:00
|
|
|
for b in Client Server ; do
|
|
|
|
makeWrapper ${python.interpreter} $out/bin/''${b,,} \
|
|
|
|
--argv0 ''${b,,} \
|
|
|
|
--add-flags $siteDir/pykms_$b.py \
|
|
|
|
--prefix PYTHONPATH : "$(toPythonPath ${systemd})"
|
2017-07-25 08:04:28 +01:00
|
|
|
done
|
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
install -Dm755 ${dbScript} $out/libexec/create_pykms_db.sh
|
2017-07-25 08:04:28 +01:00
|
|
|
|
2019-07-05 02:46:13 +01:00
|
|
|
install -Dm644 ../README.md -t $out/share/doc/pykms
|
2017-07-25 08:04:28 +01:00
|
|
|
|
2018-01-27 07:01:24 +00:00
|
|
|
${python.interpreter} -m compileall $siteDir
|
2017-07-25 08:04:28 +01:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
2021-01-11 07:54:33 +00:00
|
|
|
meta = with lib; {
|
2017-07-25 08:04:28 +01:00
|
|
|
description = "Windows KMS (Key Management Service) server written in Python";
|
2019-07-05 02:46:13 +01:00
|
|
|
homepage = "https://github.com/SystemRage/py-kms";
|
2017-07-25 08:04:28 +01:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ peterhoeg ];
|
|
|
|
};
|
|
|
|
}
|