Files
yukkop 50c4efc09b
runner nix smoke / nix label and flake smoke (push) Failing after 1m12s
gpt in affine
2026-11-01 11:21:28 +00:00

52 lines
1.3 KiB
Nix

{
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;
};
}