static-haskell-nix
static-haskell-nix copied to clipboard
stack2nix: user error (No such package libiserv-8.6.3 in the cabal database. Did you run cabal update?)
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
https://github.com/input-output-hk/haskell.nix/commit/14615173c2adf03fdaad8ee010c47732d609cd01 and https://github.com/input-output-hk/haskell.nix/issues/269 seem related
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
.
I think I have the solution:
We need the same as https://github.com/nh2/stack2nix/commit/6b29a9efc4f8d4326983321e2a7cec94e02a8623 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
.
It looks like some problem in old Stack adding libiserv into build plan, I couldn't find why that happens yet :-\
@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
.