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

Fix private repos and add filename support #36

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

dasJ
Copy link
Contributor

@dasJ dasJ commented Nov 25, 2022

I'm very sorry for this.

So essentially when using a private repos, the sha1= parameter was replaced by the private token rather than the private token being appended to the query params.
This would have been an easy fix but that actually results in & being part of the derivation name which is invalid. This is why I now generate filenames for all the pins that are fetchurl'ed. Yay.

src/git.rs Outdated Show resolved Hide resolved
src/git.rs Outdated Show resolved Hide resolved
@dasJ dasJ force-pushed the fix/private-repos branch 3 times, most recently from b485e94 to b2c3ae1 Compare November 25, 2022 15:22
Copy link
Owner

@andir andir left a comment

Choose a reason for hiding this comment

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

Just a quick pass. We need some test coverage and commentary around the new code.

}
Some(url)
},
})
}

fn filename(&self) -> Option<String> {
Copy link
Owner

Choose a reason for hiding this comment

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

Tests pretty please.

match self {
Repository::GitLab { repo_path, .. } => Some(format!(
"npins-gitlab-{}.tar.gz",
repo_path.split('/').last().unwrap().to_owned()
Copy link
Owner

Choose a reason for hiding this comment

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

What are our assurances that we can really unwrap here? Do we verify this while unserializing? Do we verify it (only?) during interactive modification of the JSON file?


Ok(ChannelHash { hash })
}
}

impl Pin {
pub fn calc_filename(url: &url::Url) -> Result<String> {
Copy link
Owner

Choose a reason for hiding this comment

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

Tests please.


impl Pin {
pub fn calc_filename(url: &url::Url) -> Result<String> {
let name_parts = url.path_segments().unwrap().collect::<Vec<&str>>();
Copy link
Owner

Choose a reason for hiding this comment

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

What makes us think it is safe to unwrap here?

@piegamesde
Copy link
Collaborator

I really dislike having to track the name in the pins JSON. Is there no way that we can solve this in Nix on the import side of things with a simple string substitution?

@dasJ
Copy link
Contributor Author

dasJ commented Nov 28, 2022

I can try but I don't see how this will be fast

@dasJ
Copy link
Contributor Author

dasJ commented Nov 28, 2022

Ah yes we have to do this in the Rust code because nix-prefetch-url will otherwise fail because the path is invalid

@piegamesde
Copy link
Collaborator

The idea is, would it be possible to generate the derivation name on the fly where required instead of having to store it in the pins file.

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.

4 participants