Skip to content

Conversation

@tjarratt
Copy link
Contributor

@tjarratt tjarratt commented Nov 12, 2025

Based on the work started in #22, I identified what was causing the build for fail for vix. Copying my comment from that PR below

Having a look at this, I think I see what happened. When we apply the elixir_make workaround for lazy_html, that applies to vix (because it depends upon elixir_make), and since our override sets the nativeBuildInputs for the derivation, the ones we had previously set for vix end up getting overriden.

I think I see a few ways to handle this, I'll take a pass at it.

I had thought to use overrrideAttrs so that we could append onto the nativeBuildInputs, but I tested whether we could build lazy_html and vix without setting pkgs.gnumake in the nativeBuildInputs and was pleasantly surprised to see this wasn't necessary for it to build. This might have side effects I can't see, or be undesirable for a number of reasons, let me know if there's any way of improving this and I can have a shot.

Closes #22 #30

Shout out to @copyps for the inspiration and to @camelpunch for
giving me some tips for how to get my footing in deps_nix
Too easy to accidentally produce these when testing locally

eg: nix build .#lazy_html
@camelpunch
Copy link
Contributor

Thanks! Can you take a look at the Linux build please?

@tjarratt
Copy link
Contributor Author

For sure !

I was waiting around last night for the build to go through, but it took too long and I went to bed first. Will have a look at the linux build and get this in a good shape :-D

@camelpunch
Copy link
Contributor

It is a silly slow build indeed.

@tjarratt
Copy link
Contributor Author

Made some progress with the initial issue (it was missing ca certs) but now I'm running into issues with how elixir_make is setup in lazy_html. My next step is to compare how the precompilation is setup in vix and lazy_html to figure out what it would take to compile lazy_html on linux.

And then once that's done, I intend to try tearing out bits and pieces of the elixirMake workaround to ensure all the additions are necessary.

@ju1m
Copy link

ju1m commented Nov 15, 2025

Hi, if that may help you, for lazy_html on Linux I'm using:

{ lexbor, ... }:
finalMixPkgs: previousMixPkgs: {
  lazy_html = previousMixPkgs.lazy_html.overrideAttrs (previousAttrs: {
    # Explanation: somehow `mix compile --no-deps-check`
    # replaces Fine.include_dir() by "/build/fine-0.1.4/c_include"
    # a path which is not available when building lazy_html there.
    #
    # Explanation: lazy_html being built in a sandbox
    # it cannot download its precompiled binary,
    # it then attempt to compile from source by first git cloning lexbor,
    # but lexbor is already packaged in nixpkgs,
    # and to let the Makefile reuse it, it's enough to empty @lexbor_git_sha.
    postPatch = ''
      substituteInPlace mix.exs \
        --replace-fail "Fine.include_dir()" '"${finalMixPkgs.fine}/src/c_include"' \
        --replace-fail '@lexbor_git_sha "244b84956a6dc7eec293781d051354f351274c46"' '@lexbor_git_sha ""'
    '';

    # Explanation: workaround:
    # (File.Error) could not make directory (with -p) "/homeless-shelter/.cache/elixir_make":
    # no such file or directory
    preConfigure = previousAttrs.preConfigure or "" + ''
      export ELIXIR_MAKE_CACHE_DIR="$TMPDIR/.cache"
    '';

    # Explanation: nix provides lexbor.
    preBuild = previousAttrs.preBuild or "" + ''
      export LEXBOR_GIT_SHA=
      install -Dm644 \
        -t _build/c/third_party/lexbor/$LEXBOR_GIT_SHA/build \
        ${lexbor}/lib/liblexbor_static.a
    '';
    buildInputs = previousAttrs.buildInputs or [ ] ++ [
      lexbor
    ];
  });
}

@tjarratt
Copy link
Contributor Author

@ju1m you're a livesaver, thanks for sharing that ! I'll give it a shot and see if it gets the build green here.

(or at least it does for sure on x86_64)
@tjarratt
Copy link
Contributor Author

Builds are green ✅ 🎉

Big shout outs to @codyps for giving me a good starting point to contribute, and to @ju1m for giving me the nudge that got this over the line. I knew there was SOMETHING about how the 'mix.exs' file in lazy_html configured elixir_make that made it prefer downloading over building it directly, as vix does, but I couldn't quite figure it out.

And of course, a thank you to @camelpunch for support and guidance throughout. Lemme know if you have any feedback on how this landed, I wouldn't mind making a few more changes if you see any way this could be improved.

@camelpunch camelpunch merged commit 1960429 into code-supply:main Nov 16, 2025
2 checks passed
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 this pull request may close these issues.

3 participants