summary refs log tree commit diff
path: root/pkgs/development/beam-modules/build-erlang-mk.nix
diff options
context:
space:
mode:
authorAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
committerAlyssa Ross <hi@alyssa.is>2021-08-04 10:43:07 +0000
commit62614cbef7da005c1eda8c9400160f6bcd6546b8 (patch)
treec2630f69080637987b68acb1ee8676d2681fe304 /pkgs/development/beam-modules/build-erlang-mk.nix
parentd9c82ed3044c72cecf01c6ea042489d30914577c (diff)
parente24069138dfec3ef94f211f1da005bb5395adc11 (diff)
downloadnixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.gz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.bz2
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.lz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.xz
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.tar.zst
nixpkgs-62614cbef7da005c1eda8c9400160f6bcd6546b8.zip
Merge branch 'nixpkgs-update' into master
Diffstat (limited to 'pkgs/development/beam-modules/build-erlang-mk.nix')
-rw-r--r--pkgs/development/beam-modules/build-erlang-mk.nix85
1 files changed, 49 insertions, 36 deletions
diff --git a/pkgs/development/beam-modules/build-erlang-mk.nix b/pkgs/development/beam-modules/build-erlang-mk.nix
index 4dedf782b75..d1afa55387d 100644
--- a/pkgs/development/beam-modules/build-erlang-mk.nix
+++ b/pkgs/development/beam-modules/build-erlang-mk.nix
@@ -1,30 +1,33 @@
 { stdenv, writeText, erlang, perl, which, gitMinimal, wget, lib }:
 
-{ name, version
+{ name
+, version
 , src
 , setupHook ? null
-, buildInputs ? []
-, beamDeps ? []
+, buildInputs ? [ ]
+, beamDeps ? [ ]
 , postPatch ? ""
 , compilePorts ? false
 , installPhase ? null
 , buildPhase ? null
 , configurePhase ? null
-, meta ? {}
+, meta ? { }
 , enableDebugInfo ? false
-, ... }@attrs:
+, buildFlags ? [ ]
+, ...
+}@attrs:
 
-with stdenv.lib;
+with lib;
 
 let
   debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "+debug_info";
 
   shell = drv: stdenv.mkDerivation {
-          name = "interactive-shell-${drv.name}";
-          buildInputs = [ drv ];
-    };
+    name = "interactive-shell-${drv.name}";
+    buildInputs = [ drv ];
+  };
 
-  pkg = self: stdenv.mkDerivation ( attrs // {
+  pkg = self: stdenv.mkDerivation (attrs // {
     app_name = name;
     name = "${name}-${version}";
     inherit version;
@@ -33,39 +36,48 @@ let
 
     inherit src;
 
-    setupHook = if setupHook == null
-    then writeText "setupHook.sh" ''
-       addToSearchPath ERL_LIBS "$1/lib/erlang/lib"
-    ''
-    else setupHook;
+    setupHook =
+      if setupHook == null
+      then
+        writeText "setupHook.sh" ''
+          addToSearchPath ERL_LIBS "$1/lib/erlang/lib"
+        ''
+      else setupHook;
 
-    buildInputs = [ erlang perl which gitMinimal wget ];
+    buildInputs = buildInputs ++ [ erlang perl which gitMinimal wget ];
     propagatedBuildInputs = beamDeps;
 
-    configurePhase = if configurePhase == null
-    then ''
-      runHook preConfigure
+    buildFlags = [ "SKIP_DEPS=1" ]
+      ++ lib.optional (enableDebugInfo || erlang.debugInfo) ''ERL_OPTS="$ERL_OPTS +debug_info"''
+      ++ buildFlags;
+
+    configurePhase =
+      if configurePhase == null
+      then ''
+        runHook preConfigure
 
-      # We shouldnt need to do this, but it seems at times there is a *.app in
-      # the repo/package. This ensures we start from a clean slate
-      make SKIP_DEPS=1 clean
+        # We shouldnt need to do this, but it seems at times there is a *.app in
+        # the repo/package. This ensures we start from a clean slate
+        make SKIP_DEPS=1 clean
 
-      runHook postConfigure
-    ''
-    else configurePhase;
+        runHook postConfigure
+      ''
+      else configurePhase;
 
-    buildPhase = if buildPhase == null
-    then ''
+    buildPhase =
+      if buildPhase == null
+      then ''
         runHook preBuild
 
-        make SKIP_DEPS=1 ERL_OPTS="$ERL_OPTS ${debugInfoFlag}"
+        make $buildFlags "''${buildFlagsArray[@]}"
 
         runHook postBuild
-    ''
-    else buildPhase;
+      ''
+      else buildPhase;
 
-    installPhase =  if installPhase == null
-    then ''
+    installPhase =
+      if installPhase == null
+      then ''
         runHook preInstall
 
         mkdir -p $out/lib/erlang/lib/${name}
@@ -85,13 +97,14 @@ let
         fi
 
         runHook postInstall
-    ''
-    else installPhase;
+      ''
+      else installPhase;
 
     passthru = {
       packageName = name;
       env = shell self;
       inherit beamDeps;
     };
-});
-in fix pkg
+  });
+in
+fix pkg