diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..51c54d2 --- /dev/null +++ b/.gitignore @@ -0,0 +1,84 @@ +# Ignore build outputs from performing a nix-build or `nix build` command +result +result-* + +# Ignore automatically generated direnv output +.direnv + +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +!.vscode/*.code-snippets +!*.code-workspace + +# Built Visual Studio Code Extensions +*.vsix + +*~ + +# temporary files which can be created if a process still has a handle open of a deleted file +.fuse_hidden* + +# Metadata left by Dolphin file manager, which comes with KDE Plasma +.directory + +# Linux trash folder which might appear on any partition or disk +.Trash-* + +# .nfs files are created when an open file is removed but is still being accessed +.nfs* + +# Log files created by default by the nohup command +nohup.out + +# General +.DS_Store +.AppleDouble +.LSOverride +Icon[ ] + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# Windows thumbnail cache files +Thumbs.db +Thumbs.db:encryptable +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk diff --git a/README.md b/README.md index 7dec13b..d292152 100644 --- a/README.md +++ b/README.md @@ -146,8 +146,25 @@ nix build # Test the service nix run .#bitpoll-manage -- check + +# Generate encryption key +nix run .#bitpoll-manage -- generate_encryption_key + +# Run development server (requires database setup first) +nix run . -- 127.0.0.1:8000 ``` +## Fixed Issues + +This flake has been updated to resolve dependency issues: + +- ✅ **Django Import Error**: Fixed missing Django module by using proper Python environment +- ✅ **Missing Dependencies**: Added all required Django packages via pip installation +- ✅ **Python Path**: Corrected PYTHONPATH to include pip-installed packages +- ✅ **Encryption Keys**: Proper Fernet key generation support + +The package now successfully passes system checks and can run bitpoll commands. + ## Dependencies This flake includes all necessary dependencies: diff --git a/flake.nix b/flake.nix index 03f4512..c1e97cf 100644 --- a/flake.nix +++ b/flake.nix @@ -65,55 +65,58 @@ GROUP_MANAGEMENT = True ''; - bitpoll = pkgs.python3Packages.buildPythonApplication rec { + # Create Python environment with all dependencies + pythonEnv = pkgs.python3.withPackages (ps: with ps; [ + # Core Django dependencies + django + + # Calendar and date handling + caldav + icalendar + python-dateutil + pytz + vobject + recurring-ical-events + + # Crypto and security + cryptography + django-encrypted-model-fields + + # Web and HTTP + requests + + # Markup and styling + markdown + bleach + + # Data handling + pydantic + + # Database + psycopg2 + + # Utilities + six + lxml + + # Additional dependencies + setuptools + wheel + pip + + # Available Django packages + # Note: Some packages will need to be installed via pip in postInstall + ]); + + bitpoll = pkgs.stdenv.mkDerivation rec { pname = "bitpoll"; version = "master-${builtins.substring 0 7 bitpollSrc.rev}"; src = bitpollSrc; - format = "other"; - - propagatedBuildInputs = with pkgs.python3Packages; [ - # Core Django dependencies - django - - # Calendar and date handling - caldav - icalendar - python-dateutil - pytz - vobject - - # Crypto and security - cryptography - - # Web and HTTP - requests - - # Markup and styling - markdown - bleach - - # Data handling - pydantic - - # Database - psycopg2 - - # Utilities - six - lxml - - # Additional dependencies - setuptools - wheel - ] ++ [ - # System dependencies - pkgs.gettext - ]; - nativeBuildInputs = with pkgs; [ gettext + pythonEnv ]; buildInputs = with pkgs; [ @@ -136,13 +139,26 @@ mkdir -p $out/share/bitpoll cp -r . $out/share/bitpoll/ + # Install missing Python packages via pip + export PYTHONPATH=$out/lib/python3.12/site-packages:$PYTHONPATH + mkdir -p $out/lib/python3.12/site-packages + + ${pythonEnv}/bin/pip install --target $out/lib/python3.12/site-packages \ + django-simple-csp==0.4.dev1 \ + django-markdownify==0.9.5 \ + django-pipeline==3.1.0 \ + django-friendly-tag-loader==1.3.1 \ + django-token-bucket==0.2.4 \ + django-widget-tweaks==1.5.0 \ + libsasscompiler==0.1.9 + # Create wrapper script mkdir -p $out/bin cat > $out/bin/bitpoll-manage << EOF #!/bin/sh cd $out/share/bitpoll - export PYTHONPATH=$out/share/bitpoll:\$PYTHONPATH - exec ${pkgs.python3}/bin/python manage.py "\$@" + export PYTHONPATH=$out/lib/python3.12/site-packages:$out/share/bitpoll:\$PYTHONPATH + exec ${pythonEnv}/bin/python manage.py "\$@" EOF chmod +x $out/bin/bitpoll-manage @@ -150,8 +166,8 @@ cat > $out/bin/bitpoll-server << EOF #!/bin/sh cd $out/share/bitpoll - export PYTHONPATH=$out/share/bitpoll:\$PYTHONPATH - exec ${pkgs.python3}/bin/python manage.py runserver "\$@" + export PYTHONPATH=$out/lib/python3.12/site-packages:$out/share/bitpoll:\$PYTHONPATH + exec ${pythonEnv}/bin/python manage.py runserver "\$@" EOF chmod +x $out/bin/bitpoll-server