Skip to content

Nix failes to compile with musl libc #469

Closed

Description

@jprjr

I tried compiling nix from source on Alpine Linux, which uses musl libc.

It looks like there's two problems in affinity.cc that's causing the compile to fail: the sched_getcpu function is glibc-specific, and there's an error about memsetnot being defined.

I added #include <string.h> into affinity.cc and that seemed to fix the memset problem (though I don't know if that's really the correct fix or not).

Activity

  1. gitfoxi commented on Jun 29, 2015

    @gitfoxi

    I am exactly where you were in February. Did you figure it out?

  2. gitfoxi commented on Jun 29, 2015

    @gitfoxi

    This got me over that hurdle:

    #undef HAVE_SCHED_SETAFFINITY
    

    I guess configure assumes that any linux has it. Should be a conf-test is the bug.

  3. gitfoxi commented on Jun 29, 2015

    @gitfoxi

    Also had to add -lcrypto to the link because of who knows? Anyway, I now have nix working under apline linux. (Well, now I have to bootstrap. That's going to be the real adventure.)

  4. dkubb commented on Aug 14, 2015

    @dkubb

    @gitfoxi do you have a script or Dockerfile that shows the process you went through to build nix on top of alpine linux?

  5. dkubb commented on Aug 17, 2015

    @dkubb

    @gitfoxi @jprjr I ended up working through it myself and made a Dockerfile that shows how I compile nix with musl libc: https://github.com/dkubb/dockerfiles/blob/master/alpine-nix/Dockerfile

    I'm curious to know if our processes differ at all, and if you have any suggestions on how I can improve things.

    For instance, I know we must differ in some way since I never needed to specify -lcrypto anywhere.

  6. edef1c commented on Feb 29, 2016

    @edef1c
    Member
  7. edef1c commented on Mar 3, 2016

    @edef1c
    Member

    Note that this actually being fixed is pending the next stable musl release, but that places the ball firmly in their court.

  8. added a commit that references this issue on May 27, 2026
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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions