push sheeet
Some checks failed
Periodic Merges (6h) / master → staging-nixos (push) Failing after 12m50s
Periodic Merges (6h) / master → staging-next (push) Failing after 12m54s
Periodic Merges (24h) / merge-base(master,staging) → haskell-updates (push) Failing after 11m54s
Periodic Merges (6h) / staging-next → staging (push) Failing after 12m13s
Periodic Merges (24h) / staging-next-25.05 → staging-25.05 (push) Failing after 13m24s
Periodic Merges (24h) / release-25.05 → staging-next-25.05 (push) Failing after 14m28s

This commit is contained in:
Dark Steveneq
2025-10-09 14:15:47 +02:00
commit 646b892680
49168 changed files with 5897842 additions and 0 deletions

View File

@@ -0,0 +1,136 @@
{
stdenv,
writeText,
erlang,
perl,
which,
gitMinimal,
wget,
lib,
}:
{
name,
version,
src,
setupHook ? null,
buildInputs ? [ ],
beamDeps ? [ ],
postPatch ? "",
compilePorts ? false,
installPhase ? null,
buildPhase ? null,
configurePhase ? null,
meta ? { },
enableDebugInfo ? false,
buildFlags ? [ ],
...
}@attrs:
let
debugInfoFlag = lib.optionalString (enableDebugInfo || erlang.debugInfo) "+debug_info";
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
pkg =
self:
stdenv.mkDerivation (
attrs
// {
app_name = name;
name = "${name}-${version}";
inherit version;
dontStrip = true;
inherit src;
setupHook =
if setupHook == null then
writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib"
''
else
setupHook;
buildInputs = buildInputs ++ [
erlang
perl
which
gitMinimal
wget
];
propagatedBuildInputs = beamDeps;
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
runHook postConfigure
''
else
configurePhase;
buildPhase =
if buildPhase == null then
''
runHook preBuild
make $buildFlags "''${buildFlagsArray[@]}"
runHook postBuild
''
else
buildPhase;
installPhase =
if installPhase == null then
''
runHook preInstall
mkdir -p $out/lib/erlang/lib/${name}
cp -r ebin $out/lib/erlang/lib/${name}/
cp -r src $out/lib/erlang/lib/${name}/
if [ -d include ]; then
cp -r include $out/lib/erlang/lib/${name}/
fi
if [ -d priv ]; then
cp -r priv $out/lib/erlang/lib/${name}/
fi
if [ -d doc ]; then
cp -r doc $out/lib/erlang/lib/${name}/
fi
runHook postInstall
''
else
installPhase;
passthru = {
packageName = name;
env = shell self;
inherit beamDeps;
};
}
);
in
lib.fix pkg

View File

@@ -0,0 +1,31 @@
{
lib,
buildRebar3,
fetchHex,
}:
{
name,
version,
sha256,
builder ? buildRebar3,
hexPkg ? name,
...
}@attrs:
let
pkg =
self:
builder (
attrs
// {
src = fetchHex {
pkg = hexPkg;
inherit version;
inherit sha256;
};
}
);
in
lib.fix pkg

View File

@@ -0,0 +1,157 @@
{
stdenv,
writeText,
elixir,
erlang,
hex,
lib,
}:
{
name,
version,
src,
buildInputs ? [ ],
nativeBuildInputs ? [ ],
erlangCompilerOptions ? [ ],
# Deterministic Erlang builds remove full system paths from debug information
# among other things to keep builds more reproducible. See their docs for more:
# https://www.erlang.org/doc/man/compile
erlangDeterministicBuilds ? true,
beamDeps ? [ ],
propagatedBuildInputs ? [ ],
postPatch ? "",
compilePorts ? false,
meta ? { },
enableDebugInfo ? false,
mixEnv ? "prod",
mixTarget ? "host",
removeConfig ? true,
# A config directory that is considered for all the dependencies of an app, typically in $src/config/
# This was initially added, as some of Mobilizon's dependencies need to access the config at build time.
appConfigPath ? null,
...
}@attrs:
assert appConfigPath != null -> removeConfig;
let
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
pkg =
self:
stdenv.mkDerivation (
attrs
// {
name = "${name}-${version}";
inherit version src;
MIX_ENV = mixEnv;
MIX_TARGET = mixTarget;
MIX_BUILD_PREFIX = (if mixTarget == "host" then "" else "${mixTarget}_") + "${mixEnv}";
MIX_DEBUG = if enableDebugInfo then 1 else 0;
HEX_OFFLINE = 1;
ERL_COMPILER_OPTIONS =
let
options = erlangCompilerOptions ++ lib.optionals erlangDeterministicBuilds [ "deterministic" ];
in
"[${lib.concatStringsSep "," options}]";
LANG = if stdenv.hostPlatform.isLinux then "C.UTF-8" else "C";
LC_CTYPE = if stdenv.hostPlatform.isLinux then "C.UTF-8" else "UTF-8";
# add to ERL_LIBS so other modules can find at runtime.
# http://erlang.org/doc/man/code.html#code-path
# Mix also searches the code path when compiling with the --no-deps-check flag
setupHook = attrs.setupHook or writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib"
'';
buildInputs = buildInputs ++ [ ];
nativeBuildInputs = nativeBuildInputs ++ [
elixir
hex
];
propagatedBuildInputs = propagatedBuildInputs ++ beamDeps;
configurePhase =
attrs.configurePhase or ''
runHook preConfigure
${./mix-configure-hook.sh}
${lib.optionalString (removeConfig && isNull appConfigPath)
# By default, we don't want to include whatever config a dependency brings; per
# https://hexdocs.pm/elixir/main/Config.html, config is application specific.
''
rm -rf config
mkdir config
''
}
${lib.optionalString (!isNull appConfigPath)
# Some more tightly-coupled dependencies do depend on the config of the application
# they're being built for.
''
rm -rf config
cp -r ${appConfigPath} config
''
}
runHook postConfigure
'';
buildPhase =
attrs.buildPhase or ''
runHook preBuild
export HEX_HOME="$TEMPDIR/hex"
export MIX_HOME="$TEMPDIR/mix"
mix compile --no-deps-check
runHook postBuild
'';
installPhase =
attrs.installPhase or ''
runHook preInstall
# This uses the install path convention established by nixpkgs maintainers
# for all beam packages. Changing this will break compatibility with other
# builder functions like buildRebar3 and buildErlangMk.
mkdir -p "$out/lib/erlang/lib/${name}-${version}"
# Some packages like db_connection will use _build/shared instead of
# honoring the $MIX_ENV variable.
for reldir in _build/{$MIX_BUILD_PREFIX,shared}/lib/${name}/{src,ebin,priv,include} ; do
if test -d $reldir ; then
# Some builds produce symlinks (eg: phoenix priv dircetory). They must
# be followed with -H flag.
cp -Hrt "$out/lib/erlang/lib/${name}-${version}" "$reldir"
fi
done
# Copy the source so it can be used by dependent packages. For example,
# phoenix applications need the source of phoenix and phoenix_html to
# build javascript and css assets.
mkdir -p $out/src
cp -r "$src/." "$out/src"
runHook postInstall
'';
# stripping does not have any effect on beam files
# it is however needed for dependencies with NIFs like bcrypt for example
dontStrip = false;
passthru = {
packageName = name;
env = shell self;
inherit beamDeps;
};
}
);
in
lib.fix pkg

