As a amateur, I am not familiar to package software written in mixed language like this. (python and go). And I have little to zero knowledge in both language.
Manually running the gopy command to build go parts seems to work somhow (with some error) in nix-shell environment with gopy and gotools installed. However I do not know how to write it in nix expression to package sligde-whatsapp.
Yesterday I found I can build the package with devenv environment with uv package and just run uv build to build it from source in codeberg easily, then I can get a .whl file inside a dist folder.
Not only that, doing it in buildGoModule don’t work in another way because it do not have internet access i guess because of GOPROXY=off issue. Manually setting GOPROXY to point to some manually crafted goModules also not help.
Today I learned what .whl actually is as I don’t know much about python, and I figured out fetchPypi can fetch wheel and not the source, so I came up another way to package it.
{
fetchPypi,
python3Packages,
python3,
...
}:
let
# from pkgs/development/python-modules/clarifai-protocol/default.nix
pythonVersionNoDot = builtins.replaceStrings [ "." ] [ "" ] python3.pythonVersion;
in
python3Packages.buildPythonPackage (finalAttrs: {
pname = "slidge-whatsapp";
version = "0.3.11";
format = "wheel";
src = fetchPypi {
format = "wheel";
pname = "slidge_whatsapp";
version = finalAttrs.version;
python = "cp${pythonVersionNoDot}";
abi = "cp${pythonVersionNoDot}";
dist = "cp${pythonVersionNoDot}";
platform = "manylinux_2_41_x86_64";
hash = "sha256-SbnRWbp2xnBg5lSNMUqwZZ0NzLQg+pOg+51LzSFr5bY=";
};
propagatedBuildInputs = [
(import ../slidge)
(import ../linkpreview)
];
meta = {
# #...
};
})
I just switch the src with my local build .whl file.
Solved.
To build from source instead of wheel, gopy need to be patch to use -mod=vendor instead of hardcoded -mod=mod.
Had some basic test it seems working. But still need to deploy to production environment to test thing out.
Will submit PR when its dependency slidge is merged.