3
0
Fork 0
forked from mirrors/nixpkgs
nixpkgs/pkgs/tools/networking/pykms/default.nix

91 lines
2.1 KiB
Nix
Raw Normal View History

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