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

85 lines
1.9 KiB
Nix
Raw Normal View History

{ stdenv, fetchFromGitHub, python3Packages, writeText, writeScript
2017-07-25 08:04:28 +01:00
, coreutils, sqlite }:
with python3Packages;
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; ''
#!${stdenv.shell} -eu
db=$1
${getBin coreutils}/bin/install -d $(dirname $db)
if [ ! -e $db ] ; then
${getBin sqlite}/bin/sqlite3 $db < ${dbSql}
fi
'');
in buildPythonApplication rec {
2017-07-25 08:04:28 +01:00
name = "pykms-${version}";
version = "20171224";
2017-07-25 08:04:28 +01:00
src = fetchFromGitHub {
owner = "ThunderEX";
repo = "py-kms";
rev = "885f67904f002042d7758e38f9c5426461c5cdc7";
sha256 = "155khy1285f8xkzi6bsqm9vzz043jsjmp039va1qsh675gz3q9ha";
2017-07-25 08:04:28 +01:00
};
propagatedBuildInputs = [ argparse pytz ];
2017-07-25 08:04:28 +01:00
prePatch = ''
siteDir=$out/${python.sitePackages}
2017-07-25 08:04:28 +01:00
substituteInPlace kmsBase.py \
--replace "'KmsDataBase.xml'" "'$siteDir/KmsDataBase.xml'"
'';
dontBuild = true;
# there are no tests
doCheck = false;
installPhase = ''
runHook preInstall
mkdir -p $out/{bin,share/doc/pykms} $siteDir
mv * $siteDir
for b in client server ; do
chmod 0755 $siteDir/$b.py
makeWrapper ${python.interpreter} $out/bin/$b.py \
2017-07-25 08:04:28 +01:00
--add-flags $siteDir/$b.py
done
install -m755 ${dbScript} $out/bin/create_pykms_db.sh
mv $siteDir/README.md $out/share/doc/pykms/
${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/ThunderEX/py-kms;
2017-07-25 08:04:28 +01:00
license = licenses.mit;
maintainers = with maintainers; [ peterhoeg ];
};
}