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,179 @@
{
lib,
stdenv,
fetchFromGitHub,
fetchgit,
fetchHex,
erlang,
makeWrapper,
writeScript,
common-updater-scripts,
coreutils,
git,
gnused,
nix,
nixfmt,
rebar3-nix,
}:
let
version = "3.25.1";
owner = "erlang";
deps = import ./rebar-deps.nix { inherit fetchFromGitHub fetchgit fetchHex; };
rebar3 = stdenv.mkDerivation rec {
pname = "rebar3";
inherit version erlang;
# How to obtain `sha256`:
# nix-prefetch-url --unpack https://github.com/erlang/rebar3/archive/${version}.tar.gz
src = fetchFromGitHub {
inherit owner;
repo = pname;
rev = version;
sha256 = "Wpg8MDVwum/cBpwbcY3Cjt2JkuQHEp7wxbZKgyP6crc=";
};
buildInputs = [ erlang ];
postPatch = ''
mkdir -p _checkouts _build/default/lib/
${toString (
lib.mapAttrsToList (k: v: ''
cp -R --no-preserve=mode ${v} _checkouts/${k}
'') deps
)}
# Bootstrap script expects the dependencies in _build/default/lib
# TODO: Make it accept checkouts?
for i in _checkouts/* ; do
ln -s $(pwd)/$i $(pwd)/_build/default/lib/
done
'';
buildPhase = ''
HOME=. escript bootstrap
'';
checkPhase = ''
HOME=. escript ./rebar3 ct
'';
doCheck = true;
installPhase = ''
mkdir -p $out/bin
cp rebar3 $out/bin/rebar3
'';
meta = {
homepage = "https://github.com/rebar/rebar3";
description = "Erlang build tool that makes it easy to compile and test Erlang applications, port drivers and releases";
mainProgram = "rebar3";
longDescription = ''
rebar is a self-contained Erlang script, so it's easy to distribute or
even embed directly in a project. Where possible, rebar uses standard
Erlang/OTP conventions for project structures, thus minimizing the amount
of build configuration work. rebar also provides dependency management,
enabling application writers to easily re-use common libraries from a
variety of locations (hex.pm, git, hg, and so on).
'';
platforms = lib.platforms.unix;
teams = [ lib.teams.beam ];
license = lib.licenses.asl20;
};
passthru.updateScript = writeScript "update.sh" ''
#!${stdenv.shell}
set -ox errexit
PATH=${
lib.makeBinPath [
common-updater-scripts
coreutils
git
gnused
nix
nixfmt
(rebar3WithPlugins { globalPlugins = [ rebar3-nix ]; })
]
}
latest=$(list-git-tags | sed -n '/[\d\.]\+/p' | sort -V | tail -1)
if [ "$latest" != "${version}" ]; then
nixpkgs="$(git rev-parse --show-toplevel)"
nix_path="$nixpkgs/pkgs/development/tools/build-managers/rebar3"
update-source-version rebar3 "$latest" --version-key=version --print-changes --file="$nix_path/default.nix"
tmpdir=$(mktemp -d)
cp -R $(nix-build $nixpkgs --no-out-link -A rebar3.src)/* "$tmpdir"
(cd "$tmpdir" && rebar3 as test nix lock -o "$nix_path/rebar-deps.nix")
nixfmt "$nix_path/rebar-deps.nix"
else
echo "rebar3 is already up-to-date"
fi
'';
};
# Alias rebar3 so we can use it as default parameter below
_rebar3 = rebar3;
rebar3WithPlugins =
{
plugins ? [ ],
globalPlugins ? [ ],
rebar3 ? _rebar3,
}:
let
pluginLibDirs = map (p: "${p}/lib/erlang/lib") (lib.unique (plugins ++ globalPlugins));
globalPluginNames = lib.unique (map (p: p.packageName) globalPlugins);
rebar3Patched = (
rebar3.overrideAttrs (old: {
# skip-plugins.patch is necessary because otherwise rebar3 will always
# try to fetch plugins if they are not already present in _build.
#
# global-deps.patch makes it possible to use REBAR_GLOBAL_PLUGINS to
# instruct rebar3 to always load a certain plugin. It is necessary since
# REBAR_GLOBAL_CONFIG_DIR doesn't seem to work for this.
patches = [
./skip-plugins.patch
./global-plugins.patch
];
# our patches cause the tests to fail
doCheck = false;
})
);
in
stdenv.mkDerivation {
pname = "rebar3-with-plugins";
inherit (rebar3) version;
nativeBuildInputs = [
erlang
makeWrapper
];
unpackPhase = "true";
# Here we extract the rebar3 escript (like `rebar3_prv_local_install.erl`) and
# add plugins to the code path.
installPhase = ''
erl -noshell -eval '
{ok, Escript} = escript:extract("${rebar3Patched}/bin/rebar3", []),
{archive, Archive} = lists:keyfind(archive, 1, Escript),
{ok, _} = zip:extract(Archive, [{cwd, "'$out/lib'"}]),
init:stop(0)
'
cp ${./rebar_ignore_deps.erl} rebar_ignore_deps.erl
erlc -o $out/lib/rebar/ebin rebar_ignore_deps.erl
mkdir -p $out/bin
makeWrapper ${erlang}/bin/erl $out/bin/rebar3 \
--set REBAR_GLOBAL_PLUGINS "${toString globalPluginNames} rebar_ignore_deps" \
--suffix-each ERL_LIBS ":" "$out/lib ${toString pluginLibDirs}" \
--add-flags "+sbtu +A1 -noshell -boot start_clean -s rebar3 main -extra"
'';
};
in
{
inherit rebar3 rebar3WithPlugins;
}

View File

@@ -0,0 +1,14 @@
diff --git a/apps/rebar/src/rebar_plugins.erl b/apps/rebar/src/rebar_plugins.erl
index 469be42e..3a901cbe 100644
--- a/apps/rebar/src/rebar_plugins.erl
+++ b/apps/rebar/src/rebar_plugins.erl
@@ -31,7 +31,8 @@ project_plugins_install(State) ->
top_level_install(State) ->
Profiles = rebar_state:current_profiles(State),
lists:foldl(fun(Profile, StateAcc) ->
- Plugins = rebar_state:get(State, {plugins, Profile}, []),
+ Plugins = rebar_state:get(State, {plugins, Profile}, [])
+ ++ [list_to_atom(P) || P <- string:lexemes(os:getenv("REBAR_GLOBAL_PLUGINS", ""), " ")],
handle_plugins(Profile, Plugins, StateAcc)
end, State, Profiles).

View File

@@ -0,0 +1,27 @@
# Generated by rebar3_nix
let
fetchOnly = { src, ... }: src;
in
{
builder ? fetchOnly,
fetchHex,
fetchgit,
fetchFromGitHub,
overrides ? (x: y: { }),
}:
let
self = packages // (overrides self packages);
packages = {
meck = builder {
name = "meck";
version = "0.8.13";
src = fetchHex {
pkg = "meck";
version = "0.8.13";
sha256 = "sha256-008BPBVttRrVfMVWiRuXIOahwd9f4uFa+ZnITWzr6xo=";
};
beamDeps = [ ];
};
};
in
self

View File

@@ -0,0 +1,43 @@
%% This module, when loaded as a plugin, overrides the default `install_deps`
%% provider and erases the dependencies from the rebar3 state, when
%% REBAR_IGNORE_DEPS is true.
-module(rebar_ignore_deps).
-export([init/1, do/1, format_error/1]).
init(State0) ->
case os:getenv("REBAR_IGNORE_DEPS", "") of
"" ->
{ok, State0};
_ ->
do_init(State0)
end.
do_init(State0) ->
State1 = rebar_state:allow_provider_overrides(State0, true),
Provider = providers:create(
[
{name, install_deps}, %% override the default install_deps provider
{module, ?MODULE},
{bare, false},
{deps, [app_discovery]},
{example, undefined},
{opts, []},
{short_desc, ""},
{desc, ""}
]),
State2 = rebar_state:add_provider(State1, Provider),
{ok, rebar_state:allow_provider_overrides(State2, false)}.
do(State0) ->
io:format("Ignoring deps...~n"),
Profiles = rebar_state:current_profiles(State0),
State = lists:foldl(fun(P, Acc0) ->
Acc = rebar_state:set(Acc0, {deps, P}, []),
rebar_state:set(Acc, {parsed_deps, P}, [])
end, State0, Profiles),
{ok, State}.
format_error(Reason) ->
io_lib:format("~p", [Reason]).

View File

@@ -0,0 +1,80 @@
diff --git a/apps/rebar/src/rebar_plugins.erl b/apps/rebar/src/rebar_plugins.erl
index cd5f377c..469be42e 100644
--- a/apps/rebar/src/rebar_plugins.erl
+++ b/apps/rebar/src/rebar_plugins.erl
@@ -108,41 +108,9 @@ handle_plugins(Profile, Plugins, State, Upgrade) ->
State3 = rebar_state:set(State2, deps_dir, DepsDir),
rebar_state:lock(State3, Locks).
-handle_plugin(Profile, Plugin, State, SrcPlugins, Upgrade) ->
+handle_plugin(_Profile, Plugin, State, _SrcPlugins, _Upgrade) ->
try
- %% Inject top-level src plugins as project apps, so that they get skipped
- %% by the installation as already seen
- ProjectApps = rebar_state:project_apps(State),
- State0 = rebar_state:project_apps(State, SrcPlugins),
- %% We however have to pick the deps of top-level apps and promote them
- %% directly to make sure they are installed if they were not also at the top level
- TopDeps = top_level_deps(State, SrcPlugins),
- %% Install the plugins
- {Apps, State1} = rebar_prv_install_deps:handle_deps_as_profile(Profile, State0, [Plugin|TopDeps], Upgrade),
- {no_cycle, Sorted} = rebar_prv_install_deps:find_cycles(SrcPlugins++Apps),
- ToBuild = rebar_prv_install_deps:cull_compile(Sorted, []),
- %% Return things to normal
- State2 = rebar_state:project_apps(State1, ProjectApps),
-
- %% Add already built plugin deps to the code path
- ToBuildPaths = [rebar_app_info:ebin_dir(A) || A <- ToBuild],
- PreBuiltPaths = [Ebin || A <- Sorted,
- Ebin <- [rebar_app_info:ebin_dir(A)],
- not lists:member(Ebin, ToBuildPaths)],
- code:add_pathsa(PreBuiltPaths),
-
- %% Build plugin and its deps
- build_plugins(ToBuild, Sorted, State2),
-
- %% Add newly built deps and plugin to code path
- State3 = rebar_state:update_all_plugin_deps(State2, Sorted),
- NewCodePaths = [rebar_app_info:ebin_dir(A) || A <- ToBuild],
-
- %% Store plugin code paths so we can remove them when compiling project apps
- State4 = rebar_state:update_code_paths(State3, all_plugin_deps, PreBuiltPaths++NewCodePaths),
- rebar_paths:set_paths([plugins], State4),
-
- {plugin_providers(Plugin), State4}
+ {plugin_providers(Plugin), State}
catch
?WITH_STACKTRACE(C,T,S)
?DEBUG("~p ~p ~p", [C, T, S]),
@@ -150,15 +118,6 @@ handle_plugin(Profile, Plugin, State, SrcPlugins, Upgrade) ->
{[], State}
end.
-build_plugins(MustBuildApps, AllApps, State) ->
- State1 = rebar_state:deps_to_build(State, MustBuildApps),
- State2 = rebar_state:all_deps(State1, AllApps),
- State3 = rebar_state:set(State2, deps_dir, ?DEFAULT_PLUGINS_DIR),
- {Args, Extra} = rebar_state:command_parsed_args(State),
- State4 = rebar_state:command_parsed_args(State3, {[{deps_only, true}|Args], Extra}),
- rebar_prv_compile:do(State4),
- ok.
-
plugin_providers({Plugin, _, _, _}) when is_atom(Plugin) ->
validate_plugin(Plugin);
plugin_providers({Plugin, _, _}) when is_atom(Plugin) ->
@@ -251,15 +210,6 @@ prepare_plugin(AppInfo) ->
false -> rebar_app_info:valid(Relocated, undefined) % force revalidation
end.
-top_level_deps(State, Apps) ->
- CurrentProfiles = rebar_state:current_profiles(State),
- Keys = lists:append([[{plugins, P}, {deps, P}] || P <- CurrentProfiles]),
- RawDeps = lists:foldl(fun(App, Acc) ->
- %% Only support the profiles we would with regular plugins?
- lists:append([rebar_app_info:get(App, Key, []) || Key <- Keys]) ++ Acc
- end, [], Apps),
- rebar_utils:tup_dedup(RawDeps).
-
needs_rebuild(AppInfo) ->
%% if source files are newer than built files then the code was edited
%% and can't be considered valid -- force a rebuild.