View File

@@ -0,0 +1,123 @@
{
stdenv,
writeText,
erlang,
rebar3WithPlugins,
openssl,
libyaml,
lib,
}:
{
name,
version,
src,
setupHook ? null,
buildInputs ? [ ],
beamDeps ? [ ],
buildPlugins ? [ ],
postPatch ? "",
installPhase ? null,
buildPhase ? null,
configurePhase ? null,
meta ? { },
erlangCompilerOptions ? [ ],
# Deterministic Erlang builds remove full system paths from debug information
# among other things to keep builds more reproducible. See their docs for more:
# https://www.erlang.org/doc/man/compile
erlangDeterministicBuilds ? true,
...
}@attrs:
let
rebar3 = rebar3WithPlugins {
plugins = buildPlugins;
};
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
customPhases = lib.filterAttrs (_: v: v != null) {
inherit
setupHook
configurePhase
buildPhase
installPhase
;
};
pkg =
self:
stdenv.mkDerivation (
attrs
// {
name = "${name}-${version}";
inherit version;
buildInputs = buildInputs ++ [
erlang
rebar3
openssl
libyaml
];
propagatedBuildInputs = lib.unique beamDeps;
inherit src;
ERL_COMPILER_OPTIONS =
let
options = erlangCompilerOptions ++ lib.optionals erlangDeterministicBuilds [ "deterministic" ];
in
"[${lib.concatStringsSep "," options}]";
# stripping does not have any effect on beam files
# it is however needed for dependencies with NIFs
# false is the default but we keep this for readability
dontStrip = false;
setupHook = writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
'';
postPatch = ''
rm -f rebar rebar3
''
+ postPatch;
buildPhase = ''
runHook preBuild
HOME=. rebar3 bare compile --paths "."
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/lib/erlang/lib/${name}-${version}"
for reldir in src ebin priv include; do
[ -d "$reldir" ] || continue
# $out/lib/erlang/lib is a convention used in nixpkgs for compiled BEAM packages
cp -Hrt "$out/lib/erlang/lib/${name}-${version}" "$reldir"
done
runHook postInstall
'';
meta = {
inherit (erlang.meta) platforms;
}
// meta;
passthru = {
packageName = name;
env = shell self;
inherit beamDeps;
};
}
// customPhases
);
in
lib.fix pkg

View File

@@ -0,0 +1,98 @@
{
lib,
__splicedPackages,
erlang,
}:
let
pkgs = __splicedPackages;
inherit (lib) makeExtensible;
lib' = pkgs.callPackage ./lib.nix { };
# FIXME: add support for overrideScope
callPackageWithScope =
scope: drv: args:
lib.callPackageWith scope drv args;
mkScope = scope: pkgs // scope;
packages =
self:
let
defaultScope = mkScope self;
callPackage = drv: args: callPackageWithScope defaultScope drv args;
in
rec {
inherit callPackage erlang;
beamPackages = self;
inherit (callPackage ../tools/build-managers/rebar3 { }) rebar3 rebar3WithPlugins;
rebar = callPackage ../tools/build-managers/rebar { };
pc = callPackage ./pc { };
rebar3-proper = callPackage ./rebar3-proper { };
rebar3-nix = callPackage ./rebar3-nix { };
fetchHex = callPackage ./fetch-hex.nix { };
fetchRebar3Deps = callPackage ./fetch-rebar-deps.nix { };
rebar3Relx = callPackage ./rebar3-release.nix { };
buildRebar3 = callPackage ./build-rebar3.nix { };
buildHex = callPackage ./build-hex.nix { };
buildErlangMk = callPackage ./build-erlang-mk.nix { };
buildMix = callPackage ./build-mix.nix { };
fetchMixDeps = callPackage ./fetch-mix-deps.nix { };
mixRelease = callPackage ./mix-release.nix { };
erlfmt = callPackage ./erlfmt { };
elvis-erlang = callPackage ./elvis-erlang { };
# BEAM-based languages.
elixir = elixir_1_18;
elixir_1_19 = lib'.callElixir ../interpreters/elixir/1.19.nix {
inherit erlang;
debugInfo = true;
};
elixir_1_18 = lib'.callElixir ../interpreters/elixir/1.18.nix {
inherit erlang;
debugInfo = true;
};
elixir_1_17 = lib'.callElixir ../interpreters/elixir/1.17.nix {
inherit erlang;
debugInfo = true;
};
elixir_1_16 = lib'.callElixir ../interpreters/elixir/1.16.nix {
inherit erlang;
debugInfo = true;
};
elixir_1_15 = lib'.callElixir ../interpreters/elixir/1.15.nix {
inherit erlang;
debugInfo = true;
};
# Remove old versions of elixir, when the supports fades out:
# https://hexdocs.pm/elixir/compatibility-and-deprecations.html
ex_doc = callPackage ./ex_doc {
inherit fetchMixDeps mixRelease;
};
elixir-ls = callPackage ./elixir-ls { inherit elixir; };
lfe = callPackage ../interpreters/lfe { inherit erlang buildRebar3 buildHex; };
livebook = callPackage ./livebook { inherit beamPackages; };
# Non hex packages. Examples how to build Rebar/Mix packages with and
# without helper functions buildRebar3 and buildMix.
hex = callPackage ./hex { };
webdriver = callPackage ./webdriver { };
};
in
makeExtensible packages

View File

@@ -0,0 +1,70 @@
{
lib,
elixir,
fetchFromGitHub,
makeWrapper,
stdenv,
nix-update-script,
}:
stdenv.mkDerivation rec {
pname = "elixir-ls";
version = "0.29.3";
src = fetchFromGitHub {
owner = "elixir-lsp";
repo = "elixir-ls";
rev = "v${version}";
hash = "sha256-ikx0adlDrkUpMXPEbPtIsb2/1wcOt1jLwciVdBEKnss=";
};
patches = [
# patch wrapper script to remove elixir detection and inject necessary paths
./launch.sh.patch
];
nativeBuildInputs = [
makeWrapper
];
# for substitution
env.elixir = elixir;
dontConfigure = true;
dontBuild = true;
installPhase = ''
cp -R . $out
ln -s $out/VERSION $out/scripts/VERSION
substituteAllInPlace $out/scripts/launch.sh
mkdir -p $out/bin
makeWrapper $out/scripts/language_server.sh $out/bin/elixir-ls \
--set ELS_LOCAL "1"
makeWrapper $out/scripts/debug_adapter.sh $out/bin/elixir-debug-adapter \
--set ELS_LOCAL "1"
runHook postInstall
'';
meta = with lib; {
homepage = "https://github.com/elixir-lsp/elixir-ls";
description = ''
A frontend-independent IDE "smartness" server for Elixir.
Implements the "Language Server Protocol" standard and provides debugger support via the "Debug Adapter Protocol"
'';
longDescription = ''
The Elixir Language Server provides a server that runs in the background, providing IDEs, editors, and other tools with information about Elixir Mix projects.
It adheres to the Language Server Protocol, a standard for frontend-independent IDE support.
Debugger integration is accomplished through the similar VS Code Debug Protocol.
'';
license = licenses.asl20;
platforms = platforms.unix;
mainProgram = "elixir-ls";
teams = [ teams.beam ];
};
passthru.updateScript = nix-update-script { };
}

View File

@@ -0,0 +1,162 @@
diff --git c/scripts/launch.sh w/scripts/launch.sh
index d9c33952..8bc5c382 100755
--- c/scripts/launch.sh
+++ w/scripts/launch.sh
@@ -1,114 +1,4 @@
-#!/bin/sh
-# Actual launcher. This does the hard work of figuring out the best way
-# to launch the language server or the debug adapter.
-
-# Running this script is a one-time action per project launch, so we opt for
-# code simplicity instead of performance. Hence some potentially redundant
-# moves here.
-
-
-did_relaunch=$1
-
-# Get the user's preferred shell
-preferred_shell=$(basename "$SHELL")
-
-# Get current dirname
-dirname=$(dirname "$0")
-
-case "${did_relaunch}" in
- "")
- if [ "$preferred_shell" = "bash" ]; then
- >&2 echo "Preferred shell is bash, relaunching"
- exec "$(which bash)" "$0" relaunch
- elif [ "$preferred_shell" = "zsh" ]; then
- >&2 echo "Preferred shell is zsh, relaunching"
- exec "$(which zsh)" "$0" relaunch
- elif [ "$preferred_shell" = "fish" ]; then
- >&2 echo "Preferred shell is fish, launching launch.fish"
- exec "$(which fish)" "$dirname/launch.fish"
- else
- >&2 echo "Preferred shell $preferred_shell is not supported, continuing in POSIX shell"
- fi
- ;;
- *)
- # We have an arg2, so we got relaunched
- ;;
-esac
-
-# First order of business, see whether we can setup asdf
-echo "Looking for asdf install" >&2
-
-readlink_f () {
- cd "$(dirname "$1")" > /dev/null || exit 1
- filename="$(basename "$1")"
- if [ -h "$filename" ]; then
- readlink_f "$(readlink "$filename")"
- else
- echo "$(pwd -P)/$filename"
- fi
-}
-
-export_stdlib_path () {
- which_elixir_expr=$1
- stdlib_path=$(eval "$which_elixir_expr")
- stdlib_real_path=$(readlink_f "$stdlib_path")
- ELX_STDLIB_PATH=$(echo "$stdlib_real_path" | sed "s/\(.*\)\/bin\/elixir/\1/")
- export ELX_STDLIB_PATH
-}
-
-# Check if we have the asdf binary for version >= 0.16.0
-if command -v asdf >/dev/null 2>&1; then
- asdf_version=$(asdf --version 2>/dev/null)
- version=$(echo "$asdf_version" | grep -Eo '[0-9]+\.[0-9]+\.[0-9]+')
- major=$(echo "$version" | cut -d. -f1)
- minor=$(echo "$version" | cut -d. -f2)
- # If the version is less than 0.16.0 (i.e. major = 0 and minor < 16), use legacy method.
- if [ "$major" -eq 0 ] && [ "$minor" -lt 16 ]; then
- ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"}
- ASDF_SH="${ASDF_DIR}/asdf.sh"
- if test -f "$ASDF_SH"; then
- >&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing"
- # Source the old asdf.sh script for versions <= 0.15.0
- . "$ASDF_SH"
- else
- >&2 echo "Legacy asdf not found at $ASDF_SH"
- fi
- else
- >&2 echo "asdf executable found at $(command -v asdf). Using ASDF_DIR=${ASDF_DIR}, ASDF_DATA_DIR=${ASDF_DATA_DIR}."
- fi
- export_stdlib_path "asdf which elixir"
-else
- # Fallback to old method for version <= 0.15.x
- ASDF_DIR=${ASDF_DIR:-"${HOME}/.asdf"}
- ASDF_SH="${ASDF_DIR}/asdf.sh"
- if test -f "$ASDF_SH"; then
- >&2 echo "Legacy pre v0.16.0 asdf install found at $ASDF_SH, sourcing"
- # Source the old asdf.sh script for versions <= 0.15.0
- . "$ASDF_SH"
- export_stdlib_path "asdf which elixir"
- else
- >&2 echo "asdf not found"
- >&2 echo "Looking for mise executable"
-
- # Look for mise executable
- if command -v mise >/dev/null 2>&1; then
- >&2 echo "mise executable found at $(command -v mise), activating"
- eval "$($(command -v mise) env -s "$preferred_shell")"
- export_stdlib_path "mise which elixir"
- else
- >&2 echo "mise not found"
- >&2 echo "Looking for vfox executable"
-
- if command -v vfox >/dev/null 2>&1; then
- >&2 echo "vfox executable found at $(command -v vfox), activating"
- eval "$( $(command -v vfox) activate "$preferred_shell" )"
- else
- >&2 echo "vfox not found"
- export_stdlib_path "which elixir"
- fi
- fi
- fi
-fi
+#!/usr/bin/env bash
# In case that people want to tweak the path, which Elixir to use, or
# whatever prior to launching the language server or the debug adapter, we
@@ -127,29 +17,22 @@ fi
# script so we can correctly configure the Erlang library path to
# include the local .ez files, and then do what we were asked to do.
-if [ -z "${ELS_INSTALL_PREFIX}" ]; then
- SCRIPT=$(readlink_f "$0")
- SCRIPTPATH=$(dirname "$SCRIPT")
-else
- SCRIPTPATH=${ELS_INSTALL_PREFIX}
-fi
+SCRIPT=$(readlink -f "$0")
+SCRIPTPATH=$(dirname "$SCRIPT")/../scripts
export MIX_ENV=prod
# Mix.install prints to stdout and reads from stdin
# we need to make sure it doesn't interfere with LSP/DAP
-echo "" | elixir "$SCRIPTPATH/quiet_install.exs" >/dev/null || exit 1
+echo "" | @elixir@/bin/elixir "$SCRIPTPATH/quiet_install.exs" >/dev/null || exit 1
default_erl_opts="-kernel standard_io_encoding latin1 +sbwt none +sbwtdcpu none +sbwtdio none"
-if [ "$preferred_shell" = "bash" ]; then
- . "$dirname/exec.bash"
-elif [ "$preferred_shell" = "zsh" ]; then
- . "$dirname/exec.zsh"
-else
- if [ -z "$ELS_ELIXIR_OPTS" ]
- then
- # in posix shell does not support arrays
- >&2 echo "ELS_ELIXIR_OPTS is not supported in current shell"
- fi
- exec elixir --erl "$default_erl_opts $ELS_ERL_OPTS" "$SCRIPTPATH/launch.exs"
-fi
+# ensure elixir stdlib can be found
+ELX_STDLIB_PATH=${ELX_STDLIB_PATH:-@elixir@/lib/elixir}
+export ELX_STDLIB_PATH
+
+# ensure our elixir is in the path
+PATH="@elixir@/bin:$PATH"
+export PATH
+
+source "$SCRIPTPATH/exec.bash"

View File

@@ -0,0 +1,58 @@
{
buildRebar3,
fetchFromGitHub,
fetchHex,
fetchgit,
lib,
rebar3Relx,
writeScript,
}:
rebar3Relx rec {
releaseType = "escript";
pname = "elvis-erlang";
version = "4.1.1";
src = fetchFromGitHub {
owner = "inaka";
repo = "elvis";
hash = "sha256-9aOJpKYb+M07bi6aEMt5Gtr/edOGm+jyA8bxiLyUd0g=";
tag = version;
};
beamDeps = builtins.attrValues (
import ./rebar-deps.nix {
inherit fetchHex fetchgit fetchFromGitHub;
builder = buildRebar3;
}
);
passthru.updateScript = writeScript "update.sh" ''
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash common-updater-scripts git nix-prefetch-git gnutar gzip "rebar3WithPlugins {globalPlugins = [beamPackages.rebar3-nix];}"
set -euo pipefail
latest=$(list-git-tags | sort -V | tail -1)
if [ "$latest" != "${version}" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
nix_path="$nixpkgs/pkgs/development/beam-modules/elvis-erlang"
update-source-version elvis-erlang "$latest" --version-key=version --print-changes --file="$nix_path/default.nix"
tmpdir=$(mktemp -d)
cp -R $(nix-build $nixpkgs --no-out-link -A elvis-erlang.src)/* "$tmpdir"
(cd "$tmpdir" && HOME=. rebar3 nix lock -o "$nix_path/rebar-deps.nix")
nixfmt "$nix_path/rebar-deps.nix"
else
echo "elvis-erlang is already up-to-date"
fi
'';
meta = {
homepage = "https://github.com/inaka/elvis";
description = "Erlang Style Reviewer";
platforms = lib.platforms.unix;
license = lib.licenses.asl20;
maintainers = with lib.maintainers; [ dlesl ];
mainProgram = "elvis";
};
}

View File

@@ -0,0 +1,193 @@
# Generated by rebar3_nix
let
fetchOnly = { src, ... }: src;
in
{
builder ? fetchOnly,
fetchHex,
fetchgit,
fetchFromGitHub,
overrides ? (x: y: { }),
}:
let
self = packages // (overrides self packages);
packages = with self; {
unicode_util_compat = builder {
name = "unicode_util_compat";
version = "0.7.1";
src = fetchHex {
pkg = "unicode_util_compat";
version = "0.7.1";
sha256 = "sha256-s6kXhUzjriM2GXRK0eAQLgVnMTZ3b7L6diNPPgOyNkI=";
};
beamDeps = [ ];
};
ssl_verify_fun = builder {
name = "ssl_verify_fun";
version = "1.1.7";
src = fetchHex {
pkg = "ssl_verify_fun";
version = "1.1.7";
sha256 = "sha256-/kwZDo83QB0wFnyMQF7aGUafNFd5h8dt3mE+g4u8Z/g=";
};
beamDeps = [ ];
};
parse_trans = builder {
name = "parse_trans";
version = "3.4.2";
src = fetchHex {
pkg = "parse_trans";
version = "3.4.2";
sha256 = "sha256-TCU0feO3w1cy0y5pq0PRzu4L6uPzs63htZy9PdIk2co=";
};
beamDeps = [ ];
};
mimerl = builder {
name = "mimerl";
version = "1.4.0";
src = fetchHex {
pkg = "mimerl";
version = "1.4.0";
sha256 = "sha256-E68V+faMZYhOzKOjiR1Qp7V9ghUnkvPhnYhlCqEmsUQ=";
};
beamDeps = [ ];
};
metrics = builder {
name = "metrics";
version = "1.0.1";
src = fetchHex {
pkg = "metrics";
version = "1.0.1";
sha256 = "sha256-abCa3dxPdKQHFq5U0UD5O+sPuJeNhjbq3tDDG28JnxY=";
};
beamDeps = [ ];
};
idna = builder {
name = "idna";
version = "6.1.1";
src = fetchHex {
pkg = "idna";
version = "6.1.1";
sha256 = "sha256-kjdut4lEEu0ZrEdeSob3tBPBufu1vRbczVeTQVeUTOo=";
};
beamDeps = [ unicode_util_compat ];
};
certifi = builder {
name = "certifi";
version = "2.15.0";
src = fetchHex {
pkg = "certifi";
version = "2.15.0";
sha256 = "sha256-sUftIs5x1y6v2tlPBVFlwcGC9hov9J3yi8xx0dW5SmA=";
};
beamDeps = [ ];
};
zipper = builder {
name = "zipper";
version = "1.1.0";
src = fetchHex {
pkg = "zipper";
version = "1.1.0";
sha256 = "sha256-RkTIOug+88CYYMte1Zewx1n7vNZK1bAKYvUa5IrvdTU=";
};
beamDeps = [ ];
};
lager = builder {
name = "lager";
version = "3.9.1";
src = fetchHex {
pkg = "lager";
version = "3.9.1";
sha256 = "sha256-P1m6daBKmeXxi/kcifRtzlNvg8bLQV/ibm51pivvN9w=";
};
beamDeps = [ goldrush ];
};
katana_code = builder {
name = "katana_code";
version = "2.4.1";
src = fetchHex {
pkg = "katana_code";
version = "2.4.1";
sha256 = "sha256-WO/GO12dq8giMMq1DN5/eyWSh6aQ7Wmfeaf6gPSbCzo=";
};
beamDeps = [ ];
};
jsx = builder {
name = "jsx";
version = "2.10.0";
src = fetchHex {
pkg = "jsx";
version = "2.10.0";
sha256 = "sha256-moPjcEgHKYAWlo21Bvn60PAn3jdUbrg4s64QZMOgrWI=";
};
beamDeps = [ ];
};
hackney = builder {
name = "hackney";
version = "1.17.1";
src = fetchHex {
pkg = "hackney";
version = "1.17.1";
sha256 = "sha256-0sup48gQOtAyBiPp8cM+jTeKFeqr4u6K5EGJjz01oYw=";
};
beamDeps = [
certifi
idna
metrics
mimerl
parse_trans
ssl_verify_fun
unicode_util_compat
];
};
goldrush = builder {
name = "goldrush";
version = "0.1.9";
src = fetchHex {
pkg = "goldrush";
version = "0.1.9";
sha256 = "sha256-mctBKM/8syJ1geXU2APVQT+mQ/TrllI/d9nmk32ZTOs=";
};
beamDeps = [ ];
};
getopt = builder {
name = "getopt";
version = "1.0.3";
src = fetchHex {
pkg = "getopt";
version = "1.0.3";
sha256 = "sha256-fgHekKxUDyFJT/cnkrHjFi05mWbrv8Z0tM5Sy49JMk8=";
};
beamDeps = [ ];
};
elvis_core = builder {
name = "elvis_core";
version = "4.1.1";
src = fetchHex {
pkg = "elvis_core";
version = "4.1.1";
sha256 = "sha256-gKViV0uNl0oudUTpqUVXFtBMngldvIyJFeJGgDHdE4U=";
};
beamDeps = [
katana_code
zipper
];
};
egithub = builder {
name = "egithub";
version = "0.7.0";
src = fetchHex {
pkg = "egithub";
version = "0.7.0";
sha256 = "sha256-4AnOEe/YAI0PntWdnEiOPpq+MCoPLNbWY+TMJnVvzEw=";
};
beamDeps = [
goldrush
hackney
jsx
lager
];
};
};
in
self

View File

@@ -0,0 +1,27 @@
{
fetchFromGitHub,
lib,
rebar3Relx,
}:
rebar3Relx rec {
pname = "erlfmt";
version = "1.7.0";
releaseType = "escript";
src = fetchFromGitHub {
owner = "WhatsApp";
repo = "erlfmt";
hash = "sha256-bljqWqpzAPP7+cVA3F+vXoUzUFzD4zXpUl/4XmMypB4=";
tag = "v${version}";
};
meta = with lib; {
homepage = "https://github.com/WhatsApp/erlfmt";
description = "Automated code formatter for Erlang";
mainProgram = "erlfmt";
platforms = platforms.unix;
license = licenses.asl20;
maintainers = with lib.maintainers; [ dlesl ];
};
}

View File

@@ -0,0 +1,63 @@
{
lib,
elixir,
fetchFromGitHub,
fetchMixDeps,
mixRelease,
nix-update-script,
# for tests
beam27Packages,
beam28Packages,
}:
# Based on ../elixir-ls/default.nix
let
pname = "ex_doc";
version = "0.38.4";
src = fetchFromGitHub {
owner = "elixir-lang";
repo = "${pname}";
rev = "v${version}";
hash = "sha256-/gZczKm/IF5QQemrdcda9oKVIGDFSqdiu8YrBwT6Mtk=";
};
in
mixRelease {
inherit
pname
version
src
elixir
;
escriptBinName = "ex_doc";
stripDebug = true;
mixFodDeps = fetchMixDeps {
pname = "mix-deps-${pname}";
inherit src version elixir;
hash = "sha256-TknrENa0Nb1Eobd4oTBl6TilPVEsw9+XjPdF3Ntq+DI=";
};
passthru = {
tests = {
# ex_doc is the doc generation for OTP 27+, so let's make sure they build
erlang_27 = beam27Packages.erlang;
erlang_28 = beam28Packages.erlang;
};
updateScript = nix-update-script { };
};
meta = with lib; {
homepage = "https://github.com/elixir-lang/ex_doc";
description = ''
ExDoc produces HTML and EPUB documentation for Elixir projects
'';
license = licenses.asl20;
platforms = platforms.unix;
mainProgram = "ex_doc";
maintainers = with maintainers; [ chiroptical ];
};
}

View File

@@ -0,0 +1,50 @@
{
lib,
stdenv,
fetchurl,
}:
{
pkg,
version,
sha256,
meta ? { },
}:
stdenv.mkDerivation {
pname = pkg;
inherit version;
dontBuild = true;
dontConfigure = true;
dontFixup = true;
src = fetchurl {
url = "https://repo.hex.pm/tarballs/${pkg}-${version}.tar";
inherit sha256;
};
unpackCmd = ''
tar -xf $curSrc contents.tar.gz CHECKSUM metadata.config
mkdir contents
tar -C contents -xzf contents.tar.gz
mv metadata.config contents/hex_metadata.config
# To make the extracted hex tarballs appear legitimate to mix, we need to
# make sure they contain not just the contents of contents.tar.gz but also
# a .hex file with some lock metadata.
# We use an old version of .hex file per hex's mix_task_test.exs since it
# is just plain-text instead of an encoded format.
# See: https://github.com/hexpm/hex/blob/main/test/hex/mix_task_test.exs#L410
echo -n "${pkg},${version},$(cat CHECKSUM | tr '[:upper:]' '[:lower:]'),hexpm" > contents/.hex
'';
installPhase = ''
runHook preInstall
mkdir "$out"
cp -Hrt "$out" .
success=1
runHook postInstall
'';
inherit meta;
}

View File

@@ -0,0 +1,100 @@
{
stdenvNoCC,
lib,
elixir,
hex,
rebar,
rebar3,
cacert,
git,
}@inputs:
{
pname,
version,
hash ? "",
sha256 ? "",
src,
mixEnv ? "prod",
mixTarget ? "host",
debug ? false,
meta ? { },
patches ? [ ],
elixir ? inputs.elixir,
hex ? inputs.hex.override { inherit elixir; },
...
}@attrs:
let
hash_ =
if hash != "" then
{
outputHashAlgo = null;
outputHash = hash;
}
else if sha256 != "" then
{
outputHashAlgo = "sha256";
outputHash = sha256;
}
else
{
outputHashAlgo = "sha256";
outputHash = lib.fakeSha256;
};
in
stdenvNoCC.mkDerivation (
attrs
// {
nativeBuildInputs = [
elixir
hex
cacert
git
];
MIX_ENV = mixEnv;
MIX_TARGET = mixTarget;
MIX_DEBUG = if debug then 1 else 0;
DEBUG = if debug then 1 else 0; # for rebar3
# the api with `mix local.rebar rebar path` makes a copy of the binary
MIX_REBAR = "${rebar}/bin/rebar";
MIX_REBAR3 = "${rebar3}/bin/rebar3";
# there is a persistent download failure with absinthe 1.6.3
# those defaults reduce the failure rate
HEX_HTTP_CONCURRENCY = 1;
HEX_HTTP_TIMEOUT = 120;
configurePhase =
attrs.configurePhase or ''
runHook preConfigure
export HEX_HOME="$TEMPDIR/.hex";
export MIX_HOME="$TEMPDIR/.mix";
export MIX_DEPS_PATH="$TEMPDIR/deps";
# Rebar
export REBAR_GLOBAL_CONFIG_DIR="$TMPDIR/rebar3"
export REBAR_CACHE_DIR="$TMPDIR/rebar3.cache"
runHook postConfigure
'';
inherit patches;
dontBuild = true;
installPhase =
attrs.installPhase or ''
runHook preInstall
mix deps.get ''${MIX_ENV:+--only $MIX_ENV}
find "$TEMPDIR/deps" -path '*/.git/*' -a ! -name HEAD -exec rm -rf {} +
cp -r --no-preserve=mode,ownership,timestamps $TEMPDIR/deps $out
runHook postInstall
'';
outputHashMode = "recursive";
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
inherit meta;
}
// hash_
)

View File

@@ -0,0 +1,46 @@
{
lib,
stdenv,
rebar3,
}:
{
name,
version,
sha256,
src,
meta ? { },
}:
stdenv.mkDerivation {
pname = "rebar-deps-${name}";
inherit version;
dontUnpack = true;
dontConfigure = true;
dontFixup = true;
buildPhase = ''
cp -r ${src} src
chmod -R u+w src
cd src
HOME='.' DEBUG=1 ${rebar3}/bin/rebar3 get-deps
'';
installPhase = ''
runHook preInstall
mkdir -p "$out/_checkouts"
for i in ./_build/default/lib/* ; do
echo "$i"
cp -R "$i" "$out/_checkouts"
done
runHook postInstall
'';
outputHashAlgo = "sha256";
outputHashMode = "recursive";
outputHash = sha256;
impureEnvVars = lib.fetchers.proxyImpureEnvVars;
inherit meta;
}

View File

@@ -0,0 +1,68 @@
{
lib,
stdenv,
fetchFromGitHub,
writeText,
elixir,
}:
let
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
pkg =
self:
stdenv.mkDerivation rec {
pname = "hex";
version = "2.2.2";
src = fetchFromGitHub {
owner = "hexpm";
repo = "hex";
rev = "v${version}";
sha256 = "sha256-Qih10OeI7KsnAthAW0yuH+YL8uoeLy7tOVn9rdkGA4M=";
};
setupHook = writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
'';
dontStrip = true;
buildInputs = [ elixir ];
buildPhase = ''
runHook preBuild
export HEX_OFFLINE=1
export HEX_HOME=./
export MIX_ENV=prod
mix compile
runHook postBuild
'';
installPhase = ''
runHook preInstall
mkdir -p $out/lib/erlang/lib
cp -r ./_build/prod/lib/hex $out/lib/erlang/lib/
runHook postInstall
'';
meta = {
description = "Package manager for the Erlang VM https://hex.pm";
license = lib.licenses.mit;
homepage = "https://github.com/hexpm/hex";
maintainers = with lib.maintainers; [ ericbmerritt ];
};
passthru = {
env = shell self;
};
};
in
lib.fix pkg

View File

@@ -0,0 +1,85 @@
{ __splicedPackages, lib }:
let
pkgs = __splicedPackages;
in
rec {
# Similar to callPackageWith/callPackage, but without makeOverridable
callPackageWith =
autoArgs: fn: args:
let
f = if pkgs.lib.isFunction fn then fn else import fn;
auto = builtins.intersectAttrs (lib.functionArgs f) autoArgs;
in
f (auto // args);
callPackage = callPackageWith pkgs;
/*
Uses generic-builder to evaluate provided drv containing OTP-version
specific data.
drv: package containing version-specific args;
builder: generic builder for all Erlang versions;
args: arguments merged into version-specific args, used mostly to customize
dependencies;
Arguments passed to the generic-builder are overridable, used to
enable/disable high-level OTP features, like ODBC or WX support;
Please note that "mkDerivation" defined here is the one called from R16.nix
and similar files.
*/
callErlang =
drv: args:
let
genericBuilder =
versionArgs: import ../../development/interpreters/erlang/generic-builder.nix (versionArgs // args);
in
pkgs.callPackage (import drv genericBuilder) { };
/*
Uses generic-builder to evaluate provided drv containing Elixir version
specific data.
drv: file containing version-specific args;
genericBuilder: generic builder for all Erlang versions;
args: arguments merged into version-specific args, used mostly to customize
high level options;
Arguments passed to the generic-builder are overridable.
*/
callElixir =
drv: args:
let
builder = callPackage ../interpreters/elixir/generic-builder.nix args;
in
callPackage drv {
mkDerivation = pkgs.makeOverridable builder;
};
/*
Uses generic-builder to evaluate provided drv containing Elixir version
specific data.
drv: package containing version-specific args;
builder: generic builder for all Erlang versions;
args: arguments merged into version-specific args, used mostly to customize
dependencies;
Arguments passed to the generic-builder are overridable.
Please note that "mkDerivation" defined here is the one called from 1.2.nix
and similar files.
*/
callLFE =
drv: args:
let
builder = callPackage ../interpreters/lfe/generic-builder.nix args;
in
callPackage drv {
mkDerivation = pkgs.makeOverridable builder;
};
}

View File

@@ -0,0 +1,62 @@
{
lib,
beamPackages,
makeWrapper,
fetchFromGitHub,
nixosTests,
nix-update-script,
}:
beamPackages.mixRelease rec {
pname = "livebook";
version = "0.17.2";
inherit (beamPackages) elixir;
buildInputs = [ beamPackages.erlang ];
nativeBuildInputs = [ makeWrapper ];
src = fetchFromGitHub {
owner = "livebook-dev";
repo = "livebook";
tag = "v${version}";
hash = "sha256-9AlvEqyQJvcRbAuuxF5Q5S9hG96vaQYVBYwPYp4lGQM=";
};
mixFodDeps = beamPackages.fetchMixDeps {
pname = "mix-deps-${pname}";
inherit src version;
hash = "sha256-18fmaNuu2KqTGhBBd+pSBfgnrHiqzXc3CMdSpC5lFs8=";
};
postInstall = ''
wrapProgram $out/bin/livebook \
--prefix PATH : ${
lib.makeBinPath [
beamPackages.elixir
beamPackages.erlang
]
} \
--set MIX_REBAR3 ${beamPackages.rebar3}/bin/rebar3
'';
passthru = {
updateScript = nix-update-script { };
tests = {
livebook-service = nixosTests.livebook-service;
};
};
meta = {
license = lib.licenses.asl20;
homepage = "https://livebook.dev/";
description = "Automate code & data workflows with interactive Elixir notebooks";
maintainers = with lib.maintainers; [
munksgaard
scvalex
];
platforms = lib.platforms.unix;
teams = [ lib.teams.beam ];
};
}

View File

@@ -0,0 +1,18 @@
# shellcheck shell=bash
# this hook will symlink all dependencies found in ERL_LIBS
# since Elixir 1.12.2 elixir does not look into ERL_LIBS for
# elixir depencencies anymore, so those have to be symlinked to the _build directory
mkdir -p _build/"$MIX_BUILD_PREFIX"/lib
while read -r -d ':' lib; do
for dir in "$lib"/*; do
# Strip version number for directory name if it exists, so naming of
# all libs matches what mix's expectation.
dest=$(basename "$dir" | cut -d '-' -f1)
build_dir="_build/$MIX_BUILD_PREFIX/lib/$dest"
((MIX_DEBUG == 1)) && echo "Linking $dir to $build_dir"
# Symlink libs to _build so that mix can find them when compiling.
# This is what allows mix to compile the package without searching
# for dependencies over the network.
ln -s "$dir" "$build_dir"
done
done <<< "$ERL_LIBS:"

View File

@@ -0,0 +1,293 @@
{
stdenv,
lib,
elixir,
erlang,
hex,
git,
rebar,
rebar3,
fetchMixDeps,
findutils,
ripgrep,
bbe,
makeWrapper,
coreutils,
gnused,
gnugrep,
gawk,
}@inputs:
{
pname,
version,
src,
nativeBuildInputs ? [ ],
buildInputs ? [ ],
meta ? { },
enableDebugInfo ? false,
mixEnv ? "prod",
mixTarget ? "host",
compileFlags ? [ ],
# 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
# erlang list and set as the ERL_COMPILER_OPTIONS environment variable.
# See https://www.erlang.org/doc/man/compile
erlangCompilerOptions ? [ ],
# Deterministic Erlang builds remove full system paths from debug information
# among other things to keep builds more reproducible. See their docs for more:
# https://www.erlang.org/doc/man/compile
erlangDeterministicBuilds ? true,
# Mix dependencies provided as a fixed output derivation
mixFodDeps ? null,
# Mix dependencies generated by mix2nix
#
# This assumes each dependency is built by buildMix or buildRebar3. Each
# dependency needs to have a setup hook to add the lib path to $ERL_LIBS.
# This is how Mix finds dependencies.
mixNixDeps ? { },
elixir ? inputs.elixir,
erlang ? inputs.erlang,
hex ? inputs.hex.override { inherit elixir; },
# Remove releases/COOKIE
#
# People have different views on the nature of cookies. Some believe that they are
# secrets, while others believe they are just ids for clustering nodes instead of
# secrets.
#
# If you think cookie is secret, you can set this attr to true, then it will be
# removed from nix store. If not, you can set it to false.
#
# For backward compatibility, it is set to true by default.
#
# You can always specify a custom cookie by using RELEASE_COOKIE environment
# variable, regardless of the value of this attr.
removeCookie ? true,
# This reduces closure size, but can lead to some hard to understand runtime
# errors, so use with caution. See e.g.
# https://github.com/whitfin/cachex/issues/205
# https://framagit.org/framasoft/mobilizon/-/issues/1169
stripDebug ? false,
...
}@attrs:
let
# Remove non standard attributes that cannot be coerced to strings
overridable = removeAttrs attrs [
"compileFlags"
"erlangCompilerOptions"
"mixNixDeps"
];
in
assert mixNixDeps != { } -> mixFodDeps == null;
assert stripDebug -> !enableDebugInfo;
assert escriptBinName != null -> mixReleaseName == "";
stdenv.mkDerivation (
overridable
// {
nativeBuildInputs =
nativeBuildInputs
++
# Erlang/Elixir deps
[
erlang
elixir
hex
git
]
++
# Mix deps
(builtins.attrValues mixNixDeps)
++
# other compile-time deps
[
findutils
ripgrep
bbe
makeWrapper
];
buildInputs = buildInputs ++ lib.optionals (escriptBinName != null) [ erlang ];
MIX_ENV = mixEnv;
MIX_TARGET = mixTarget;
MIX_BUILD_PREFIX = (if mixTarget == "host" then "" else "${mixTarget}_") + "${mixEnv}";
MIX_DEBUG = if enableDebugInfo then 1 else 0;
HEX_OFFLINE = 1;
DEBUG = if enableDebugInfo then 1 else 0; # for Rebar3 compilation
# The API with `mix local.rebar rebar path` makes a copy of the binary
# some older dependencies still use rebar.
MIX_REBAR = "${rebar}/bin/rebar";
MIX_REBAR3 = "${rebar3}/bin/rebar3";
ERL_COMPILER_OPTIONS =
let
options = erlangCompilerOptions ++ lib.optionals erlangDeterministicBuilds [ "deterministic" ];
in
"[${lib.concatStringsSep "," options}]";
LANG = if stdenv.hostPlatform.isLinux then "C.UTF-8" else "C";
LC_CTYPE = if stdenv.hostPlatform.isLinux then "C.UTF-8" else "UTF-8";
postUnpack = ''
# Mix and Hex
export MIX_HOME="$TEMPDIR/mix"
export HEX_HOME="$TEMPDIR/hex"
# Rebar
export REBAR_GLOBAL_CONFIG_DIR="$TEMPDIR/rebar3"
export REBAR_CACHE_DIR="$TEMPDIR/rebar3.cache"
${lib.optionalString (mixFodDeps != null) ''
# Compilation of the dependencies will require that the dependency path is
# writable, thus a copy to the $TEMPDIR is inevitable here.
export MIX_DEPS_PATH="$TEMPDIR/deps"
cp --no-preserve=mode -R "${mixFodDeps}" "$MIX_DEPS_PATH"
''}
''
+ (attrs.postUnpack or "");
configurePhase =
attrs.configurePhase or ''
runHook preConfigure
${./mix-configure-hook.sh}
# This is needed for projects that have a specific compile step
# the dependency needs to be compiled in order for the task
# to be available.
#
# Phoenix projects for example will need compile.phoenix.
mix deps.compile --no-deps-check --skip-umbrella-children
# Symlink dependency sources. This is needed for projects that require
# access to the source of their dependencies. For example, Phoenix
# projects need javascript assets to build asset bundles.
${lib.optionalString (mixNixDeps != { }) ''
mkdir -p deps
${lib.concatMapStringsSep "\n" (dep: ''
dep_name=$(basename ${dep} | cut -d '-' -f2)
dep_path="deps/$dep_name"
if [ -d "${dep}/src" ]; then
ln -s ${dep}/src $dep_path
fi
'') (builtins.attrValues mixNixDeps)}
''}
# Symlink deps to build root. Similar to above, but allows for mixFodDeps
# Phoenix projects to find javascript assets.
${lib.optionalString (mixFodDeps != null) ''
ln -s "$MIX_DEPS_PATH" ./deps
''}
runHook postConfigure
'';
buildPhase =
attrs.buildPhase or ''
runHook preBuild
mix compile --no-deps-check ${lib.concatStringsSep " " compileFlags}
${lib.optionalString (escriptBinName != null) ''
mix escript.build --no-deps-check
''}
runHook postBuild
'';
installPhase =
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
'';
postFixup = ''
echo "removing files for Microsoft Windows"
rm -f "$out"/bin/*.bat
echo "wrapping programs in $out/bin with their runtime deps"
for f in $(find $out/bin/ -type f -executable); do
wrapProgram "$f" \
--prefix PATH : ${
lib.makeBinPath [
coreutils
gnused
gnugrep
gawk
]
}
done
''
+ lib.optionalString removeCookie ''
if [ -e $out/releases/COOKIE ]; then
echo "removing $out/releases/COOKIE"
rm $out/releases/COOKIE
fi
''
+ ''
if [ -e $out/erts-* ]; then
# ERTS is included in the release, then erlang is not required as a runtime dependency.
# But, erlang is still referenced in some places. To removed references to erlang,
# following steps are required.
# 1. remove references to erlang from plain text files
for file in $(rg "${erlang}/lib/erlang" "$out" --files-with-matches); do
echo "removing references to erlang in $file"
substituteInPlace "$file" --replace "${erlang}/lib/erlang" "$out"
done
# 2. remove references to erlang from .beam files
#
# No need to do anything, because it has been handled by "deterministic" option specified
# by ERL_COMPILER_OPTIONS.
# 3. remove references to erlang from normal binary files
for file in $(rg "${erlang}/lib/erlang" "$out" --files-with-matches --binary --iglob '!*.beam'); do
echo "removing references to erlang in $file"
# use bbe to substitute strings in binary files, because using substituteInPlace
# on binaries will raise errors
bbe -e "s|${erlang}/lib/erlang|$out|" -o "$file".tmp "$file"
rm -f "$file"
mv "$file".tmp "$file"
done
# References to erlang should be removed from output after above processing.
fi
''
+ lib.optionalString stripDebug ''
# Strip debug symbols to avoid hardreferences to "foreign" closures actually
# not needed at runtime, while at the same time reduce size of BEAM files.
erl -noinput -eval 'lists:foreach(fun(F) -> io:format("Stripping ~p.~n", [F]), beam_lib:strip(F) end, filelib:wildcard("'"$out"'/**/*.beam"))' -s init stop
'';
}
)

