Unverified Commit 50c57d11 authored by Adam C. Stephens's avatar Adam C. Stephens Committed by GitHub
Browse files

beamPackages.mixRelease: support escript properly (#404412)

parents 411c68ae c7ab7b94
Loading
Loading
Loading
Loading
+1 −14
Original line number Diff line number Diff line
@@ -25,20 +25,7 @@ mixRelease rec {
    hash = "sha256-T1uL3xXXmCkobJJhS3p6xMrJUyiim3AMwaG87/Ix7A8=";
  };

  buildInputs = [ erlang ];

  postBuild = ''
    mix do escript.build
  '';

  installPhase = ''
    runHook preInstall

    mkdir -p $out/bin
    cp protoc-gen-elixir $out/bin

    runHook postInstall
  '';
  escriptBinName = "protoc-gen-elixir";

  passthru.updateScript = nix-update-script { };

+2 −19
Original line number Diff line number Diff line
@@ -30,6 +30,8 @@ mixRelease {
    elixir
    ;

  escriptBinName = "ex_doc";

  stripDebug = true;

  mixFodDeps = fetchMixDeps {
@@ -38,25 +40,6 @@ mixRelease {
    hash = "sha256-s4b6wuBJPdN0FPn76zbLCHzqJNEZ6E4nOyB1whUM2VY=";
  };

  configurePhase = ''
    runHook preConfigure
    mix deps.compile --no-deps-check
    runHook postConfigure
  '';

  buildPhase = ''
    runHook preBuild
    mix do escript.build
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    mkdir -p $out/bin
    cp -v ex_doc $out/bin
    runHook postInstall
  '';

  passthru = {
    tests = {
      # ex_doc is the doc generation for OTP 27+, so let's make sure they build
+20 −2
Original line number Diff line number Diff line
@@ -31,6 +31,9 @@
  # Build a particular named release.
  # see https://hexdocs.pm/mix/1.12/Mix.Tasks.Release.html#content
  mixReleaseName ? "",
  # If set, the given escript binary will be copied to the output
  # instead of the release
  escriptBinName ? null,

  # Options to be passed to the Erlang compiler. As documented in the reference
  # manual, these must be valid Erlang terms. They will be turned into an
@@ -90,6 +93,7 @@ let
in
assert mixNixDeps != { } -> mixFodDeps == null;
assert stripDebug -> !enableDebugInfo;
assert escriptBinName != null -> mixReleaseName == "";

stdenv.mkDerivation (
  overridable
@@ -116,7 +120,7 @@ stdenv.mkDerivation (
          makeWrapper
        ];

    buildInputs = buildInputs;
    buildInputs = buildInputs ++ lib.optionals (escriptBinName != null) [ erlang ];

    MIX_ENV = mixEnv;
    MIX_DEBUG = if enableDebugInfo then 1 else 0;
@@ -199,6 +203,10 @@ stdenv.mkDerivation (

        mix compile --no-deps-check ${lib.concatStringsSep " " compileFlags}

        ${lib.optionalString (escriptBinName != null) ''
          mix escript.build --no-deps-check
        ''}

        runHook postBuild
      '';

@@ -206,7 +214,17 @@ stdenv.mkDerivation (
      attrs.installPhase or ''
        runHook preInstall

        ${
          if (escriptBinName != null) then
            ''
              mkdir -p $out/bin
              cp ${escriptBinName} $out/bin
            ''
          else
            ''
              mix release ${mixReleaseName} --no-deps-check --path "$out"
            ''
        }

        runHook postInstall
      '';