nh2 / static-haskell-nix

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

nix tests fail with musl #52

Closed purefn closed 3 years ago

purefn commented 5 years ago

When trying to build pkgsMusl.nix the tests fail, complaining about a missing unshare executable. This is mainly of significance because I'm trying to use callCabal2Nix from the Haskell library.

dtzWill commented 5 years ago

I'm not sure what causes this, but can be fixed by adding utillinux to nix's nativeBuildInputs (or perhaps checkInputs); I'm not sure how non-musl (glibc) builds manage to find unshare without such a dependency, but I think it'd be an improvement for upstream to explicitly specify it anyway (and fix this for you as well).

If that seems reasonable we should fix this in nixpkgs proper and probably nix itself as well.

I've had this in my tree for some time, but since I didn't have a good explanation why glibc doesn't need this I never ended up sending upstream... commit:

https://github.com/dtzWill/nixpkgs/commit/08ceaa5fe914193af1d6f78adf7d92a2d755e488

Please cc me on any PR's opened towards fixing this.

I'm willing to be convinced to do the PR's but might not be able to get to it as quickly as someone else O:).

When trying to build pkgsMusl.nix the tests fail, complaining about a missing unshare executable. This is mainly of significance because I'm trying to use callCabal2Nix from the Haskell library.

-- You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/nh2/static-haskell-nix/issues/52Non-text part: text/html

purefn commented 5 years ago

That solution works for sure, but I'm not sure how it would affect builds on Darwin. Would those fail because they couldn't pull in that dependency? Maybe the best solution would be to raise the issue upstream and see what they say, but I figured I'd start here first and see what @nh2 thinks before doing that.

nh2 commented 4 years ago

nix's unshare use is here: https://github.com/NixOS/nix/blob/95cf23ee7c5b0fd69b21811989a5668f4261fd51/tests/common.sh.in#L89-L91

It calls it only on Linux, so I think the utillinux dependency should be added only on Linux, using e.g.

lib.optionals stdenv.isLinux [ utillinuxMinimal ]

I think @dtzWill is absolutely right and nix should declare the utillinux dependency.

@purefn two things that would be great if you could do:

nh2 commented 3 years ago

This was fixed in nixpkgs with commit https://github.com/NixOS/nixpkgs/commit/fc3227e6983cecfb215a97f36c683ebf2d9527db