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

Custom stack resolver in stack.yaml fails #1157

Open
codygman opened this issue Jul 2, 2021 · 8 comments
Open

Custom stack resolver in stack.yaml fails #1157

codygman opened this issue Jul 2, 2021 · 8 comments
Labels
help wanted Extra attention is needed stack

Comments

@codygman
Copy link

codygman commented Jul 2, 2021

I can work around this by inlining the contents of that resolver in changing packages to extra-deps So I know I have everything else working. Sadly my team needs that for other stuff and doesn't see the work around of removing the resolver and using a plain stack.yaml as an option.

# stack.yaml
resolver: https://raw.githubusercontent.com/EdutainmentLIVE/snapshot/f5f60d88a128aff3da0e5fd508a3e2aacd2ca109/snapshot.yaml

Results in:

host name: Just "raw.githubusercontent.com", service name: Just "443"): does not exist (Name or service not known))

Full log:


smurf  July-haskell-nix 「↪ 𝚫 ✔ 📁 」 on  (us-east-1) took 25s 
✖1 ❯ nix build
warning: Git tree '/home/cody/smurf' is dirty
trace: To make project.stack-nix for haskell-project a fixed-output derivation but not materialized, set `stack-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.stack-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: WARNING: `cleanSourceWith` called on /nix/store/qy510ayhgci7wksf6qzkbac6cszcg8mp-source without a `name`. Consider adding `name = "qy510ayhgci7wksf6qzkbac6cszcg8mp-source";`
error: builder for '/nix/store/pd7zjfwh977mkyd3zrjwqmdk1cnq9i9v-stack-repos.drv' failed with exit code 1;
       last 10 log lines:
       >   queryString          = ""
       >   method               = "GET"
       >   proxy                = Nothing
       >   rawBody              = False
       >   redirectCount        = 10
       >   responseTimeout      = ResponseTimeoutDefault
       >   requestVersion       = HTTP/1.1
       >   proxySecureMode      = ProxySecureWithConnect
       > }
       >  (ConnectionFailure Network.Socket.getAddrInfo (called with preferred socket type/protocol: AddrInfo {addrFlags = [AI_ADDRCONFIG], addrFamily = AF_UNSPEC, addrSocketType = Stream, addrProtocol = 0, addrAddress = 0.0.0.0:0, addrCanonName = Nothing}, host name: Just "raw.githubusercontent.com", service name: Just "443"): does not exist (Name or service not known))
       For full logs, run 'nix log /nix/store/pd7zjfwh977mkyd3zrjwqmdk1cnq9i9v-stack-repos.drv'.
(use '--show-trace' to show detailed location information)

@codygman
Copy link
Author

codygman commented Jul 2, 2021

I found out in libera.chat#haskell.nix that this is not a bug but something that nix intentionally doesn't allow.

@codygman codygman closed this as completed Jul 2, 2021
@codygman
Copy link
Author

codygman commented Jul 2, 2021

It appears there is an option thanks to @balsoft I came up with this but still have an issue:

{
  description = "A very basic flake";
  inputs.haskellNix.url = "github:input-output-hk/haskell.nix";
  inputs.nixpkgs.follows = "haskellNix/nixpkgs-unstable";
  inputs.flake-utils.url = "github:numtide/flake-utils";
  outputs = { self, nixpkgs, flake-utils, haskellNix }:
    flake-utils.lib.eachSystem [ "x86_64-linux" "x86_64-darwin" ] (system:
    let
      overlays = [ haskellNix.overlay
        (final: prev: {
          # This overlay adds our project to pkgs
          myproj =
            final.haskell-nix.project' {
              src = ./.;
              resolverSha256 = "0zhmk6qasy3zfr616n7a1kj34m16dcv47gjfvb2424wk7d9w1xr1";
              compiler-nix-name = "ghc8104";
              # This is used by `nix develop .` to open a shell for use with
              # `cabal`, `hlint` and `haskell-language-server`
              shell.tools = {
                cabal = {};
                hlint = {};
                haskell-language-server = {};
              };
              branchMap = {
                "https://github.com/brendanhay/amazonka"."020bc7bde47bb235e448c76088dc44d6cec13e9b" = "develop";
              };
              # This adds `js-unknown-ghcjs-cabal` to the shell.
              # shell.crossPlatform = p: [p.ghcjs];
            };
        })
      ];
      pkgs = import nixpkgs { inherit system overlays; };
      flake = pkgs.myproj.flake {
        # This adds support for `nix build .#js-unknown-ghcjs-cabal:myproj:exe:myproj`
        # crossPlatforms = p: [p.ghcjs];
      };
    in flake // {
      # Built by `nix build .`
      defaultPackage = flake.packages."myproj:exe:myproj";
    });
}

