Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mautrix-telegram: patch away alembic dependency #59519

Merged
merged 1 commit into from May 30, 2019

Conversation

Ma27
Copy link
Member

@Ma27 Ma27 commented Apr 14, 2019

Motivation for this change

alembic[1] is a database migration tool which is invoked from the CLI
when installing the telegram bridge, but never needed during the
runtime.

The reason why alembic is required here is to ensure that it
exists in the Python environment when deploying the bridge. However
alembic requires mautrix-telegram in its environment to create a
database schema from the Python models.

Such a dependency relation may be possible with tools like virtualenv,
however it'll result in an infinite recursion at evaluation time in Nix.

With this patch, mautrix-telegram doesn't depend on alembic anymore
and provides a patched alembic (pkgs.mautrix-telegram.alembic) which
has mautrix-telegram in its path.

[1] https://alembic.sqlalchemy.org/en/latest/

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Assured whether relevant documentation is up to date
  • Fits CONTRIBUTING.md.

@Ma27
Copy link
Member Author

Ma27 commented May 23, 2019

As the package maintainer gave a 👍 I guess this should be fine. I'll merge this PR in a week unless there are further comments :)

Copy link
Contributor

@worldofpeace worldofpeace left a comment

Choose a reason for hiding this comment

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

I recall reviewing this when it was added to nixpkgs and maybe suggesting something like this being done (or perhaps thought). LGTM.

Perhaps initial-setup should be tested though.

@Ma27
Copy link
Member Author

Ma27 commented May 23, 2019

@worldofpeace I have to admit that I didn't read the thread when this was packaged initially, this is actually the result of something I used to have in an overlay in my deployment repo that seemed useful to upstream :)

Perhaps initial-setup should be tested though.

I actually confirmed that mautrix-telegram.alembic is able ot create a sqlite database that is usable by mautrix-telegram. Is there anything else you'd suggest to test?

@worldofpeace
Copy link
Contributor

I actually confirmed that mautrix-telegram.alembic is able ot create a sqlite database that is usable by mautrix-telegram. Is there anything else you'd suggest to test?

I think doing alembic upgrade head would be the only thing to test.

But now I'm thinking, how is a user going to know that they need to use mautrix-telegram.alembic?
Also will hydra cache mautrix-telegram.alembic?

@Ma27
Copy link
Member Author

Ma27 commented May 23, 2019

But now I'm thinking, how is a user going to know that they need to use mautrix-telegram.alembic

Whenever you need alembic to run migrations for mautrix-telegram as this should be the only case where you need alembic with a dependency to the mautrix-telegram package, right?

Also will hydra cache mautrix-telegram.alembic?

That's indeed a good question. I guess not (atm), but this should be fixable by recurseIntoAttrs, right?

@worldofpeace
Copy link
Contributor

That's indeed a good question. I guess not (atm), but this should be fixable by recurseIntoAttrs, right?

I believe that should be correct.

`alembic`[1] is a database migration tool which is invoked from the CLI
when installing the telegram bridge, but never needed during the
runtime.

The reason why `alembic` is required here is to ensure that it
exists in the Python environment when deploying the bridge. However
`alembic` requires `mautrix-telegram` in its environment to create a
database schema from the Python models.

Such a dependency relation may be possible with tools like virtualenv,
however it'll result in an infinite recursion at evaluation time in Nix.

With this patch, `mautrix-telegram` doesn't depend on `alembic` anymore
and provides a patched alembic (`pkgs.mautrix-telegram.alembic`) which
has `mautrix-telegram` in its path.

[1] https://alembic.sqlalchemy.org/en/latest/
@Ma27 Ma27 force-pushed the improve-mautrix-telegram branch from edfdc23 to 0a94f89 Compare May 24, 2019 07:36
@Ma27
Copy link
Member Author

Ma27 commented May 24, 2019

@worldofpeace ack, fixed :)

@Ma27
Copy link
Member Author

Ma27 commented May 30, 2019

As announced, I'll merge this now. It's been approved by a collaborator and got a thumbs-up from the package maintainer. Also, recurseIntoAttrs is now used to get a prebuilt mautrix-telegram.alembic from Hydra.

@Ma27 Ma27 merged commit 5949838 into NixOS:master May 30, 2019
@Ma27 Ma27 deleted the improve-mautrix-telegram branch May 30, 2019 09:01
@worldofpeace
Copy link
Contributor

Thanks for being so thorough ✨

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

Successfully merging this pull request may close these issues.

None yet

3 participants