(thanks to @hexa for help in https://app.element.io/#/room/#python:nixos.org)
So what happens here is that mssql-cli
is configured in the setup.py via scripts
(this script here). I.e. the scripts are just copy/pasted naively without being wrapped by nix. The cleanest solution would be to setup them as entrypoints in the setup.py
calling the mssqlcl.main:main
function, instead of scripts
, following for instance this example. But since this is not under our control, the simplest is certainly to wrap the binary file with:
postFixup = ''
wrapProgram "$out/bin/mssql-cli" \
--prefix PYTHONPATH : "$PYTHONPATH" \
--prefix PATH : "${python311}/bin"
'';
The whole derivation:
{ lib, python311, fetchFromGitHub }:
python311.pkgs.buildPythonPackage rec {
pname = "mssql-cli";
version = "1.0";
nativeBuildInputs = [ python311.pkgs.wrapPython ];
propagatedBuildInputs = with python311.pkgs; [
applicationinsights
cli-helpers
click
configobj
future
humanize
prompt-toolkit
sqlparse
wheel
pygments
];
patchPhase = ''
substituteInPlace setup.py \
--replace "click >= 4.1,<7.1" "click"
'';
src = fetchFromGitHub {
owner = "dbcli";
repo = "mssql-cli";
rev = "HEAD";
hash = "sha256-v2RKJXG2bqIviQeppaa6JVhlgBdbj0axip12bxfTcMs=";
};
postFixup = ''
wrapProgram "$out/bin/mssql-cli" \
--prefix PYTHONPATH : "$PYTHONPATH" \
--prefix PATH : "${python311}/bin"
'';
doCheck = false;
pythonImportsCheck = [
"mssqlcli"
];
}