cachix / devenv

Fast, Declarative, Reproducible, and Composable Developer Environments
https://devenv.sh
Apache License 2.0
4.32k stars 323 forks source link

Specifying machine configuration #286

Open domenkozar opened 1 year ago

domenkozar commented 1 year ago

We have a bunch of ways to describe machines: NixOS, nix-darwin, home-manager.

It would be nice if we could describe them in devenv and then they can be references elsewhere to be built, etc.

Proposal for the interface:

{
  machines."mydesktop".system = "x86_64-linux";
  machines."mydesktop".nixos = {
    fileSystems."/".device = "/dev/sda1";
  };

  machines."myhome".home-manager = {
    home.username = "jdoe";
    home.homeDirectory = "/home/jdoe";
  };

  machines."mylaptop".nix-darwin = { pkgs, ... }: {
    environment.systemPackages =[
      pkgs.vim
    ];
  };
}
Mic92 commented 1 year ago

What would be the differentiation from having the same information in flake.nix (nixosConfigurations, homeConfigurations etc)

thenonameguy commented 1 year ago

How is this relevant for per-project development environments? This seems to be specifying a cluster of machines, which is not the goal for devenv.

domenkozar commented 1 year ago

You can have for example (interface is just to show how it could work):

{
  process."runmyapp".machine = "mylaptop";
}

I've probably misguided the goal of this issue with names, but the idea is to describe other modules systems in devenv and be able to combine them.

The declarative interface to describing things would be abstract, but different options could consume it.

thenonameguy commented 1 year ago

Interesting, I never had this use-case. Even still, if I had to run a NixOS configuration for my development, I would do:

{ 
  process."runmyapp".exec = "${some-nixos-config.config.system.build.vm}/bin/run-vm";
}

And let Nix handle the module system.

domenkozar commented 1 year ago

That boilerplate is what I'd like to hide away for common tasks - one of the goals with devenv is to make simple things simple.

There's still the low-level interface process.my.exec but things like services.myservice and machine.mything abstract that away and turn it into flipping a knob.

thenonameguy commented 1 year ago

I think the set of people who can write a NixOS configuration +/ nix-darwin +/ home-manager modules AND need those things present for having a VM executable for their project that can't figure out the above snippet is empty :)

I would also note the distinction between simple and easy. If your project needs a VM to be able to run, it's so complected to it's runtime environment that there won't be a comfortable way of developing it, even if using devenv or not. At that point some Nix experience for wiring everything together is expected.

When you are this deep, usually you have a flake.nix at this point, and use specialArgs to inject your own packages to the machine or using overlays, etc. This assumes a deeper understanding of Nix + NixOS.

I think the main question is does devenv want to fully surpass Flakes or augment it mainly for devShells