View File

@@ -0,0 +1,13 @@
{ lib, buildHex }:
buildHex {
name = "pc";
version = "1.15.0";
sha256 = "sha256-TA+tT2Q3yuNT1RfaIY/ng0e4/6RLmBeIdJTKquVFlbM=";
meta = {
description = "Rebar3 port compiler for native code";
license = lib.licenses.mit;
homepage = "https://github.com/blt/port_compiler";
};
}

View File

@@ -0,0 +1,44 @@
{
lib,
stdenv,
fetchFromGitHub,
buildRebar3,
}:
let
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
pkg =
self:
buildRebar3 {
name = "pgsql";
version = "25+beta.2";
src = fetchFromGitHub {
owner = "semiocast";
repo = "pgsql";
rev = "14f632bc89e464d82ce3ef12a67ed8c2adb5b60c";
sha256 = "17dcahiwlw61zhy8aq9rn46lwb35fb9q3372s4wmz01czm8c348w";
};
dontStrip = true;
meta = {
description = "Erlang PostgreSQL Driver";
license = lib.licenses.mit;
homepage = "https://github.com/semiocast/pgsql";
maintainers = with lib.maintainers; [ ericbmerritt ];
};
passthru = {
env = shell self;
};
};
in
lib.fix pkg

View File

@@ -0,0 +1,25 @@
{
lib,
buildRebar3,
fetchFromGitHub,
}:
buildRebar3 rec {
name = "rebar3_nix";
version = "0.1.1";
src = fetchFromGitHub {
owner = "erlang-nix";
repo = name;
rev = "v${version}";
sha256 = "10ijc06qvv5hqv0qy3w7mbv9pshdb8bvy0f3phr1vd5hksbk731y";
};
meta = {
description = "nix integration for rebar3";
license = lib.licenses.bsd3;
homepage = "https://github.com/erlang-nix/rebar3_nix";
maintainers = with lib.maintainers; [
dlesl
gleber
];
};
}

