Skip to content

Add support for evaluating values of environment variable definitions #11

@astratagem

Description

@astratagem

Currently, env attribute values are interpreted as a static string. That means that it is not possible to include existing environment variables inside a new definition. For example:

make-shells.default.env = {
  HOME_DRV = "\${XDG_STATE_HOME:-$HOME/.local/state}/nix/profiles/home-manager";
};

Results in:

$ echo $HOME_DRV
${XDG_STATE_HOME:-$HOME/.local/state}/nix/profiles/home-manager

Though I would hope for something like this result instead:

$ echo $HOME_DRV
/home/<USER>/.local/state/nix/profiles/home-manager

https://github.com/numtide/devshell provides a mechanism to handle this, which can be seen in https://github.com/numtide/devshell/blob/main/modules/env.nix and loaded as a setup hook in https://github.com/numtide/devshell/blob/7c9e793ebe66bcba8292989a68c0419b737a22a0/modules/devshell.nix (see the envBash variable). It would be great if make-shell did something similar, but in a simpler way!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions