devenv icon indicating copy to clipboard operation
devenv copied to clipboard

Directory doesn't work as expected when working with imports

Open soundofspace opened this issue 1 year ago • 0 comments

Posting here since I'm not sure if this is me doing something wrong or a bug.

Example project:

├── nested
│   ├── devenv.nix
│   └── package.json
├── devenv.lock
├── devenv.nix
└── devenv.yaml

devenv.yaml

inputs:
  nixpkgs:
    url: github:cachix/devenv-nixpkgs/rolling

imports:
  - ./nested

devenv.nix

{ pkgs, lib, config, inputs, ... }:
{
# https://devenv.sh/packages/
packages = [ ];

enterShell = ''
'';
}

nested/devenv.nix

{ pkgs, lib, config, inputs, ... }:
{
  packages = [ ];

  languages.javascript = rec {
    package = pkgs.nodejs_21;
    directory = "./nested";
    enable = true;
    yarn = {
      enable = true;
      install.enable = true;
    };
  };
}

Nested/devenv.nix directory needs to be set to /nested because importing this file changes the working directoy, but this doesn't feel right. It also makes importing things feel weird since importing something now requires changes to the original fix, hence breaking it if still used separately also. It feels that nested imports should all run in their own directory by default, and have access to the global parent through env var DEVENV_ROOT.

Relates to https://github.com/cachix/devenv/issues/316.

soundofspace avatar May 15 '24 18:05 soundofspace