nmattia / niv

Easy dependency management for Nix projects

Home Page:https://github.com/nmattia/niv

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

autodetect obvious URLs (`niv add https://github.com/user/repo.git`)

deliciouslytyped opened this issue · comments

It would be convenient if niv add could take automatically recognize some defined url so I could just paste the repo path instead of writing github -u user -r repo -n repo.

Maybe there could be a config file that contains regexes with captures or something, though personally I'm fine with just predefined things for gitlab and github, which would probably cover 99% of cases.

Hello @deliciouslytyped,

For github, you can already do niv add nmattia/niv and niv add github nmattia/niv which is as short as can be. I can see that using urls could be convenient since that's what we already use with git.

Ex:

niv add https://github.com/nmattia/niv
niv add https://github.com/nmattia/niv.git
niv add git@github.com:nmattia/niv.git

It's not about length, it's about copy-pasting ;)

I agree this would be nice! right now we differentiate between "github" and "git" dependencies, I guess some cases would be a bit ambiguous (but this would be based on heuristics anyways...)

I did the same thing and I had to search in github issue to figure out the cryptic error as like any other nix projects (then I also found it by manually checking the help). I wish niv would just accept the input.

> niv add https://github.com/nix-community/impermanence
Adding package /github.com/nix-community/impermanence
WARNING: Could not read from GitHub repo: https://github.com/nix-community/impermanence
I assumed that your package was a GitHub repository. An error occurred while
gathering information from the repository. Check whether your package was added
correctly:

  niv show

If not, try re-adding it:

  niv drop <package>
  niv add <package-without-typo>

Make sure the repository exists.

(Error was: (Request {
  host                 = "api.github.com"
  port                 = 443
  secure               = True
  requestHeaders       = [("user-agent","niv"),("accept","application/vnd.github.v3+json")]
  path                 = "/repos/https://github.com/nix-community/impermanence"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
,Response {responseStatus = Status {statusCode = 404, statusMessage = "Not Found"}, responseVersion = HTTP/1.1, responseHeaders = [("Server","GitHub.com"),("Date","Sat, 12 Mar 2022 10:24:46 GMT"),("Content-Type","application/json; charset=utf-8"),("X-GitHub-Media-Type","github.v3; format=json"),("Access-Control-Expose-Headers","ETag, Link, Location, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Used, X-RateLimit-Resource, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval, X-GitHub-Media-Type, X-GitHub-SSO, X-GitHub-Request-Id, Deprecation, Sunset"),("Access-Control-Allow-Origin","*"),("Strict-Transport-Security","max-age=31536000; includeSubdomains; preload"),("X-Frame-Options","deny"),("X-Content-Type-Options","nosniff"),("X-XSS-Protection","0"),("Referrer-Policy","origin-when-cross-origin, strict-origin-when-cross-origin"),("Content-Security-Policy","default-src 'none'"),("Vary","Accept-Encoding, Accept, X-Requested-With"),("Content-Encoding","gzip"),("X-RateLimit-Limit","60"),("X-RateLimit-Remaining","50"),("X-RateLimit-Reset","1647082307"),("X-RateLimit-Resource","core"),("X-RateLimit-Used","10"),("Content-Length","91"),("X-GitHub-Request-Id","AE28:0263:E83A23:F6A95A:622C74ED")], responseBody = "{\"message\":\"Not Found\",\"documentation_url\":\"https://docs.github.com/rest\"}", responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose}) )

  FATAL: One or more packages failed to update:
  /github.com/nix-community/impermanence: ExitFailure 1
ERROR: ExitFailure 1