View File

@@ -0,0 +1,13 @@
{ lib, buildHex }:
buildHex {
name = "rebar3_proper";
version = "0.12.1";
sha256 = "1f174fb6h2071wr7qbw9aqqvnglzsjlylmyi8215fhrmi38w94b6";
meta = {
description = "rebar3 proper plugin";
license = lib.licenses.bsd3;
homepage = "https://github.com/ferd/rebar3_proper";
};
}

View File

@@ -0,0 +1,128 @@
{
stdenv,
erlang,
rebar3WithPlugins,
openssl,
lib,
}:
{
pname,
version,
src,
beamDeps ? [ ],
buildPlugins ? [ ],
checkouts ? null,
releaseType,
buildInputs ? [ ],
setupHook ? null,
profile ? "default",
installPhase ? null,
buildPhase ? null,
configurePhase ? null,
meta ? { },
...
}@attrs:
let
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.pname}";
buildInputs = [ drv ];
};
customPhases = lib.filterAttrs (_: v: v != null) {
inherit
setupHook
configurePhase
buildPhase
installPhase
;
};
# When using the `beamDeps` argument, it is important that we use
# `rebar3WithPlugins` here even when there are no plugins. The vanilla
# `rebar3` package is an escript archive with bundled dependencies which can
# interfere with those in the app we are trying to build. `rebar3WithPlugins`
# doesn't have this issue since it puts its own deps last on the code path.
rebar3 = rebar3WithPlugins {
plugins = buildPlugins;
};
pkg =
assert beamDeps != [ ] -> checkouts == null;
self:
stdenv.mkDerivation (
attrs
// {
name = "${pname}-${version}";
inherit version pname;
buildInputs =
buildInputs
++ [
erlang
rebar3
openssl
]
++ beamDeps;
# ensure we strip any native binaries (eg. NIFs, ports)
stripDebugList = lib.optional (releaseType == "release") "rel";
inherit src;
REBAR_IGNORE_DEPS = beamDeps != [ ];
configurePhase = ''
runHook preConfigure
${lib.optionalString (checkouts != null) "cp --no-preserve=all -R ${checkouts}/_checkouts ."}
runHook postConfigure
'';
buildPhase = ''
runHook preBuild
HOME=. DEBUG=1 rebar3 as ${profile} ${if releaseType == "escript" then "escriptize" else "release"}
runHook postBuild
'';
installPhase = ''
runHook preInstall
dir=${if releaseType == "escript" then "bin" else "rel"}
mkdir -p "$out/$dir" "$out/bin"
cp -R --preserve=mode "_build/${profile}/$dir" "$out"
${lib.optionalString (
releaseType == "release"
) "find $out/rel/*/bin -type f -executable -exec ln -s -t $out/bin {} \\;"}
runHook postInstall
'';
# Release will generate a binary which will cause a read null byte failure, see #261354
postInstall = lib.optionalString (releaseType == "escript") ''
for dir in $out/rel/*/erts-*; do
echo "ERTS found in $dir - removing references to erlang to reduce closure size"
for f in $dir/bin/{erl,start}; do
substituteInPlace "$f" --replace "${erlang}/lib/erlang" "''${dir/\/erts-*/}"
done
done
'';
meta = {
inherit (erlang.meta) platforms;
}
// meta;
passthru = (
{
packageName = pname;
env = shell self;
}
// (if attrs ? passthru then attrs.passthru else { })
);
}
// customPhases
);
in
lib.fix pkg

View File

@@ -0,0 +1,51 @@
{
lib,
stdenv,
fetchFromGitHub,
writeText,
erlang,
}:
let
shell =
drv:
stdenv.mkDerivation {
name = "interactive-shell-${drv.name}";
buildInputs = [ drv ];
};
pkg =
self:
stdenv.mkDerivation {
pname = "webdriver";
version = "0.pre+unstable=2015-02-08";
src = fetchFromGitHub {
owner = "Quviq";
repo = "webdrv";
rev = "7ceaf1f67d834e841ca0133b4bf899a9fa2db6bb";
sha256 = "1pq6pmlr6xb4hv2fvmlrvzd8c70kdcidlgjv4p8n9pwvkif0cb87";
};
setupHook = writeText "setupHook.sh" ''
addToSearchPath ERL_LIBS "$1/lib/erlang/lib/"
'';
buildInputs = [ erlang ];
installFlags = [ "PREFIX=$(out)/lib/erlang/lib" ];
meta = {
description = "WebDriver implementation in Erlang";
license = lib.licenses.mit;
homepage = "https://github.com/Quviq/webdrv";
maintainers = with lib.maintainers; [ ericbmerritt ];
};
passthru = {
env = shell self;
};
};
in
lib.fix pkg