nh2 / static-haskell-nix

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

Can't build stack project #39

Closed jpathy closed 5 years ago

jpathy commented 5 years ago

On lts-13.28 stack2nix: user error (No such package ALUT-2.4.0.3 in the cabal database. Did you run cabal update?)

nh2 commented 5 years ago

Did you see #36 and #37? Do they help?

jpathy commented 5 years ago

Thanks using a snapshot of this month worked. Now my binary uses direct-sqlite with systemlib, i get linker failure:

/nix/store/ljx5sayk6w0bpd1ahcf0rm5fj55cqafd-binutils-2.31.1/bin/ld: cannot find -lsqlite3
collect2: error: ld returned 1 exit status
`cc' failed in phase `Linker'. (Exit code: 1)
nh2 commented 5 years ago

@jpathy Is it an open-source project, so I could try building it?

If not, is it possible for you to strip it down to just some hello-world program with the sqlite dependency?

Also just to confirm, you were xdxd on IRC, right?

nh2 commented 5 years ago

I tried to test this by adding a direct-sqlite dependency to static-stack2nix-builder-example, but didn't get far enough because with this patch:

diff -ru static-stack2nix-builder-example/default.nix static-stack2nix-builder-example-sqlite/default.nix
--- static-stack2nix-builder-example/default.nix    2019-06-12 18:55:17.738253636 +0200
+++ static-stack2nix-builder-example-sqlite/default.nix 2019-07-21 03:59:42.133934161 +0200
@@ -17,7 +17,7 @@
   stack2nix-script = import "${static-haskell-nix}/static-stack2nix-builder/stack2nix-script.nix" {
     inherit pkgs;
     stack-project-dir = toString ./.; # where stack.yaml is
-    hackageSnapshot = "2019-05-08T00:00:00Z"; # pins e.g. extra-deps without hashes or revisions
+    hackageSnapshot = "2019-07-21T00:00:00Z"; # pins e.g. extra-deps without hashes or revisions
   };

   static-stack2nix-builder = import "${static-haskell-nix}/static-stack2nix-builder/default.nix" {
diff -ru static-stack2nix-builder-example/example-project.cabal static-stack2nix-builder-example-sqlite/example-project.cabal
--- static-stack2nix-builder-example/example-project.cabal  2019-05-24 01:01:22.576306658 +0200
+++ static-stack2nix-builder-example-sqlite/example-project.cabal   2019-07-21 03:57:26.499945454 +0200
@@ -4,7 +4,7 @@
 --
 -- see: https://github.com/sol/hpack
 --
--- hash: f29499e26d59c63f4043d8f0d8ba9bf25eb9fb9877cde46564e5e1579fe55b11
+-- hash: 7183d88b8421062f436818b1310200068f08e2ca5b811690a7668a79bdf72bbc

 name:           example-project
 version:        0.1.0.0
@@ -33,5 +33,6 @@
   ghc-options: -threaded -rtsopts -with-rtsopts=-N
   build-depends:
       base >=4.7 && <5
+    , direct-sqlite
     , example-project
   default-language: Haskell2010
diff -ru static-stack2nix-builder-example/package.yaml static-stack2nix-builder-example-sqlite/package.yaml
--- static-stack2nix-builder-example/package.yaml   2019-05-24 01:01:22.576306658 +0200
+++ static-stack2nix-builder-example-sqlite/package.yaml    2019-07-21 03:57:09.252200133 +0200
@@ -20,3 +20,4 @@
     - -with-rtsopts=-N
     dependencies:
     - example-project
+    - direct-sqlite
Only in static-stack2nix-builder-example-sqlite/.stack-work: dist
Only in static-stack2nix-builder-example-sqlite/.stack-work/install/x86_64-linux: 7d6d968be153d4dcc0edab19f77cd81934e5dbcbcb69dad0082c318db701ea3b
Only in static-stack2nix-builder-example-sqlite/.stack-work/install/x86_64-linux: lts-13.28
diff -ru static-stack2nix-builder-example/stack.yaml static-stack2nix-builder-example-sqlite/stack.yaml
--- static-stack2nix-builder-example/stack.yaml 2019-05-24 01:01:22.576306658 +0200
+++ static-stack2nix-builder-example-sqlite/stack.yaml  2019-07-21 03:57:18.896057766 +0200
@@ -1,3 +1,3 @@
-resolver: lts-13.15
+resolver: lts-13.28
 packages:
 - .
Only in static-stack2nix-builder-example-sqlite: stack.yaml.lock

I get the well-known and dreaded failure:

Determined cabalPackageId as Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8
setupCompileFlags: -package-id Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8
<command line>: cannot satisfy -package-id Cabal-2.4.1.0-9MZFDeNrcJI10bcroa6pq8
    (use -v for more information)

Looks like one more case where my overriding to use patched Cabal isn't perfect yet (brought to light because direct-sqlite somehow recursively depends on Cabal).

jpathy commented 5 years ago

Attached is an example project. I didn't get the cabal problem, it did compile the patched cabal for me.

test.zip

Yes, i don't directly depend on direct-sqlite, but i pass systemlib flag, so it doesn't link to the amalgamated sqlite on their repo.

nh2 commented 5 years ago

I've found the solution.

https://github.com/nh2/static-haskell-nix/blob/71d3aaa533687c2b11091f04b8a2abddfe8b99af/static-stack2nix-builder/default.nix#L35

Uses just .pkgs, not the pkgsWithArchiveFiles that have the sqlite that's overriden to have .a files.

I'll push a fix soon.

nh2 commented 5 years ago

PR in #41

nh2 commented 5 years ago

@jpathy PR merged. Please try with the latest static-haskell-nix, and reopen if it still doesn't work (it does work for me now).

jpathy commented 5 years ago

It works now. Thanks for figuring it out.

nh2 commented 5 years ago

Great! Sorry it took so long; was a bit unfortunate with some holidays in between.