Tutorial: Using flake-parts to build a GitHub page powered by Astro/Starlight

Heyo, when I started with flake.parts, I missed some easy examples on how to use it in practice.

I wrote a simple tutorial here to use flake-parts to set up a dev-shell with nodejs:

https://blog.eigenvalue.net/2024-flake-parts-nodejs-devshell/

There is nothing fancy in there (I hope!) but it might make it easier for people new to flake.parts to wrap their head around it.

Let me know what you think. I want to follow it up with a tutorial on how to setup
a Astro/Starlight GitHub page based on this – built hermetically with nix.

7 Likes

Thank you very much. Why have you decided to use Numtide’s devshell instead of for example devenv.sh?

1 Like

As I wrote in the intro, there are a lot of (partially arbitrary) choices.

I used devenv before and it is definitely a strong contender, especially for the task in the tutorial. I also learned quite a thing by looking at the code and @domenkozar is obviously awesome.

The documentation is really nice and it has more features. devshell documentations is worse and it marks itself as unstable. (though devenv also has a 0.6.x version indicating that it does not commit yet to a stable API)

Shim over nix

Maybe the main part is what I dislike of both: They build on top of nix but want to simplify it and thus provide alternative ways to configure it: devshell toml and devenv yaml.

devenv takes it further by providing its own CLI and direnv integration.

I don’t say that’s wrong, especially for newcomers. But I want to keep the dependencies minimal (i.e. nix-only) and keep the config in nix because I think that is more composable. It obviously also exposes you to the power and the pain of nix.

Both alternatives allow you to use just nix with flakes. I “feel” (and it is not much more than that) that devenvs emphasis is more on its own CLI and that is likely what is better tested etc.

Conclusion

So, in a sense, for something really simple, I prefer devshell. I could have also probably just gotten away with nixpkgs but devshell provides a cleaner environment and I do like the menu – but something that would be easy to add to any solution.

I think it would be great if there was a canonical “nix-only” solution that devenv/devshell used underneath as a library. Just to reduce choice where it doesn’t matter much. But I also think that they both might want to innovate/experiment in terms of settings and that’s easier if something is completely under the control of one person/org. Coordination/consolidation costs time :wink:

I hope that makes sense!

In terms of the tutorial, it would make total sense to provide a devenv.sh variant and it could be easily done. But what criteria would I give the reader as for chosing one over the other without getting to philosphical?

I would be interesting to hear if @domenkozar or @zimbatm have thoughts on this…

1 Like

Found this from @domenkozar :

The next step in this tutorial series is here:

https://blog.eigenvalue.net/2024-astro-starlight-with-nix/

Based on what we built in the first part (a dev environment with node/npm), we’ll
add Astro/Starlight to the repo and build the docs with nix!

Let me know what you think.

3 Likes