Output:

✖1 ❯ nix build
warning: Git tree '/home/cody/myproj' is dirty
trace: To make project.stack-nix for haskell-project a fixed-output derivation but not materialized, set `stack-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.stack-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
trace: WARNING: `cleanSourceWith` called on /nix/store/sk8d3r8brx6frzrqd7rxfnk38rmq29vh-source without a `name`. Consider adding `name = "sk8d3r8brx6frzrqd7rxfnk38rmq29vh-source";`
error: builder for '/nix/store/c8yhryj23nnfq7azzk4py3iknw7w09vj-stack-repos.drv' failed with exit code 1;
       last 4 log lines:
       > substituteStream(): WARNING: pattern '# nix-sha256:' doesn't match anything in file 'stack.yaml'
       > stack-repos: AesonException "Error in $: key \"name\" not found"
       > CallStack (from HasCallStack):
       >   error, called at lib/Stack2nix/External/Resolve.hs:45:25 in nix-tools-0.1.0.0-HSKLHXvL6X11Z9A8iBqCaD:Stack2nix.External.Resolve
       For full logs, run 'nix log /nix/store/c8yhryj23nnfq7azzk4py3iknw7w09vj-stack-repos.drv'.
(use '--show-trace' to show detailed location information)

myproj  July-haskell-nix 「↪ 𝚫 📁 」 on  (us-east-1) took 2s 
✖1 ❯ 

@codygman codygman reopened this Jul 2, 2021
@codygman
Copy link
Author

codygman commented Jul 2, 2021

It seems this is working, but two things made it tricky:

  • You get a very unhelpful error if your resolver file does not have a name: field
  • I forgot to update the resolver hash after adding a name to my github branch and it silently used the old version

After addressing both of those though things work!

@locallycompact
Copy link
Contributor

locallycompact commented Aug 6, 2021

When I try your exact example I get:

trace: To make project.stack-nix for haskell-project a fixed-output derivation but not materialized, set `stack-sha256` to the output of the 'calculateMaterializedSha' script in 'passthru'.
trace: To materialize project.stack-nix for haskell-project entirely, pass a writable path as the `materialized` argument and run the 'updateMaterialized' script in 'passthru'.
error: fetchurl requires either `url` or `urls` to be set
(use '--show-trace' to show detailed location information)

@locallycompact
Copy link
Contributor

Here's a reproduction using your flake.nix expression and a stack manifest with your resolver in resulting in error: fetchurl requires either urlorurls to be set

https://github.com/locallycompact/custom-stack-resolver-bug

@locallycompact
Copy link
Contributor

Ok, the name: field needs to be in the resolver, for some reason I'd convinced myself it was going in the stack.yaml. Ignore me.

@locallycompact
Copy link
Contributor

Ok, related though is this behaviour, setting:

resolver:
  url: https://gitlab.homotopic.tech/packaging/stackage-snapshots/-/raw/master/nightly/2021/8/5.yaml
  size: 605
  sha256: 4b996341941b8e0c41aecfa0d1852c22e8747e7deeee87a9f862c7257b8c47df

is a valid stack configuration, but this will fail in stack2nix with the fetchurl error above.

@stale
Copy link

stale bot commented Sep 28, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Sep 28, 2022
@stale stale bot removed the wontfix label Oct 10, 2022
@hamishmack hamishmack added the help wanted Extra attention is needed label Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed stack
Projects
None yet
Development

No branches or pull requests

3 participants