Skip to content

feat: add Nix flake package definition - #693

Closed
TomVollerthun1337 wants to merge 1 commit into
otto-de:mainfrom
TomVollerthun1337:feat/nix-package-definition
Closed

TomVollerthun1337 wants to merge 1 commit into
otto-de:mainfrom
TomVollerthun1337:feat/nix-package-definition

Conversation

@TomVollerthun1337

Copy link
Copy Markdown
Contributor

Summary

Adds packages.default to the flake so logsmith can be consumed as an installable Nix package directly from the repo.

Usage

In a NixOS machine config:

inputs.logsmith.url = "github:otto-de/logsmith";
# ...
environment.systemPackages = [ inputs.logsmith.packages.${system}.default ];

Run without installing:

nix run github:otto-de/logsmith

Implementation

  • Python env: python313.withPackages with boto3, pyqt6, ruamel-yaml from nixpkgs. Using nixpkgs' PyQt6 means Qt is properly linked in the Nix store - no LD_LIBRARY_PATH workaround needed (that hack is only for PyPI wheels, which the devShell still uses).
  • Entry point: makeWrapper creates bin/logsmith pointing at app/run.py. The project has a non-standard dual-root import layout (from app.X and bare import arguments); this is handled by PYTHONPATH=$out/share/logsmith combined with Python's automatic sys.path[0] insertion for the script directory.
  • AWS CLI: awscli2 is appended to PATH for SSO login (aws sso login is called at runtime).
  • Version: read from pyproject.toml via builtins.fromTOML - no need to update the flake on version bumps.
  • devShell: the existing uv/PyPI-based devShell is unchanged.

Also adds .envrc (use flake) and excludes .direnv/ and result from git.

Adds packages.default so logsmith can be consumed directly from the
flake in a NixOS machine config:

  inputs.logsmith.url = "github:otto-de/logsmith";
  environment.systemPackages = [ inputs.logsmith.packages.${system}.default ];

Or run without installing:

  nix run github:otto-de/logsmith

Implementation details:
- Uses python313.withPackages with nixpkgs boto3/pyqt6/ruamel-yaml
  (nixpkgs PyQt6 is properly linked; no LD_LIBRARY_PATH hack needed)
- Copies only app/ into the store; PYTHONPATH + sys.path[0] cover
  the project's non-standard dual-root import layout
- Appends awscli2 to PATH for SSO login support
- Version read from pyproject.toml via builtins.fromTOML

The existing devShell (uv + PyPI workflow) is unchanged.

Also adds .envrc (use flake) and excludes .direnv/ and result from git.
@TomVollerthun1337

Copy link
Copy Markdown
Contributor Author

Superseded by #692 (by @PaulKobow7536), which takes a more complete approach via uv2nix. Planning to contribute macOS support and a few quality fixes directly to that PR instead.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant