This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
{
|
||||
lib,
|
||||
makeWrapper,
|
||||
stdenvNoCC,
|
||||
python3,
|
||||
}:
|
||||
|
||||
let
|
||||
pythonEnv = python3.withPackages (ps: [
|
||||
ps.requests
|
||||
ps.pyjwt
|
||||
ps.cryptography
|
||||
]);
|
||||
in
|
||||
stdenvNoCC.mkDerivation {
|
||||
pname = "affine-chatgpt";
|
||||
version = "0.1.0";
|
||||
src = lib.cleanSourceWith {
|
||||
src = ./.;
|
||||
filter = path: type:
|
||||
!(builtins.elem (builtins.baseNameOf path) [ "__pycache__" ".venv" ]) && !(lib.hasSuffix ".pyc" path);
|
||||
};
|
||||
|
||||
nativeBuildInputs = [ makeWrapper ];
|
||||
passthru = { inherit pythonEnv; };
|
||||
|
||||
doCheck = true;
|
||||
checkPhase = ''
|
||||
runHook preCheck
|
||||
PYTHONPATH="$PWD/src" ${pythonEnv}/bin/python3 -m unittest discover -s test -v
|
||||
runHook postCheck
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dm444 src/affine_chatgpt.py "$out/share/affine-chatgpt/affine_chatgpt.py"
|
||||
install -Dm444 src/affine_gateway.py "$out/share/affine-chatgpt/affine_gateway.py"
|
||||
makeWrapper ${pythonEnv}/bin/python3 "$out/bin/affine-chatgpt" \
|
||||
--add-flags "$out/share/affine-chatgpt/affine_chatgpt.py" \
|
||||
--run 'umask 077'
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
meta = {
|
||||
description = "Local ChatGPT OAuth enrollment companion for AFFiNE";
|
||||
homepage = "https://developers.openai.com/siwc/token-sharing-open-source/";
|
||||
license = lib.licenses.mit;
|
||||
mainProgram = "affine-chatgpt";
|
||||
platforms = lib.platforms.unix;
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user