Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

dotenv .env files from imports are not added to config.env #1582

Open
Maximilian-Staab opened this issue Nov 11, 2024 · 2 comments
Open

dotenv .env files from imports are not added to config.env #1582

Maximilian-Staab opened this issue Nov 11, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@Maximilian-Staab
Copy link

Describe the bug

Using both devenv.yaml

imports: 
 - ./submodule

and submodule/devenv.nix

dotenv.enable = true;
services.minio.accessKey = config.env.VAR;

submodule/.env

VAR=123

breaks devenv shell.

To reproduce
This issue is related to the project structure, so I created a git repo instead of a gist. Here it is: https://github.com/Maximilian-Staab/devenv-env-loading-issue

Expextation

  • Calling devenv shell with submodules that use dotenv.enable = true merges all applicable .env files.
  • (maybe) Conflicting keys lead to errors if the values differ.
  • I'm able to start all services/processes of all submodules from the root dir.
Error Log ``` devenv shell • Building shell ... • Using Cachix: devenv error: … while calling the 'derivationStrict' builtin at :9:12: 8| 9| strict = derivationStrict drvAttrs; | ^ 10|
   … while evaluating derivation 'devenv-shell'
     whose name attribute is located at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/stdenv/generic/make-derivation.nix:331:7

   … while evaluating attribute 'DEVENV_PROFILE' of derivation 'devenv-shell'

   … while calling the 'getAttr' builtin
     at <nix/derivation-internal.nix>:19:19:
       18|       value = commonAttrs // {
       19|         outPath = builtins.getAttr outputName strict;
         |                   ^
       20|         drvPath = strict.drvPath;

   … while calling the 'derivationStrict' builtin
     at <nix/derivation-internal.nix>:9:12:
        8|
        9|   strict = derivationStrict drvAttrs;
         |            ^
       10|

   … while evaluating derivation 'devenv-profile'
     whose name attribute is located at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/stdenv/generic/make-derivation.nix:331:7

   … while evaluating attribute 'passAsFile' of derivation 'devenv-profile'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/build-support/trivial-builders/default.nix:69:9:
       68|         inherit buildCommand name;
       69|         passAsFile = [ "buildCommand" ]
         |         ^
       70|           ++ (derivationArgs.passAsFile or [ ]);

   … while evaluating the attribute 'passAsFile'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/build-support/buildenv/default.nix:76:5:
       75|     # XXX: The size is somewhat arbitrary
       76|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
         |     ^
       77|   }

   … while evaluating a branch condition
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/build-support/buildenv/default.nix:76:18:
       75|     # XXX: The size is somewhat arbitrary
       76|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
         |                  ^
       77|   }

   … in the argument of the not operator
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/build-support/buildenv/default.nix:76:48:
       75|     # XXX: The size is somewhat arbitrary
       76|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
         |                                                ^
       77|   }

   … while calling the 'lessThan' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/build-support/buildenv/default.nix:76:48:
       75|     # XXX: The size is somewhat arbitrary
       76|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
         |                                                ^
       77|   }

   … while calling the 'stringLength' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/build-support/buildenv/default.nix:76:21:
       75|     # XXX: The size is somewhat arbitrary
       76|     passAsFile = if builtins.stringLength pkgs >= 128*1024 then [ "pkgs" ] else [ ];
         |                     ^
       77|   }

   … while calling the 'toJSON' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/build-support/buildenv/default.nix:58:12:
       57|             nativeBuildInputs buildInputs;
       58|     pkgs = builtins.toJSON (map (drv: {
         |            ^
       59|       paths =

   … while evaluating list element at index 1

   … while evaluating attribute 'paths'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/build-support/buildenv/default.nix:59:7:
       58|     pkgs = builtins.toJSON (map (drv: {
       59|       paths =
         |       ^
       60|         # First add the usual output(s): respect if user has chosen explicitly,

   … while evaluating list element at index 0
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/build-support/buildenv/default.nix:59:7:
       58|     pkgs = builtins.toJSON (map (drv: {
       59|       paths =
         |       ^
       60|         # First add the usual output(s): respect if user has chosen explicitly,

   … while calling the 'getAttr' builtin
     at <nix/derivation-internal.nix>:19:19:
       18|       value = commonAttrs // {
       19|         outPath = builtins.getAttr outputName strict;
         |                   ^
       20|         drvPath = strict.drvPath;

   … while calling the 'derivationStrict' builtin
     at <nix/derivation-internal.nix>:9:12:
        8|
        9|   strict = derivationStrict drvAttrs;
         |            ^
       10|

   … while evaluating derivation 'mc'
     whose name attribute is located at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/stdenv/generic/make-derivation.nix:331:7

   … while evaluating attribute 'text' of derivation 'mc'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/build-support/trivial-builders/default.nix:103:17:
      102|       ({
      103|         inherit text executable checkPhase allowSubstitutes preferLocalBuild;
         |                 ^
      104|         passAsFile = [ "text" ]

   … while calling the 'getAttr' builtin
     at <nix/derivation-internal.nix>:19:19:
       18|       value = commonAttrs // {
       19|         outPath = builtins.getAttr outputName strict;
         |                   ^
       20|         drvPath = strict.drvPath;

   … while calling the 'derivationStrict' builtin
     at <nix/derivation-internal.nix>:9:12:
        8|
        9|   strict = derivationStrict drvAttrs;
         |            ^
       10|

   … while evaluating derivation 'mc-config.json'
     whose name attribute is located at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/stdenv/generic/make-derivation.nix:331:7

   … while evaluating attribute 'value' of derivation 'mc-config.json'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/pkgs-lib/formats.nix:64:7:
       63|       nativeBuildInputs = [ jq ];
       64|       value = builtins.toJSON value;
         |       ^
       65|       passAsFile = [ "value" ];

   … while calling the 'toJSON' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/pkgs/pkgs-lib/formats.nix:64:15:
       63|       nativeBuildInputs = [ jq ];
       64|       value = builtins.toJSON value;
         |               ^
       65|       passAsFile = [ "value" ];

   … while evaluating attribute 'aliases'

   … while evaluating attribute 'local'

   … while calling anonymous lambda
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:578:22:
      577|       merge = loc: defs:
      578|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
         |                      ^
      579|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

   … while evaluating the attribute 'value'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:857:27:
      856|     optionalValue =
      857|       if isDefined then { value = mergedValue; }
         |                           ^
      858|       else {};

   … from call site
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:846:59:
      845|       if isDefined then
      846|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal
         |                                                           ^
      847|         else let allInvalid = filter (def: ! type.check def.value) defsFinal;

   … while calling 'merge'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:646:20:
      645|       check = x: x == null || elemType.check x;
      646|       merge = loc: defs:
         |                    ^
      647|         let nrNulls = count (def: def.value == null) defs; in

   … from call site
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:651:14:
      650|           throw "The option `${showOption loc}` is defined both null and not null, in ${showFiles (getFiles defs)}."
      651|         else elemType.merge loc defs;
         |              ^
      652|       emptyValue = { value = null; };

   … while calling 'merge'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:891:20:
      890|       check = x: t1.check x || t2.check x;
      891|       merge = loc: defs:
         |                    ^
      892|         let

   … from call site
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:896:21:
      895|           if   all (x: t1.check x) defList
      896|                then t1.merge loc defs
         |                     ^
      897|           else if all (x: t2.check x) defList

   … while calling 'merge'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:891:20:
      890|       check = x: t1.check x || t2.check x;
      891|       merge = loc: defs:
         |                    ^
      892|         let

   … from call site
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:898:21:
      897|           else if all (x: t2.check x) defList
      898|                then t2.merge loc defs
         |                     ^
      899|           else mergeOneOption loc defs;

   … while calling 'merge'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:577:20:
      576|       check = isAttrs;
      577|       merge = loc: defs:
         |                    ^
      578|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:

   … while calling the 'mapAttrs' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:578:9:
      577|       merge = loc: defs:
      578|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
         |         ^
      579|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

   … from call site
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:578:35:
      577|       merge = loc: defs:
      578|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
         |                                   ^
      579|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

   … while calling 'filterAttrs'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:646:5:
      645|     pred:
      646|     set:
         |     ^
      647|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));

   … while calling the 'listToAttrs' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:647:5:
      646|     set:
      647|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
         |     ^
      648|

   … while calling the 'concatMap' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:647:18:
      646|     set:
      647|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
         |                  ^
      648|

   … while calling anonymous lambda
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:647:29:
      646|     set:
      647|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
         |                             ^
      648|

   … while evaluating a branch condition
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:647:59:
      646|     set:
      647|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
         |                                                           ^
      648|

   … from call site
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:647:62:
      646|     set:
      647|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
         |                                                              ^
      648|

   … while calling anonymous lambda
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:578:51:
      577|       merge = loc: defs:
      578|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
         |                                                   ^
      579|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

   … from call site
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:647:43:
      646|     set:
      647|     listToAttrs (concatMap (name: let v = set.${name}; in if pred name v then [(nameValuePair name v)] else []) (attrNames set));
         |                                           ^
      648|

   … while calling anonymous lambda
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:578:86:
      577|       merge = loc: defs:
      578|         mapAttrs (n: v: v.value) (filterAttrs (n: v: v ? value) (zipAttrsWith (name: defs:
         |                                                                                      ^
      579|             (mergeDefinitions (loc ++ [name]) elemType defs).optionalValue

   … while evaluating the attribute 'optionalValue'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:856:5:
      855|
      856|     optionalValue =
         |     ^
      857|       if isDefined then { value = mergedValue; }

   … while evaluating a branch condition
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:857:7:
      856|     optionalValue =
      857|       if isDefined then { value = mergedValue; }
         |       ^
      858|       else {};

   … while evaluating the attribute 'values'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:838:9:
      837|       in {
      838|         values = defs''';
         |         ^
      839|         inherit (defs'') highestPrio;

   … while evaluating a branch condition
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:834:11:
      833|           # Avoid sorting if we don't have to.
      834|           if any (def: def.value._type or "" == "order") defs''.values
         |           ^
      835|           then sortProperties defs''.values

   … while calling the 'any' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:834:14:
      833|           # Avoid sorting if we don't have to.
      834|           if any (def: def.value._type or "" == "order") defs''.values
         |              ^
      835|           then sortProperties defs''.values

   … while evaluating the attribute 'values'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:937:7:
      936|     in {
      937|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
         |       ^
      938|       inherit highestPrio;

   … while calling the 'concatMap' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:937:16:
      936|     in {
      937|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
         |                ^
      938|       inherit highestPrio;

   … while calling the 'concatMap' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:824:17:
      823|         # Process mkMerge and mkIf properties.
      824|         defs' = concatMap (m:
         |                 ^
      825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

   … while calling anonymous lambda
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:824:28:
      823|         # Process mkMerge and mkIf properties.
      824|         defs' = concatMap (m:
         |                            ^
      825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

   … while calling the 'map' builtin
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:825:11:
      824|         defs' = concatMap (m:
      825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
         |           ^
      826|         ) defs;

   … while evaluating definitions from `«github:cachix/devenv/983153344922e5fb8545aae7e5e70127da981a71»/src/modules/services/minio.nix':

   … from call site
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:825:137:
      824|         defs' = concatMap (m:
      825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
         |                                                                                                                                         ^
      826|         ) defs;

   … while calling 'dischargeProperties'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:896:25:
      895|   */
      896|   dischargeProperties = def:
         |                         ^
      897|     if def._type or "" == "merge" then

   … while evaluating a branch condition
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:897:5:
      896|   dischargeProperties = def:
      897|     if def._type or "" == "merge" then
         |     ^
      898|       concatMap dischargeProperties def.contents

   … while evaluating the attribute 'value'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/types.nix:582:60:
      581|           # Push down position info.
      582|           (map (def: mapAttrs (n: v: { inherit (def) file; value = v; }) def.value) defs)));
         |                                                            ^
      583|       emptyValue = { value = {}; };

   … from call site
     at «github:cachix/devenv/983153344922e5fb8545aae7e5e70127da981a71»/src/modules/services/minio.nix:163:23:
      162|         url = "http://${if lib.hasPrefix ":" cfg.listenAddress then "localhost:${cfg.listenAddress}" else cfg.listenAddress}";
      163|         inherit (cfg) accessKey secretKey;
         |                       ^
      164|         api = "S3v4";

   … while calling anonymous lambda
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:1171:18:
     1170|         mapAttrs
     1171|           (name: value:
         |                  ^
     1172|             if isAttrs value && cond value

   … from call site
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:1174:18:
     1173|             then recurse (path ++ [ name ]) value
     1174|             else f (path ++ [ name ]) value);
         |                  ^
     1175|     in

   … while calling anonymous lambda
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:242:72:
      241|           # For definitions that have an associated option
      242|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
         |                                                                        ^
      243|

   … while evaluating the attribute 'value'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:809:9:
      808|     in warnDeprecation opt //
      809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
         |         ^
      810|         inherit (res.defsFinal') highestPrio;

   … while evaluating the option `services.minio.accessKey':

   … while evaluating the attribute 'mergedValue'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:844:5:
      843|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
      844|     mergedValue =
         |     ^
      845|       if isDefined then

   … while evaluating a branch condition
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:845:7:
      844|     mergedValue =
      845|       if isDefined then
         |       ^
      846|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal

   (8 duplicate frames omitted)

   … while evaluating definitions from `/home/max/Workspace/temp/submodule/devenv.nix':

   … from call site
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:825:137:
      824|         defs' = concatMap (m:
      825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
         |                                                                                                                                         ^
      826|         ) defs;

   … while calling 'dischargeProperties'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:896:25:
      895|   */
      896|   dischargeProperties = def:
         |                         ^
      897|     if def._type or "" == "merge" then

   … while evaluating a branch condition
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:897:5:
      896|   dischargeProperties = def:
      897|     if def._type or "" == "merge" then
         |     ^
      898|       concatMap dischargeProperties def.contents

   … while evaluating the attribute 'value'
     at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:607:53:
      606|                 (n: value:
      607|                   [{ inherit (module) file; inherit value; }]
         |                                                     ^
      608|                 )

   error: at /home/max/Workspace/temp/submodule/devenv.nix:8:17:
        7|     enable = true;
        8|     accessKey = config.env.S3_AK;
         |                 ^
        9|     secretKey = config.env.S3_SK;

   error: attribute 'S3_AK' missing

✔ Building shell in 0.6s.
Error: × Failed to run command /nix/store/wssamm2w2917xv940zkhrhhq0rd5xilc-nix-2.24-devenv/bin/nix --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes --option warn-dirty false --keep-going --max-jobs 6 --option eval-cache false │ --option extra-substituters https://devenv.cachix.org --option extra-trusted-public-keys nixpkgs-python.cachix.org-1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU= devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw= print-dev-env --profile /home/max/ │ Workspace/temp/.devenv/gc/shell -vv --log-format internal-json
╰─▶ Nix command failed: exit status: 1

</details>

**Version**
 
Paste the output of `$ devenv version` here or tell us if you're using flakes.
@Maximilian-Staab Maximilian-Staab added the bug Something isn't working label Nov 11, 2024
@sandydoo
Copy link
Member

This is expected. Paths and strings paths are resolved from the root of the project, ie. the top-level devenv.nix from where devenv shell is called. This is a Nix (and Nix flakes) limitation and we have absolutely no way resolving paths this way.

You can add additional paths with dotenv.filename = [ ".env" "submodule/.env" ];, but you'll have to stick to using the top-level devenv.nix.

@Maximilian-Staab
Copy link
Author

Hi, thank you for your response.

I just tried this, but it seems like there's some string validation that breaks this. The error I'm getting is The dotenv filename must start with '.env'.

Here's the full log:

Error Log
direnv: loading https://raw.githubusercontent.com/cachix/devenv/82c0147677e510b247d8b9165c54f73d32dfd899/direnvrc (sha256-7u4iDd1nZpxL4tCzmPG0dQgC5V+/44Ba+tHkPob1v2k=)
direnv: using devenv
direnv: .envrc changed, reloading
• Using Cachix: devenv
error:
       … from call site
         at /home/max/Nextcloud/Dateien/AutoPulse/.devenv.flake.nix:147:34:
          146|           build = build project.options project.config;
          147|           devShell."${system}" = config.shell;
             |                                  ^
          148|         };

       … while calling anonymous lambda
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:1171:18:
         1170|         mapAttrs
         1171|           (name: value:
             |                  ^
         1172|             if isAttrs value && cond value

       … from call site
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/attrsets.nix:1174:18:
         1173|             then recurse (path ++ [ name ]) value
         1174|             else f (path ++ [ name ]) value);
             |                  ^
         1175|     in

       … while calling anonymous lambda
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:242:72:
          241|           # For definitions that have an associated option
          242|           declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
             |                                                                        ^
          243|

       … while evaluating the attribute 'value'
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:809:9:
          808|     in warnDeprecation opt //
          809|       { value = builtins.addErrorContext "while evaluating the option `${showOption loc}':" value;
             |         ^
          810|         inherit (res.defsFinal') highestPrio;

       … while evaluating the option `shell':

       … while evaluating the attribute 'mergedValue'
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:844:5:
          843|     # Type-check the remaining definitions, and merge them. Or throw if no definitions.
          844|     mergedValue =
             |     ^
          845|       if isDefined then

       … while evaluating a branch condition
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:845:7:
          844|     mergedValue =
          845|       if isDefined then
             |       ^
          846|         if all (def: type.check def.value) defsFinal then type.merge loc defsFinal

       … while evaluating the attribute 'values'
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:838:9:
          837|       in {
          838|         values = defs''';
             |         ^
          839|         inherit (defs'') highestPrio;

       … while evaluating a branch condition
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:834:11:
          833|           # Avoid sorting if we don't have to.
          834|           if any (def: def.value._type or "" == "order") defs''.values
             |           ^
          835|           then sortProperties defs''.values

       … while calling the 'any' builtin
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:834:14:
          833|           # Avoid sorting if we don't have to.
          834|           if any (def: def.value._type or "" == "order") defs''.values
             |              ^
          835|           then sortProperties defs''.values

       … while evaluating the attribute 'values'
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:937:7:
          936|     in {
          937|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |       ^
          938|       inherit highestPrio;

       … while calling the 'concatMap' builtin
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:937:16:
          936|     in {
          937|       values = concatMap (def: if getPrio def == highestPrio then [(strip def)] else []) defs;
             |                ^
          938|       inherit highestPrio;

       … while calling the 'concatMap' builtin
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:824:17:
          823|         # Process mkMerge and mkIf properties.
          824|         defs' = concatMap (m:
             |                 ^
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while calling anonymous lambda
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:824:28:
          823|         # Process mkMerge and mkIf properties.
          824|         defs' = concatMap (m:
             |                            ^
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))

       … while calling the 'map' builtin
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:825:11:
          824|         defs' = concatMap (m:
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |           ^
          826|         ) defs;

       … while evaluating definitions from `«github:cachix/devenv/c5353d1a0483b8f0dc15933de91c6b1b9a892831»/src/modules/top-level.nix':

       … from call site
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:825:137:
          824|         defs' = concatMap (m:
          825|           map (value: { inherit (m) file; inherit value; }) (builtins.addErrorContext "while evaluating definitions from `${m.file}':" (dischargeProperties m.value))
             |                                                                                                                                         ^
          826|         ) defs;

       … while calling 'dischargeProperties'
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:896:25:
          895|   */
          896|   dischargeProperties = def:
             |                         ^
          897|     if def._type or "" == "merge" then

       … while evaluating a branch condition
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:897:5:
          896|   dischargeProperties = def:
          897|     if def._type or "" == "merge" then
             |     ^
          898|       concatMap dischargeProperties def.contents

       … while evaluating the attribute 'value'
         at «github:cachix/devenv-nixpkgs/4267e705586473d3e5c8d50299e71503f16a6fb6»/lib/modules.nix:607:53:
          606|                 (n: value:
          607|                   [{ inherit (module) file; inherit value; }]
             |                                                     ^
          608|                 )

       … while calling the 'throw' builtin
         at «github:cachix/devenv/c5353d1a0483b8f0dc15933de91c6b1b9a892831»/src/modules/top-level.nix:31:7:
           30|     then
           31|       throw ''
             |       ^
           32|         Failed assertions:

       error:
       error: Failed assertions:
       - The dotenv filename must start with '.env'.
Error:   × Failed to run command `/nix/store/wssamm2w2917xv940zkhrhhq0rd5xilc-nix-2.24-devenv/bin/nix
  │ --show-trace --extra-experimental-features nix-command --extra-experimental-features flakes
  │ --option warn-dirty false --keep-going --max-jobs 8 --option eval-cache false --option extra-
  │ substituters https://devenv.cachix.org --option extra-trusted-public-keys nixpkgs-python.cachix.org-
  │ 1:hxjI7pFxTyuTHn2NkvWCrAUcNZLNS3ZAvfYNuYifcEU= devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/
  │ Hm9XgU50cw= print-dev-env --profile /home/max/Nextcloud/Dateien/AutoPulse/.devenv/gc/shell -vv --log-
  │ format internal-json`
  ╰─▶ Nix command failed: exit status: 1

direnv: failed to build the devenv environment. devenv.nix may contain errors. see above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants