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

Try multiple file paths for netrc file #149

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
Open

Try multiple file paths for netrc file #149

wants to merge 8 commits into from

Conversation

lucperkins
Copy link
Member

This is meant to support older installs that placed the netrc at the relevant XDG path rather than in /nix.

@@ -477,6 +482,22 @@ fn validate_segment(s: &str) -> Result<(), FhError> {
Ok(())
}

// See if the netrc exists at the /nix/var/determinate/netrc and, if not, try
// to find it via XDG path.
async fn get_netrc_path(xdg: &BaseDirectories) -> Result<PathBuf, FhError> {
Copy link
Member

Choose a reason for hiding this comment

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

I kinda wonder about this... I think we probably need two separate functions: one for when we're getting a path-to-write-to (i.e. the user running fh login without determinate-nixd running), and one for when we're getting a path-to-read-from.

In the write-to one, it would take into account if determinate-nixd is running and return None if it is (since it won't write to a file, but will instead tell the daemon) and Some(xdg-path) if it's not.

In the read-from one, it would return netrcnotfound if the determinate and normal netrc files are not found.

Copy link
Member Author

Choose a reason for hiding this comment

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

What's the canonical way to determine if dnixd is running?

Copy link
Member

Choose a reason for hiding this comment

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

I think the dnixd_uds function is a good starting point, but basically request to http://localhost/info and see if it responds with 200.

Copy link
Member Author

Choose a reason for hiding this comment

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

Cool cool, shouldn't be too bad

Copy link
Member Author

Choose a reason for hiding this comment

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

@cole-h What action do we take if the write-to path is None?

Copy link
Member

Choose a reason for hiding this comment

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

I imagine that case is only reachable when we're using dnixd, so we just wouldn't write a file and tell the daemon to use this token the same way we do it already.

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.

2 participants