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

Fail certain programs outside of Project Manager environment #85

Open
sellout opened this issue Aug 12, 2024 · 0 comments
Open

Fail certain programs outside of Project Manager environment #85

sellout opened this issue Aug 12, 2024 · 0 comments

Comments

@sellout
Copy link
Owner

sellout commented Aug 12, 2024

I don’t know if this is solvable, but perhaps there are some mitigations.

If you have Project Manager configured to allow non-Nix-using contributors, then this isn’t an issue, as all generated files will have “repository” persistence.

However, if you intend contributors to use Nix, but someone isn’t (perhaps a direnv failure or forgot to run nix develop), then binaries on their system PATH may lead to confusing or inconsistent behavior.

E.g., clang-format can run without a .clang-format file. If the .clang-format file in your repo has “store” persistence, but the user runs clang-format outside of a Project Manager environment, it’ll format using the default style.

One way to prevent this would be to add a .clang-format file to the worktree containing something like

# IMPORTANT: `clang-format` must be run from a Project Manager environment.
# Run `direnv reload` or `nix develop .#project-manager` and then run `clang-format` there.
broken config = cause clang-format to error

which would result in clang-format erroring instead of formatting the files.

Of course, this still requires the user to have run project-manager switch to generate this erroneous file in the first place. Giving it “repository” persistence would avoid that.

However, once you’re generating these files, why not just give the correct file the higher persistence in the first place? One reason might be that clang-format v15 and clang-format v16 cause different formatting even with identical files.

Regardless, this approach seems far from ideal. I wouldn’t use it personally.

Another option might be to have direnv produce an empty environment rather than failing, so that you can’t overlook the failure and accidentally run programs from outside the environment. But this is also not something I would do personally.

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

No branches or pull requests

1 participant