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

Dealing with non-root $PWD #26

Closed
srid opened this issue Jul 19, 2023 · 6 comments · Fixed by #27
Closed

Dealing with non-root $PWD #26

srid opened this issue Jul 19, 2023 · 6 comments · Fixed by #27
Labels
question Further information is requested

Comments

@srid
Copy link
Member

srid commented Jul 19, 2023

cd ./example
mkdir tmp
cd ./tmp
nix run

This creates the data diretory in ./example/tmp/data (instead of ./example/data as one would expect -- ie. in flake root). What is the best way to address this? In nammayatri we use flake-root + mission-control module to side-step the problem.

One possible solution here is to have services-flake require the use of flake-root module, and have the data directory use the flake root directory determined by the latter module.

@srid srid added the question Further information is requested label Jul 19, 2023
@srid
Copy link
Member Author

srid commented Jul 19, 2023

In some cases (where you are providing services to external users to be run via, say, nix run github:user/repo#blah), there is no such concept of flake root - so we should respect $PWD in these cases.

If we are using flake-root to solve this, then there should be a way to disable it, such as via a cdToProjectRoot option (cf. Platonic-Systems/mission-control#29).

@adrian-gierakowski
Copy link
Contributor

How about resolving the dir in the following order:

  1. if PRJ_ROOT is set, use that
  2. otherwise try flake root
  3. finally fallback on $PWD

@adrian-gierakowski
Copy link
Contributor

If we are using flake-root to solve this, then there should be a way to disable it, such as via a cdToProjectRoot

👍

@srid
Copy link
Member Author

srid commented Jul 19, 2023

I'm happy to add support for setting PRJ_ROOT in github:srid/flake-root if that env var is widely used. So, your sequence is narrowed down to (1) and (3) only.

The problem with resolving dir in an order like this is that the behaviour is no longer deterministic within the process-compose configuration. If you use flake-root, it behaves one way. If you don't, the same config.process-compose.<name> behaves differently. That's a bit of magic I'd like to avoid, and instead go for an explicit and local approach.

@srid
Copy link
Member Author

srid commented Jul 19, 2023

Maybe this should be solved upstream, in process-compose-flake. See Platonic-Systems/process-compose-flake#29 by @MrFoxPro

@srid
Copy link
Member Author

srid commented Jul 19, 2023

Is this really a problem that's worth solving in process-compose-flake / services-flake? I'm getting convinced that we should not. And instead document this, pointing users towards using mission-control + flake-root for a devShell experience.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants