Heyo peeps,
I’ve been working on and off on my nixos journey, applying best practices as I learn along.
What I settled with is the idea of a “motherflake”: a single flake in a git repo that will contain everything I ever want as code. In particular, this motherflake contains the nixosconfigurations for all my machines, be it workstations or servers. My current attempt is here: GitHub - Chewie/motherflake: The Nixos flake to handle all of Loutre Telecom's configuration management
Keen eyes will notice a big problem in my config: everything is installed as packages, even stuff that should be a devshell. I didn’t notice this problem until I needed to install a C development library (cgreen): with nix-shell -p cgreen
, I can compile; but if I put it as a package in my nixos config it fails, because the appropriate env vars are not updated.
So after going back to the drawing board, I learned about devshells and I think that’s what I need. However, my needs are a bit different than the usual use case: as a teacher, I don’t just have a few projects I’m working on that deserve their own devshell in the flake of their repository, but I tend to create lot of small temporary “projects” on the fly when I want to demonstrate something quickly. I don’t want to have to define the same devshell over and over, instead I’d like to have a collection of basic devshells with sane defaults for various languages that I can use for those cases.
Unfortunately, from what I understand it doesn’t look like I can “install” devshells or make them part of a nixos configuration, I have to specify a flake each time I run nix develop
, which means either fetching from github each time, or having a local copy of my motherflake cloned somewhere in my home (eeeeh). Is there a way to have that behavior?
In some sense, what I want is for a given machine to not just have the appropriate nixosconfiguration built and deployed, but instead for it to have knowledge of the whole motherflake, but I don’t know if this idea is a good one. Any thoughts?
Another question: it also seems that nix develop
is not so much creating a “dev environment”, but something suitable to automatically run build/install commands as part of an automated process. I want my usual shell in here, with all its bells and whistle, when I’m developping something. Is nix develop
suited for this use case?
Cheers,