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

Devenv init template support #1718

Open
liammcdermott opened this issue Feb 11, 2025 · 4 comments · May be fixed by #1721
Open

Devenv init template support #1718

liammcdermott opened this issue Feb 11, 2025 · 4 comments · May be fixed by #1721
Labels
enhancement New feature or request

Comments

@liammcdermott
Copy link

liammcdermott commented Feb 11, 2025

Problem

I'm developing drupal-devenv, which builds on devenv to provide Drupal development environments.

I feel the Getting Started process is less than ideal, users have to run devenv init, then edit our repo into their project's inputs and add the corresponding import. If you're new to devenv, this is all a bit opaque and gives a first impression that it requires a lot of boilerplate.

Meanwhile, the competition is ddev, where getting started is ddev config followed by ddev start. While the config step does ask some questions, the whole process is short and streamlined.

Solution

If we could provide a template for use with devenv init, with pre-configured inputs and such, users could get started just as easily as with ddev. For example, the usage might look like:

devenv init --template gitlab:woolwichweb/drupal-devenv

Then users just have to run devenv up to get a fully working Drupal development environment.

Related: #1705

@liammcdermott liammcdermott added the enhancement New feature or request label Feb 11, 2025
@LorenzBischof LorenzBischof linked a pull request Feb 12, 2025 that will close this issue
@LorenzBischof
Copy link
Contributor

I created a really simple implementation. May I ask why you don't just use nix flake init -t directly?

@liammcdermott
Copy link
Author

Fantastic, thanks for working on this!

May I ask why you don't just use nix flake init -t directly?

I just assumed it wouldn't work with devenv. In particular devenv's default mode, with Flake inputs defined in devenv.yaml, and a flake file named .devenv.flake.nix. Maybe I'm wrong about that though.

Since you created a PR, I'm assuming you see the value in having the template parameter on devenv init? I believe it's less confusing for users who aren't familiar with Nix.

@LorenzBischof
Copy link
Contributor

LorenzBischof commented Feb 12, 2025

I made a quick example. You can use it with:

nix flake init -t github:LorenzBischof/devenv-issue-1718

I don't really see any benefit, other than a simpler interface. In your documentation you would also have to add --extra-experimental-features "nix-command flakes" to the command in case someone does not have the features enabled yet.

edit: I updated the example with a welcomeText which might be useful for your use case. I also noticed that the template gets cached locally. To force retrieval of the newest version use --refresh. The cache probably expires after a while, so it should not be necessary for you to document it.

@liammcdermott
Copy link
Author

Thank you so much for the pointer and example! I didn't know it was even possible to use Flakes in that way. The welcomeText example is also really nice.

I don't really see any benefit, other than a simpler interface.

Yeah, that's pretty-much it. But, even knowing about nix flake init -t, I would still ask for this feature for social reasons:

  1. It signals that building your own templates, and using other peoples' templates with devenv is explicitly supported.
  2. It reduces the ‘wtf is this? wtf command am I even running’ factor for newer users.
  3. Looking at the diff, the implementation is very simple. So, sure the benefit is limited, but so is the cost.
  4. Internally, it reminds maintainers that templates are a supported workflow. For example, anything about templates that the switch to Tvix might break should be fixed (I can't think of anything, but who knows?)
  5. This view may be wrong, but I feel Devenv exists to provide a simpler interface over modules and Flakes, and this feature aligns with that principle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants