nh2 / static-haskell-nix

easily build most Haskell programs into fully static Linux executables
388 stars 36 forks source link

stack2nix fails with 404 with lts-15.13 #95

Closed matsumonkie closed 3 years ago

matsumonkie commented 4 years ago

Hello! First things first, thanks a lot for this work, it might help me a lot.

I'm trying to build a static binary from a stack project based. My project is using stack lts-15.13 with gh883. When I try to build the adapted default.nix, stack2nix fails with a 404:

 % $(nix-build --no-link -A fullBuildScript)
+ /nix/store/4jl99687r2r5xdxis5g93v7cy5rmzrjb-stack2nix-0.2.3/bin/stack2nix /home/iori/Work/patchGirl2/back --stack-yaml stack.yaml --hackage-snapshot 2019-10-08T00:00:00Z -o /tmp/stack2nix-output-dir.q5rywLgu3b/stack2nix-output.nix

Ensuring git version is >= 2 ...
Ensuring cabal version is >= 2 ...
stack2nix: RedownloadInvalidResponse Request {
  host                 = "raw.githubusercontent.com"
  port                 = 443
  secure               = True
  requestHeaders       = []
  path                 = "/fpco/lts-haskell/master//lts-15.13.yaml"
  queryString          = ""
  method               = "GET"
  proxy                = Nothing
  rawBody              = False
  redirectCount        = 10
  responseTimeout      = ResponseTimeoutDefault
  requestVersion       = HTTP/1.1
}
 "/home/iori/.stack/build-plan/lts-15.13.yaml" (Response {responseStatus = Status {statusCode = 404, statusMessage = "Not Found"}, responseVersion = HTTP/1.1, responseHeaders = [("Connection","keep-alive"),("Content-Length","14"),("Content-Security-Policy","default-src 'none'; style-src 'unsafe-inline'; sandbox"),("Strict-Transport-Security","max-age=31536000"),("X-Content-Type-Options","nosniff"),("X-Frame-Options","deny"),("X-XSS-Protection","1; mode=block"),("Content-Type","text/plain; charset=utf-8"),("Via","1.1 varnish (Varnish/6.0)"),("X-GitHub-Request-Id","9E3C:51E6:45222:54D20:5EE1FA35"),("Accept-Ranges","bytes"),("Date","Thu, 11 Jun 2020 09:32:37 GMT"),("Via","1.1 varnish"),("X-Served-By","cache-cdg20740-CDG"),("X-Cache","MISS, MISS"),("X-Cache-Hits","0, 0"),("X-Timer","S1591867957.157747,VS0,VE444"),("Vary","Authorization,Accept-Encoding"),("Access-Control-Allow-Origin","*"),("X-Fastly-Request-ID","1f20cd3df7a973cb09e66cd12d6ffbe7f5b31e62"),("Expires","Thu, 11 Jun 2020 09:37:37 GMT"),("Source-Age","0")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose})

It seems the issue comes from path = "/fpco/lts-haskell/master//lts-15.13.yaml" and the double slash. So my question is, is lts-15.13 supported ?

matsumonkie commented 4 years ago

The failing build can be found here if it helps to reproduce

matsumonkie commented 4 years ago

I believe the issue comes from https://github.com/nh2/static-haskell-nix/blob/master/static-stack2nix-builder/stack2nix-script.nix#L88 I'm a beginner at nix though, so not quite sure :-S

matsumonkie commented 4 years ago

So I've been investigating a little bit more and it turns out that the issue comes from stack2nix :-( I'll close this issue!

nh2 commented 4 years ago

You don't need to close the issue because it's with stack2nix, because I essentially maintain that too.

What you see seems to be this: https://stackoverflow.com/questions/57516944/stack-new-command-failing-to-download-build-plan-for-lts-14-1

But it doesn't tell what the actual problem is. Newer stack seems to fix it, but it may not be easy to upgrade stack2nix to use a newer Stack immediately.

So it would be good to know if indeed we could fix it in stack2nix by removing double slashes, if that is the problem.

nh2 commented 4 years ago

I think I found it:

https://github.com/commercialhaskell/lts-haskell/issues/247#issuecomment-608669620

leading via https://github.com/commercialhaskell/stack/issues/5204#issuecomment-591354784 to https://www.stackage.org/blog/2020/02/discontinuing-legacy-snapshots:

you will not be able to use Stack 1.9 or earlier with newer nightly or LTS 15 snapshots

This means we need to upgrade stack2nix to work with Stack 2 (currently it depends on Stack 1.9).

Or alternatively switch from stack2nix to haskell.nix, if it works well enough.

Both are no trivial tasks though.

matsumonkie commented 4 years ago

Yeah, it seems indeed quite hard :-( I've kind of given up trying to make it work with stack2nix and am actually trying to use the same technique postgres. Not completely sure how great it is since my nix knowledge is still quite low though ? (would love your opinion whether postgres' solution is right or not!)

Good luck in trying to fix stack2nix for newer version!

nh2 commented 3 years ago

This was fixed with PR #98, with commit 66fce684a20451514cb68d71bcb62fb246cb2080, which updates stack2nix to a version with Stack2 support.