cachix / devenv

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

Composing devenv.yaml #14

Open domenkozar opened 1 year ago

domenkozar commented 1 year ago

Please leave a thumbs up if you'd like to see this happen and a comment with your use case.

majidaldo commented 1 year ago

i'm coming from a conda-centric data science experience. i really want this to work! https://github.com/pnnl/hydraconda/blob/master/project/readme.md

i've been looking for ways to create composable environments.

edrex commented 7 months ago

I have a devenv file in my home dir / repo, and a bunch of task-specific environments in subdirs. They all want to track nixpkgs independently while I'd like to just track it once at the top level. Would this help with that?

My current workaround is to have each devenv.yaml point to the nixpkgs entry in the nix input registry:

inputs:
  nixpkgs:
    url: nixpkgs

( which on my systems is set to the nixpkgs entry revision used to build the system:

registry.nixpkgs.to = {
  owner = "NixOS";
  repo = "nixpkgs";
  rev = inputs.nixpkgs.rev;
  type = "github";
};

)

Other than not being as clean as referencing the input used at the repo root, the downside is the lock files still need to be updated individually for each subdir when the registry entry is updated.

euphemism commented 3 months ago

Getting around to experimenting with devenv. Like the above comment, I'm interested in hoisting shared configuration to a single place, and then consuming that in a number of repositories.

For example, in this higher-up shared environment configuration, I have something that checks for package.json in the project root, and if present configures JavaScript with a specific package version and setup. In this way, arbitrary repositories that consume the devenv environment from this one just magically have identical JavaScript tooling setup, without needing to add that to the individual repositories' devenv.nix files.

Extending that, I tried to setup something similar for Terraform. i.e. if there are any .tf files in the repo, setup the environment with Terraform support. Unfortunately, devenv gives me the following message in these downstream repos:

error: To use 'languages.terraform.version', run the following command:

  $ devenv inputs add nixpkgs-terraform github:stackbuilders/nixpkgs-terraform

Presumably, this could be an input at the top level and propagated downstream if devenv.yaml could be composed.