-
Notifications
You must be signed in to change notification settings - Fork 29
Use nix to install prettier for prettier-markdown #1108
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
base: main
Are you sure you want to change the base?
Conversation
2c0929d to
6156cce
Compare
|
I think the approach has merit. In fact, I wouldn't be against totally re-implementing everything on nix; it would just be a pretty big lift at this point. To get this specific fix out, I think there's three things:
Are these things you'd be interested in tackling, or should I take it from here and come back when/if I trip over nix specifically? |
I think so, I'll see.
I think you would make a directory that just contains
https://docs.renovatebot.com/modules/manager/nix/ -
I'll turn this on in the Freckle flakes repo and see how it works.
Would appreciate help with that.
I haven't even figured out how to reproduce that outside of megarepo CI. |
Me either! This runs the exact command in the exact restyler image being used on CI. And it works fine. % docker run --rm -it --volume $(pwd):/code public.ecr.aws/restyled-io/restyler-prettier:v3.6.2-3 /app/node_modules/.bin/prettier --write frontend/educator/docs/README.md
frontend/educator/docs/README.md 36ms (unchanged)Only the image, command, and directory contents could affect behavior, and everything looks exactly the same to me (I ran in latest So I'm pretty baffled as well. |
|
Is the idea that the (edit) Oh overmind I see, it's controlled by |
|
Yup, Restyled is not opinionated, so it should always follow what the project has configured. |
|
How does that work? Is it doing that presently? I don't see any code in this repo that reads from |
It does it by not doing anything. It runs a tool in a directory that is expected to hold configuration and that tool is expected to use that configuration. In this case |
7e18f6a to
0c245bf
Compare
|
I have sort of a local bug reproduction and fix. I don't think Nix actually has anything to do with the solution. You just have to make sure your execution of # Move to a directory that contains the right node_modules
cd /nix/store/nw387q5idifi4d7yskiia3q0n36i6ir7-prettier-current/lib/node_modules/@restyled/restyler-prettier
# Restyle a file elsewhere
/nix/store/nw387q5idifi4d7yskiia3q0n36i6ir7-prettier-current/bin/prettier \
/home/chris/code/megarepo-frontend/frontend/educator/entities/ts/math/adaptive/models/math-adaptive-domains-practiced.tsAnd So the non-Nix build could actually be modified to do this, but I think first I'll try the approach of making the Nix package output a wrapper script that just changes directory before running. |
|
Yes, I hit on a similar solution in branch I have locally. What I did was just clobber ./node_modules with ours, run, then restore it after. I guess this situation could be made simpler, and just add (then run, and remove) our node_modules only if one does not already exist (because the project doesn't commit it). |
|
Pushed my local branch as #1112 🤷 |
d189e76 to
f2034a4
Compare
|
Okay, I think I've got this into a good state. Nixpkgs offers a very straightforward buildNodeModules function; its inputs are a directory with The JS and Nix dependencies are all in standard package/lock files that I would expect any automated tool to be able to update. Enabled Nix integration for Renovate. I'm not convinced that the additional test cases are really necessary with this approach. Since the wrapper script does not run |
f2034a4 to
bbb5481
Compare
bbb5481 to
097634a
Compare
I'm not sure I understand the problem I'm trying to fix, but it sounds like the gist is that the files we're trying to restyle are interfering with the installation of the tool that does the restyling. My hope is that installation of
prettieras a Nix package will be more isolated. Since the markdown restyler doesn't need a lot of the stuff that you may need to restyle JS files, I've implemented this separately rather than have it extend theprettierrestyler. I think a similar change could be made, though, to the other Prettier-based restylers; we could put together e.g. a "prettier-with-tailwind" nix package, etc.