Skip to content

etebase-server: use buildPythonApplication, default to withLdap = false#326398

Merged
natsukium merged 2 commits intoNixOS:masterfrom
phaer:etebase-python
Jul 17, 2024
Merged

etebase-server: use buildPythonApplication, default to withLdap = false#326398
natsukium merged 2 commits intoNixOS:masterfrom
phaer:etebase-python

Conversation

@phaer
Copy link
Member

@phaer phaer commented Jul 11, 2024

  • I noticed that using python3 here referred to pkgs.python3 while python is always the one from the calling interpreter. In other words: before that change
    legacyPackages.x86_64-linux.python311.pkgs.etebase-server.python would give me a python 3.12 release, now it's 3.11 as it should be.

  • as etebase-server is an app in pkgs/servers, not a library in pkgs/development/python-modules, we use buildPythonApplication and callPackage in all-packages.nix and convert with toPythonModule in python-packages.nix. The latter could be dropped in a future commit

  • In services.etebase-server, we now use pkgs.etebase-server instead of python3.pkgs.etebase-server. We still expose passthru.python and passthru.python path in order to avoid rewriting the module right now as well. This could be simplified in a later commit, the wrapper there shouldn't be needed.

  • withLdap defaults to false now, as pkgs.python3.pkgs.python-ldap is broken on master. (see e.g. python312Packages.python-ldap: fix build #326321) and its not a required feature in any way.

Description of changes

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@phaer phaer requested a review from felschr July 11, 2024 22:56
@ofborg ofborg bot added 8.has: package (new) This PR adds a new package 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Jul 11, 2024
@felschr
Copy link
Member

felschr commented Jul 12, 2024

Result of nixpkgs-review pr 326398 run on x86_64-linux 1

2 packages built:
  • python311Packages.etebase-server
  • python311Packages.etebase-server.dist

Copy link
Member

@felschr felschr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good to me and tests pass on my machine with mentioned adjustment.

@felschr felschr added 12.approvals: 1 This PR was reviewed and approved by one person. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages. labels Jul 14, 2024
@nixos-discourse
Copy link

This pull request has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/prs-already-reviewed/2617/1821

Copy link
Member

@Aleksanaa Aleksanaa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This package almost works in an ugly way.

This is in top-level/all-packages.nix

etebase-server = with python3Packages; toPythonApplication etebase-server;

This is in top-level/python-packages.nix:

etebase-server = callPackage ../servers/etebase { };

I just don't know why we have to shoot our foot like this. The better way is just putting it in by-name, and if it is still used as a module, use toPythonModule in python-packages.nix. This PR only makes it more confusing to read, because normally people think of python2 when seeing python (because top-level python is python2)

@phaer
Copy link
Member Author

phaer commented Jul 15, 2024

This package almost works in an ugly way.

I agree with that. As it's an application it probably shouldn't be a python module as well, but I ofc don't know if there's any out of tree users of the module. The nixos module currently depends on python and pythonpath in passthru in the package, but that could of course be fixed.

This PR only makes it more confusing to read, because normally people think of python2 when seeing python (because top-level python is python2)

Hm, I was about to write that in the context of a python-module it makes sense. But yeah, the file isn't in pkgs/development/python-module, so thats a good argument to actually turn things around.

@felschr
Copy link
Member

felschr commented Jul 15, 2024

I agree with that. As it's an application it probably shouldn't be a python module as well, [...]

The etebase-server NixOS module currently relies on the python module. If it could be refactored to work without it I would be happy removing the python module altogether.

It's been a while since I initially added the package & NixOS module, but I remember some issues why I couldn't get it working without the python module. The NixOS module invokes etebase-server via uvicorn, so that's a bit special.

I didn't know about toPythonModule yet. With that, migrating to pkgs/by-name seems to be the best option to streamline the package either way.

@phaer phaer requested a review from natsukium as a code owner July 15, 2024 10:27
@github-actions github-actions bot added 6.topic: python Python is a high-level, general-purpose programming language. 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jul 15, 2024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this was just accidentally pushed? Or do you propose changing the default here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I do - see commit message. I'll update the PR description in a moment :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be mentioned in the release notes. And we might as well remove the python module then.

Copy link
Member Author

@phaer phaer Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, Thank you! I just removed the python package, wrote 2 sentences of release notes, squashed and rebased.

@phaer phaer changed the title etebase-server: use python, not python3 etebase-server: use buildPythonApplication, default to withLdap = false Jul 15, 2024
@Aleksanaa Aleksanaa dismissed their stale review July 15, 2024 10:38

addressed

@ofborg ofborg bot requested a review from felschr July 15, 2024 11:07
@ofborg ofborg bot removed 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1 This PR causes 1 package to rebuild on Linux. labels Jul 15, 2024
as it's not unsual to run it without ldap and python-ldap is currently broken on master for python 3.12.
@github-actions github-actions bot added 8.has: documentation This PR adds or changes documentation 8.has: changelog This PR adds or changes release notes labels Jul 15, 2024
@phaer phaer requested a review from Aleksanaa July 15, 2024 11:49
@ofborg ofborg bot added the 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. label Jul 15, 2024
@wegank wegank removed the 12.approvals: 1 This PR was reviewed and approved by one person. label Jul 15, 2024
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have to add this

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your review! Do you mean we should not add this? It seems to a relevant, user-visible change to effectively drop a package?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But do remember to add an entry in python-aliases.nix!

Copy link
Member Author

@phaer phaer Jul 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you explain why? We have an agreement between both maintainers of the package, @felschr and myself, to drop the python package. Are you using it?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We always add an entry there except for extra versions. Then we can also drop the release notes entry.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah right, sorry i misunderstood the suggestion at first. Should be fixed now?

...not pythonPackage. This is an app, living in pkgs/servers, so
we just use callPackage in all-packages and drop the python module.

python3.pkgs.toPythonModule could be used if a python module was needed.
Before that change legacyPackages.x86_64-linux.python311.pkgs.etebase-server.python
would give a python 3.12 release, and was therefore broken.

etebase-server = toPythonModule (pkgs.etebase-server.override {
  python3 = python;
});

would now be correct
@github-actions github-actions bot removed 8.has: documentation This PR adds or changes documentation 8.has: changelog This PR adds or changes release notes labels Jul 16, 2024
@ofborg ofborg bot requested a review from felschr July 16, 2024 19:19
@natsukium natsukium merged commit 43d306e into NixOS:master Jul 17, 2024
@phaer phaer deleted the etebase-python branch July 17, 2024 06:53
email_validator = email-validator; # added 2022-06-22
enhancements = throw "enhancements is unmaintained upstream and has therefore been removed"; # added 2023-10-27
et_xmlfile = et-xmlfile; # added 2023-10-16
etebase-server = throw "pkgs.python3.etebase-server has been removed, use pkgs.etebase-server"; # added 2024-07-16
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
etebase-server = throw "pkgs.python3.etebase-server has been removed, use pkgs.etebase-server"; # added 2024-07-16
etebase-server = pkgs.etebase-server; # added 2024-07-16

that should also just work

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could end up with the wrong python version used, see this PRs description.

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

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 6.topic: python Python is a high-level, general-purpose programming language. 8.has: module (update) This PR changes an existing module in `nixos/` 8.has: package (new) This PR adds a new package 10.rebuild-darwin: 1-10 This PR causes between 1 and 10 packages to rebuild on Darwin. 10.rebuild-darwin: 1 This PR causes 1 package to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. 11.by: package-maintainer This PR was created by a maintainer of all the package it changes. 12.approved-by: package-maintainer This PR was reviewed and approved by a maintainer listed in any of the changed packages.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants