Skip to content

Nix: package web dependencies#897

Draft
toast003 wants to merge 14 commits into9001:hovudstraumfrom
toast003:nix-webdebs
Draft

Nix: package web dependencies#897
toast003 wants to merge 14 commits into9001:hovudstraumfrom
toast003:nix-webdebs

Conversation

@toast003
Copy link
Contributor

@toast003 toast003 commented Oct 6, 2025

See #703 (comment)

I added a check to make sure the nix packaging doesn't drift apart from the dockerfile.

Things to package:

  • asmcrypto
  • hash-wasm
  • markedjs
  • DOMPurify (dompf)
  • easy-markdown-editor (mde)
  • codemirror
  • fontawesome
  • prism
  • sourcecodepro font
  • fusepy (in nixpkgs, but the dockerfile patches it)
  • busy-mp3

This pr should be as complete as it can be right now, would be ideal to have #868 merged first.

To show that your contribution is compatible with the MIT License, please include the following text somewhere in this PR description:
This PR complies with the DCO; https://developercertificate.org/

@toast003
Copy link
Contributor Author

toast003 commented Oct 6, 2025

The dockerfile does a bunch of patches with sed, so I have chosen to still do them with sed instead of using substituteInPlace.

Not best practice (at least in Nixpkgs), but that way we can just copy paste them

@9001
Copy link
Owner

9001 commented Oct 7, 2025

Since you're actually doing this (madlad), I should mention you don't really need all the patches, some are just to reduce the size by removing unnecessary features -- and the main reason the dockerfile is still using Alpine 3.18 to build the deps is because the output from nodejs changed at some point so some of the patches don't apply anymore, though iirc those were not important ones

these can be skipped; just sizegolfing:

  • codemirror.patch
  • easymde.patch
  • marked.patch

these are necessary for scroll-position sync in the markdown editors:

  • easymde-ln.patch
  • marked-ln.patch

these inline modifications which are made in the dockerfile can be skipped (sizegolfing):

  • asmcrypto awk

and the cacophony of seds in the dockerfile for easymde is just to use my modified copy of marked.js instead of having node grab the upstream, there's probably better ways to do this, I"m just banging rocks together here 👍

@toast003
Copy link
Contributor Author

toast003 commented Oct 7, 2025

Thanks for explaining!

I'm running into some weird issue with packaging easymde, I think nix gets confused by having file:/ urls in package-lock.json?
Anyways I'm not familiar with packaging npm packages with nix so I'll move on to something and try later

@toast003
Copy link
Contributor Author

Ok, should be ready to test now

@toast003
Copy link
Contributor Author

I'm making the assumption that we build the dependencies only if we're building from git and not a pinned release

@9001
Copy link
Owner

9001 commented Nov 15, 2025

cool! if you create a tar.gz of the deps folder I can give it a spin too

@toast003
Copy link
Contributor Author

Sure thing!
deps.tar.gz

The fuse.py here will probably not work outside my NixOS install cause nix weirdness but yee

@9001
Copy link
Owner

9001 commented Jan 24, 2026

yikes, I completely forgot about this -- sorry!

only remembered because i'm looking at vendoring asmcrypto since it's tricky to build with modern node/npm versions, and went "wait, didn't we have something to build this with nixos...?"

so uhh would now be a good time to merge this, or has it been overtaken?

EDIT: asmcrypto is now vendored btw, bef30ac

@toast003
Copy link
Contributor Author

Hi, I think it would be a good idea to wait a bit before we merge this, since I have an idea for building the web dependencies that would need less maintenance, and I still have to actually see if it would work

@toast003
Copy link
Contributor Author

Basically I recently realized that fixed-output derivations can access the network, so using them we could just extract the Dockerfile's commands into a separate script, and run that (with some slight changes) instead of packaging everything individually.

That would require a lot less Nix code, which is good since copyparty doesn't have that many contributors that want to work or know Nix

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.

2 participants