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

stack2nix: user error (No such package libiserv-8.6.3 in the cabal database. Did you run cabal update?) #85

Open
hasufell opened this issue Mar 9, 2020 · 4 comments

Comments

@hasufell
Copy link

hasufell commented Mar 9, 2020

default.nix:

# Run using:
#
#     $(nix-build --no-link -A fullBuildScript)
{
  stack2nix-output-path ? "custom-stack2nix-output.nix",
}:
let
  cabalPackageName = "example-project";
  compiler = "ghc865"; # matching stack.yaml

  # Pin static-haskell-nix version.
  static-haskell-nix =
    if builtins.pathExists ../.in-static-haskell-nix
      then toString ../. # for the case that we're in static-haskell-nix itself, so that CI always builds the latest version.
      # Update this hash to use a different `static-haskell-nix` version:
      else fetchTarball https://github.com/nh2/static-haskell-nix/archive/6b9004a44efdf13ad35f29317a12d58cf9cd3e3e.tar.gz;

  # Pin nixpkgs version
  # By default to the one `static-haskell-nix` provides, but you may also give
  # your own as long as it has the necessary patches, using e.g.
  #     pkgs = import (fetchTarball https://github.com/nh2/nixpkgs/archive/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa123.tar.gz) {};
  pkgs = import "${static-haskell-nix}/nixpkgs.nix";

  stack2nix-script = import "${static-haskell-nix}/static-stack2nix-builder/stack2nix-script.nix" {
    inherit pkgs;
    stack-project-dir = toString ./.; # where stack.yaml is
    hackageSnapshot = "2020-03-09T18:53:34Z"; # pins e.g. extra-deps without hashes or revisions
  };

  static-stack2nix-builder = import "${static-haskell-nix}/static-stack2nix-builder/default.nix" {
    normalPkgs = pkgs;
    inherit cabalPackageName compiler stack2nix-output-path;
    # disableOptimization = true; # for compile speed
  };

  # Full invocation, including pinning `nix` version itself.
  fullBuildScript = pkgs.writeShellScript "stack2nix-and-build-script.sh" ''
    set -eu -o pipefail
    STACK2NIX_OUTPUT_PATH=$(${stack2nix-script})
    export NIX_PATH=nixpkgs=${pkgs.path}
    ${pkgs.nix}/bin/nix-build --no-link -A static_package --argstr stack2nix-output-path "$STACK2NIX_OUTPUT_PATH" "$@"
  '';

in
  {
    static_package = static-stack2nix-builder.static_package;
    inherit fullBuildScript;
    # For debugging:
    inherit stack2nix-script;
    inherit static-stack2nix-builder;
  }

stack.yaml:

resolver: lts-14.27
packages:
    - .
extra-deps:
    - IfElse-0.85@sha256:6939b94acc6a55f545f63a168a349dd2fbe4b9a7cca73bf60282db5cc6aa47d2
    - ascii-string-1.0.1.3
    - brotli-0.0.0.0@sha256:448061ceabdcaa752bbaf208f255bbb7e90bbcf8ea8a913d26ffa7887636823b
    - brotli-streams-0.0.0.0@sha256:c75a1d5d33420cbc9399c315e9b50a1976a5370f4fa8a40c71e11d011c2fedd6
    - case-insensitive-1.2.1.0
    - data-default-instances-base-0.1.0.1@sha256:985a13d7103e45a65f06f277b735ef025636014f0d29dd6de998bc7628e09be9
    - fusion-plugin-types-0.1.0@sha256:0f11bbc445ab8ae3dbbb3d5d2ea198bdb1ac020518b7f4f7579035dc89182438
    - generics-sop-0.5.0.0
    - haskus-utils-data-1.2@sha256:48f62aa23d84b94edd0338379d3b3d74a34d3c2dbabf8c448a774a89ca70ea5d
    - haskus-utils-types-1.5
    - haskus-utils-variant-3.0
    - hpath-0.11.0
    - hpath-directory-0.13.2
    - hpath-filepath-0.10.4
    - hpath-io-0.13.1
    - hpath-posix-0.13.1
    - http-io-streams-0.1.2.0
    - indexed-profunctors-0.1@sha256:ddf618d0d4c58319c1e735e746bc69a1021f13b6f475dc9614b80af03432e6d4
    - language-bash-0.9.0
    - optics-0.2
    - optics-core-0.2@sha256:cfdf39871553769b59fcc54863a3521d262ea25d8d05d0f41ab87296c560cfa6
    - optics-extra-0.2@sha256:211ce1dfd1b3ffd95c1158d8c8beb53cbd17c4d477169e226b1831607f6789eb
    - optics-th-0.2@sha256:b4f6c5a3f134c697837190ed6da969dd284aefe79e43c3ef793093b607bb83b9
    - optics-vl-0.2
    - optparse-applicative-0.15.1.0
    - pretty-terminal-0.1.0.0
    - sop-core-0.5.0.0@sha256:8734ab38b8c84837094eec657da0b58942e481e20166131f34cf6c7fe9787b07
    - streamly-0.7.1
    - streamly-bytestring-0.1.2
    - streamly-posix-0.1.0.0
    - strict-base-0.4.0.0
    - string-interpolate-0.2.0.0
    - table-layout-0.8.0.5
    - tar-bytestring-0.6.3.0
    - time-1.9.3

input-output-hk/haskell.nix@1461517 and input-output-hk/haskell.nix#269 seem related

@nh2
Copy link
Owner

nh2 commented Mar 20, 2020

That is odd. That error usually appears when stuff is not in this list:

https://github.com/nh2/stack2nix/blob/c009e33af30c76b8fe94388382d816079fb5ac4e/pkg_versions.txt#L92

But libiserv/8.6.3 is in there.

A minimal repro is:

index c113006..473da42 100644
--- a/static-stack2nix-builder-example/stack.yaml
+++ b/static-stack2nix-builder-example/stack.yaml
@@ -1,3 +1,5 @@
 resolver: lts-14.7
 packages:
 - .
+extra-deps:
+  - time-1.9.3

Edit: When trying this with plain stack, we also need to use the dependency to make stack put it into the build plan, e.g.:

--- a/static-stack2nix-builder-example/package.yaml
+++ b/static-stack2nix-builder-example/package.yaml
@@ -6,6 +6,7 @@ maintainer:          "[email protected]"
 
 dependencies:
 - base >= 4.7 && < 5
+- time
 
 library:
   source-dirs: src

Then after stack build will the newer time version show up in stack exec -- ghc-pkg list time.

@nh2
Copy link
Owner

nh2 commented Mar 20, 2020

I think I have the solution:

We need the same as nh2/stack2nix@6b29a9e but for libiserv.

That makes it run through for me locally.

I haven't figured out yet though why it happens only when you put that time into extra-deps.

@qrilka
Copy link

qrilka commented Mar 21, 2020

It looks like some problem in old Stack adding libiserv into build plan, I couldn't find why that happens yet :-\

@qrilka
Copy link

qrilka commented Mar 22, 2020

@nh2 I have found the reason this happens. It's another occurrence of the same problem Michael wrote about in https://www.snoyman.com/blog/2019/01/mismatched-global-packages . Overriding time triggers rebuild for any dependent packages and in this case libserv is one of such libraries, see https://github.com/commercialhaskell/core-cabal-files/blob/master/libiserv-8.6.3.cabal . The dependency is not direct - libserv depends on unix which depends on time.

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

No branches or pull requests

3 participants