Skip to content

Cryptpad: add example and test#661

Merged
erictapen merged 4 commits into
ngi-nix:mainfrom
eljamm:add-cryptpad-example
Mar 27, 2025
Merged

Cryptpad: add example and test#661
erictapen merged 4 commits into
ngi-nix:mainfrom
eljamm:add-cryptpad-example

Conversation

@eljamm
Copy link
Copy Markdown
Contributor

@eljamm eljamm commented Mar 25, 2025

Tested inside an lxc container generated with nixos-generators:

image

Note: Instructions for reproducing this are available here.

@erictapen
Copy link
Copy Markdown
Contributor

I worked on something similar yesterday to show something in the project overview. I think this will not work as expected without a reverse proxy, as the Nginx config currently ties a few routes together? My solution to this was

  services.nginx = {
    virtualHosts."cryptpad.localhost" = {
      enableACME = false;
      forceSSL = false;
    };
  };

so that we don't depend on ACME working.

Comment thread projects/Cryptpad/default.nix Outdated
name = "cryptpad";
module = "${sources.inputs.nixpkgs}/nixos/modules/services/web-apps/cryptpad.nix";
examples.basic = null;
examples.basic = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Suggested change
examples.basic = {
examples.demo = {

I had this idea to reserve the demo name for service demos, as they would be rendered differently in the overview than other examples. What do you think?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yup, that's a great idea! I like it.

@eljamm
Copy link
Copy Markdown
Contributor Author

eljamm commented Mar 26, 2025

I worked on something similar yesterday to show something in the project overview. I think this will not work as expected without a reverse proxy, as the Nginx config currently ties a few routes together? My solution to this was

  services.nginx = {
    virtualHosts."cryptpad.localhost" = {
      enableACME = false;
      forceSSL = false;
    };
  };

so that we don't depend on ACME working.

The current config doesn't enable nginx for Cryptpad (even though it has an option to) and instead uses:

services.cryptpad.setting.httpSafeOrigin = "http://localhost:${toString servicePort}";

Which seems to work. Is there something that wouldn't work without this?

@erictapen
Copy link
Copy Markdown
Contributor

erictapen commented Mar 26, 2025

Yeah I know. I didn't check the functionality, but the Nginx config also contains the /cryptpad_websocket route which wouldn't be reachable in your code, as the app seems to provide websockets on a different port.

https://github.com/NixOS/nixpkgs/blob/b613a5f7db5a7ad8507a2d20bec11db892193f25/nixos/modules/services/web-apps/cryptpad.nix#L266-L292

@eljamm
Copy link
Copy Markdown
Contributor Author

eljamm commented Mar 26, 2025

I can't seem to make this work with nginx as I keep getting CORS errors when I try to sign up. Have you encountered this @erictapen?

@erictapen
Copy link
Copy Markdown
Contributor

Oh, no I never tested it this far, sorry. Ideally we would be able give the name a proper host name like cryptpad.local, because my suspicion would be that using localhost messes with CORS.

Copy link
Copy Markdown
Contributor

@erictapen erictapen left a comment

Choose a reason for hiding this comment

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

Let's merge for now and iterate on the Nginx problem later.

@erictapen erictapen force-pushed the add-cryptpad-example branch from a18c6ac to 9ffded7 Compare March 27, 2025 13:29
@erictapen erictapen enabled auto-merge (squash) March 27, 2025 13:29
@erictapen erictapen merged commit 9b4ae90 into ngi-nix:main Mar 27, 2025
@github-project-automation github-project-automation Bot moved this to Done in Nix@NGI Mar 27, 2025
@eljamm eljamm deleted the add-cryptpad-example branch March 27, 2025 13:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants