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

feat: support extending a parent environment #398

Merged
merged 1 commit into from Mar 13, 2024

Conversation

jvmakine
Copy link
Collaborator

Adds a new environment configuration to bin/hermit.hcl

inherit-parent = true

Setting this inherits the Hermit environment from a parent directory, inheriting environment variables and packages.

This should be useful in larger monorepos where we want to have a single root environment with most tooling, but want to still allow subprojects to have their own owerwrites and environment variables.

Note, the packages in parent environment won't have access to the child environment even when being called from the child environment. This means that any package calling another package in the parent environment will still call the parent package even if that is overwritten in the child environment. Though this can be potentially confusing, it should give more consistent behaviour between parent and child environments. Also, package dependencies can not cross environments. So, it is not possible to have a package dependency from a child environment package to a parent environment package.

Finally, for the time being, all hermit operations apply only to the currently active environment. So, it is not possible to upgrade, install, or uninstall parent packages from the child environment

Adds a new environment configuration to bin/hermit.hcl
```
inherit-parent = true
```

Setting this inherits the Hermit environment from a parent directory, inheriting environment variables and packages.

This should be useful in larger monorepos where we want to have a single root environment with most tooling, but want to still allow subprojects to have their own owerwrites and environment variables.

Note, the packages in parent environment won't have access to the child environment even when being called from the child environment. This means that any package calling another package in the parent environment will still call the parent package even if that is overwritten in the child environment. Though this can be potentially confusing, it should give more consistent behaviour between parent and child environments. Also, package dependencies can not cross environments. So, it is not possible to have a package dependency from a child environment package to a parent environment package.

Finally, for the time being, all hermit operations apply only to the currently active environment. So, it is not possible to upgrade or uninstall parent packages from the child environment, for example
Copy link
Collaborator

@alecthomas alecthomas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That is surprisingly straightforward. Awesome.

pkgs, err := e.ListInstalled(l)
if err != nil {
return nil, err
}
return e.allEnvarOpsForPackages(nil, nil, pkgs...), nil
return append(ops, e.allEnvarOpsForPackages(nil, nil, pkgs...)...), nil
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops for the win!

@jvmakine jvmakine merged commit d30b168 into master Mar 13, 2024
6 checks passed
@jvmakine jvmakine deleted the juho/nested-environments branch March 13, 2024 05:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants