@@ -92,6 +92,7 @@ def read_pyproject_toml():
9292
9393 return pyproject_data
9494
95+
9596def extract_project_meta (pyproject_data ):
9697 # Extract project metadata from pyproject.toml data.
9798 project_data = pyproject_data ["project" ]
@@ -194,13 +195,16 @@ def create_defualt_nix(dependencies_list, meta_dict):
194195 else :
195196 python_use = f"python{ py_version_major } { py_version_minor } "
196197 # Create a default.nix
197- nix_content = """
198+ nix_content = (
199+ """
198200{
199201 pkgs ? import <nixpkgs> { },
200202}:
201203
202204let
203- python = pkgs.""" + python_use + """;
205+ python = pkgs."""
206+ + python_use
207+ + """;
204208
205209 # Helper function to create packages with specific versions and disabled tests
206210 buildCustomPackage = { pname, version, format ? "wheel", src, ... }@attrs:
@@ -215,6 +219,14 @@ def create_defualt_nix(dependencies_list, meta_dict):
215219 ];
216220 buildInputs = with pkgs; [ openldap cyrus_sasl ];
217221 };
222+ psycopg = {
223+ nativeBuildInputs = with pkgs; [
224+ pkg-config
225+ ];
226+ buildInputs = with pkgs; [
227+ postgresql
228+ ];
229+ };
218230 };
219231
220232 # Get the special build inputs for this package, or empty if none
@@ -230,6 +242,7 @@ def create_defualt_nix(dependencies_list, meta_dict):
230242
231243 pythonOverlay = self: super: {
232244"""
245+ )
233246 need_review_packages_list = []
234247 deps_size = len (dependencies_list )
235248 for idx , dep in enumerate (dependencies_list ):
@@ -366,17 +379,30 @@ def create_defualt_nix(dependencies_list, meta_dict):
366379 setuptools
367380 wheel
368381 pip
382+ pkgs.pkg-config
383+ pkgs.makeWrapper
369384 ];
370385
371386 # Add PostgreSQL to buildInputs to ensure libpq is available at runtime
372387 buildInputs = with pkgs; [
373388 postgresql
374389 ];
375390
376- # This wrapper ensures the PostgreSQL libraries are available at runtime
377- makeWrapperArgs = [
378- "--set LD_LIBRARY_PATH ${pkgs.postgresql.lib}/lib"
379- ];
391+ # Ensure proper runtime setup.
392+ postInstall = ''
393+ # Create source directory like RPM does (for source access)
394+ mkdir -p $out/src
395+ cp -r ${./.}/* $out/src/ 2>/dev/null || true
396+
397+ # Remove build artifacts from source copy
398+ rm -rf $out/src/dist $out/src/build $out/src/result $out/src/default.nix 2>/dev/null || true
399+
400+ # Wrap the dejacode executable to set up the runtime environment
401+ wrapProgram $out/bin/dejacode \
402+ --set PYTHONPATH "$out/src:$out/lib/python*/site-packages" \
403+ --set LD_LIBRARY_PATH "${pkgs.postgresql.lib}/lib:$LD_LIBRARY_PATH" \
404+ --run "cd $out/src"
405+ '';
380406
381407 propagatedBuildInputs = with pythonWithOverlay.pkgs; [
382408"""
0 commit comments