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

callCabal2nix doesn't work with musl-native #43665

Closed
nh2 opened this issue Jul 17, 2018 · 1 comment · Fixed by #43666
Closed

callCabal2nix doesn't work with musl-native #43665

nh2 opened this issue Jul 17, 2018 · 1 comment · Fixed by #43666

Comments

@nh2
Copy link
Contributor

nh2 commented Jul 17, 2018

A follow-up for #43369.

@dtzWill @ElvishJerricco

I'm trying something like the following:

overlay.nix:

final:
  previous:
    with final.haskell.lib;
    {
      haskellPackages = previous.haskellPackages.override (old: {
        overrides = final.lib.composeExtensions (old.overrides or (_: _: {})) (self: super: {

          pretty-relative-time = self.callCabal2nix "pretty-relative-time" (final.fetchFromGitHub { ... }) {};

        });
      });
    }

(see #26561 (comment) for the interaction of nixpkgs overlays and haskellPackages.override)

used from https://github.com/nh2/static-haskell-nix/blob/627a8c5f86719531e1b1237aec4f5f85982cbd6c/survey/default.nix

by changing the first line to have nixpkgs ? (import <nixpkgs> { overlays = [ (import ./overlay.nix) ]; }).pkgsMusl.

Then I get:

% NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz nix-build --no-link survey/default.nix -A haskellPackages.pretty-relative-time
error: cannot coerce null to a string, at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:131:71

That error is in

LOCALE_ARCHIVE = pkgs.lib.optionalString buildPlatform.isLinux "${buildPackages.glibcLocales}/lib/locale/locale-archive";

Full trace:

% NIX_PATH=nixpkgs=https://github.com/NixOS/nixpkgs/archive/2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz nix-build --no-link survey/default.nix -A haskellPackages.pretty-relative-time --show-trace
error: while evaluating 'callCabal2nix' at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:173:32, called from /home/niklas/src/haskell/intray/overlay.nix:39:38:
while evaluating 'overrideCabal' at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/lib.nix:37:24, called from /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:183:8:
while evaluating 'callPackageKeepDeriver' at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:156:33, called from /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:183:23:
while evaluating 'overrideCabal' at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/lib.nix:37:24, called from /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:157:5:
while evaluating 'callPackage' at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:115:22, called from /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:157:20:
while evaluating 'callPackageWithScope' at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:75:37, called from /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:115:28:
while evaluating 'makeOverridable' at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/lib/customisation.nix:72:24, called from /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:98:8:
while evaluating 'drvScope' at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:88:18, called from /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/lib/customisation.nix:74:12:
while evaluating the attribute 'LOCALE_ARCHIVE' of the derivation 'cabal2nix-pretty-relative-time' at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/stdenv/generic/make-derivation.nix:175:11:
while evaluating 'optionalString' at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/lib/strings.nix:138:26, called from /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:131:24:
cannot coerce null to a string, at /nix/store/w1fndb8swaamrf7amgjjvxfp12nifl2d-2c07921cff84dfb0b9e0f6c2d10ee2bfee6a85ac.tar.gz/pkgs/development/haskell-modules/make-package-set.nix:131:71

From IRC:

elvishjerricco> nh2: Yea the problem is that callCabal2nix relies on the glibcLocales thing. Not sure if it should... But if the pkgsMusl stuff doesn't provide that derivation, that would break callCabal2nix

@dtzWill Do you know what we could do about this glibcLocales?

@nh2
Copy link
Contributor Author

nh2 commented Jul 17, 2018

From IRC:

dtz> nh2: I think I just never got that far previously--other nixpkgs references to using glibcLocales w/haskell on musl are conditional but this isn't
dtz> nh2: yeah so in generic-builder we do this:

LOCALE_ARCHIVE = optionalString (stdenv.hostPlatform.libc == "glibc") "${glibcLocales}/lib/locale/locale-archive";

nh2> comments must have been a bit out of fashion when LOCALE_ARCHIVE was added to haskellSrc2nix to fix ... something?
dtz> nh2: well it probably helps w/glibc! But IIRC musl has some other locale thing that I'm not even sure took off? MUSL_LOCPATH
nh2> dtz: I found the commit that added it: 69cda1a
nh2> it apparently fixed #5904

So I suspect that this is very related to some other thing I'm working on in GHC & co: That many Haskell build tools break when you don't force the encoding: commercialhaskell/stack#3988

{^_^}> [nixpkgs] @dtzWill opened pull request #43666 → haskell-modules: only include glibc locales when using glibc
dtz> nh2: well musl is utf8 by default :3 lol

nh2 pushed a commit to nh2/nixpkgs that referenced this issue Jul 19, 2018
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

Successfully merging a pull request may close this issue.

1 participant