gnu: elixir: Add vendoring support.

* gnu/packages/elixir.scm (elixir): Add vendoring support.
* gnu/packages/patches/elixir-vendoring-support.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.

Change-Id: Id295ac66684c724ac799878ec58d84617bf9a5be
Signed-off-by: Giacomo Leidi <therewasa@fishinthecalculator.me>
This commit is contained in:
Igorj Gorjaĉev
2025-10-22 01:36:34 +03:00
committed by Giacomo Leidi
parent 023b344a41
commit f88a63b636
3 changed files with 59 additions and 1 deletions

View File

@@ -1228,6 +1228,7 @@ dist_patch_DATA = \
%D%/packages/patches/elfutils-tests-ptrace.patch \
%D%/packages/patches/elixir-httpoison-tag-network-dependent-test-cases.patch \
%D%/packages/patches/elixir-path-length.patch \
%D%/packages/patches/elixir-vendoring-support.patch \
%D%/packages/patches/elm-ghc9.2.patch \
%D%/packages/patches/exaile-gstreamer-1.28.patch \
%D%/packages/patches/python-treelib-remove-python2-compat.patch \

View File

@@ -51,7 +51,8 @@
(file-name (git-file-name name version))
(sha256
(base32 "1i10a5d7mlcrav47k7qirqvrqn2kbl5265fbcp8fzavr86xz67m6"))
(patches (search-patches "elixir-path-length.patch"))))
(patches (search-patches "elixir-path-length.patch"
"elixir-vendoring-support.patch"))))
(build-system gnu-build-system)
(arguments
(list

View File

@@ -0,0 +1,56 @@
Author: Igorj Gorjaĉev <igor@goryachev.org>
Date: Wed Oct 22 10:10:13 2025 +0300
vendoring support for guix
diff --git a/lib/mix/lib/mix/dep/loader.ex b/lib/mix/lib/mix/dep/loader.ex
index e47bfc556..0ddd49fe5 100644
--- a/lib/mix/lib/mix/dep/loader.ex
+++ b/lib/mix/lib/mix/dep/loader.ex
@@ -198,6 +198,10 @@ defp with_scm_and_app(app, req, opts, original, locked?) do
)
end
+ scm = Mix.Guix.scm(scm)
+ req = Mix.Guix.req(req)
+ opts = Mix.Guix.opts(opts, app)
+
%Mix.Dep{
scm: scm,
app: app,
diff --git a/lib/mix/lib/mix/guix.ex b/lib/mix/lib/mix/guix.ex
new file mode 100644
index 000000000..9c821704c
--- /dev/null
+++ b/lib/mix/lib/mix/guix.ex
@@ -0,0 +1,30 @@
+defmodule Mix.Guix do
+ @moduledoc false
+
+ @guix_vendorize "GUIX_MIX_VENDOR_DIR"
+
+ def scm(scm), do: (vendorize?() && Mix.SCM.Path) || scm
+
+ def req(req), do: (vendorize?() && nil) || req
+
+ def opts(opts, app) do
+ if vendorize?() do
+ if Keyword.has_key?(opts, :path) do
+ opts
+ else
+ dep_dir = vendor_dep_dir(app)
+
+ [path: dep_dir, dest: dep_dir] ++
+ Keyword.drop(opts, [:hex, :override, :repo, :lock, :dest])
+ end
+ else
+ opts
+ end
+ end
+
+ defp vendorize?, do: not is_nil(vendor_dir())
+
+ defp vendor_dir, do: System.get_env(@guix_vendorize)
+
+ defp vendor_dep_dir(name), do: "#{vendor_dir()}/#{name}"
+end