Skip to content

callCabal2nix doesn't work with musl-native #43665

Closed

Description

@nh2

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?

Activity

  1. added a commit that references this issue on Jul 17, 2018
    da53830
  2. nh2 commented on Jul 17, 2018

    @nh2
    ContributorAuthor

    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

  3. added a commit that references this issue on Jul 19, 2018
    11f3eca
  4. added
    6.topic: musl
    on Oct 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    6.topic: musl

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions