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

Using enacl as a dependency in a Nix derivation of an Elixir project #75

Open
cognivore opened this issue Sep 2, 2024 · 0 comments
Open

Comments

@cognivore
Copy link

To whom it may concern,

Elixir test task we build for my startup use enacl for cryptography, however when we started moving to nix-docker, which is the best Docker image compilation backend (better than docker!), we needed to nixify all the dependencies too.

While hex dependencies worked with no problem, enacl couldn't build. That's why after a lot of digging and thinking, @ixahedron has produced the following pearl:

      packages.default = beamPackages.mixRelease rec {
        pname = "on_the_map-goo";
        version = "0.1.0";

        src = ./.;

        buildInputs = allBuildInputs;

        mixNixDeps = (import ./deps.nix) {
          inherit beamPackages;
          lib = pkgs.lib;

          # enacl is a pain in the ass. Heed my warnings.
          overrides = (final: prev: {
            # deps_nix and autofetchers treat it as a mix dependency even
            # though it's specified for rebar3.
            enacl = beamPackages.buildRebar3 {
              version = "46e2754a50f4d9192ebf008bf80ea8242e7f7986";
              name = "enacl";

              # Maybe that's why fetching it from hex, where it DOES EXIST,
              # fail for some reason.
              src = builtins.fetchGit {
                url = "https://github.com/jlouis/enacl.git";
                rev = "46e2754a50f4d9192ebf008bf80ea8242e7f7986";
                allRefs = true;
              };

              # Then, it fails to compile, as rebar3's pc plugin is unavailable.
              compilePorts = true;
              buildPlugins = [ beamPackages.pc ];

              # Also, it won't pick up mixRelease's buildInputs, so we need
              # to pass libsodium explicitly.
              buildInputs = [ pkgs.libsodium ];
            };
          });
        };

      };

Sorry to abuse Github issues (and, of course, feel free to close), but this needs to be indexed by search engines!

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

No branches or pull requests

1 participant