Skip to content

Comments

Add devenv#16263

Merged
straight-shoota merged 2 commits intocrystal-lang:masterfrom
straight-shoota:infra/devenv
Oct 26, 2025
Merged

Add devenv#16263
straight-shoota merged 2 commits intocrystal-lang:masterfrom
straight-shoota:infra/devenv

Conversation

@straight-shoota
Copy link
Member

@straight-shoota straight-shoota commented Oct 24, 2025

Adds a basic https://devenv.sh/ configuration.
So far, it only contains a couple of git hooks. They're useful as pre-commit checks, and we can also run them in CI.

That'll be the next step: consolidate and enhance the linting jobs in CI.
With this change, it's already easy to run the exact same configurations locally and automatically (when using devenv).

We're already using devenv in other repos (shards, crystal-book, crystal-website) and I'm very pleased with it.

@straight-shoota straight-shoota added this to the 1.19.0 milestone Oct 24, 2025
@straight-shoota straight-shoota merged commit 6d3ed28 into crystal-lang:master Oct 26, 2025
40 checks passed
@straight-shoota straight-shoota deleted the infra/devenv branch October 26, 2025 18:27
@ysbaddaden
Copy link
Collaborator

ysbaddaden commented Oct 27, 2025

Note: while I'm fine with a nix/devenv setup, I don't agree that the pre-commit hook depends on nix/devenv being installed and setup just to be able to run it.

It should only require that the executables are installed, which devenv, docker, podman, homebrew or chocolatey can provide.

@straight-shoota
Copy link
Member Author

straight-shoota commented Oct 27, 2025

The devenv setup should not prevent a custom pre-commit configuration without nix/devenv.
It might be a bit tricky if we wanted to commit a .pre-commit-config.yaml into the repository. But other from that I don't see any friction.
Is your comment just a general statement or do you have a specific issue?

@ysbaddaden
Copy link
Collaborator

ysbaddaden commented Oct 27, 2025

That's the problem: we must create a custom configuration file, and duplicate the devenv/git-hooks to pre-commit configuration 😞

Why not provide a .pre-commit-config.yaml that everybody can use?

@straight-shoota
Copy link
Member Author

Because that's hard to do? It requires all these tools to be available and there's no effective generic way to ensure they are.
devenv produces a .pre-commit-config.yaml which we could check in. But it uses hard-coded paths to /nix/store so it's not good to anyone not using devenv. If we patch the paths to use the plain commands instead, it should still work within a devenv shell (though it might reduce reproducibility guarantees a little bit). But it still wouldn't work unless you have all the required tools installed in your environment.

That's the nice thing about git-hooks from devenv: they're integrated with the package manager that makes the tools available.

If you use a custom pre-commit configuration, you can easily select which hooks you even want to run locally (for example, reuse is probably not very relevant; it should be enough to run it in CI). I'm planning to add some segmentation to the devenv config as well.

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.

2 participants