elixir: add maximumOTPVersion assertion

This commit is contained in:
Adam C. Stephens
2024-12-24 14:35:26 -05:00
parent 371e69dcca
commit 1e73e22f30
4 changed files with 31 additions and 4 deletions

View File

@@ -5,4 +5,5 @@ mkDerivation {
sha256 = "sha256-bCCTjFT+FG1hz+0H6k/izbCmi0JgO3Kkqc3LWWCs5Po=";
# https://hexdocs.pm/elixir/1.14.5/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp
minimumOTPVersion = "23";
maximumOTPVersion = "26";
}

View File

@@ -4,5 +4,6 @@ mkDerivation {
sha256 = "sha256-6GfZycylh+sHIuiQk/GQr1pRQRY1uBycSQdsVJ0J13k=";
# https://hexdocs.pm/elixir/1.15.0/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp
minimumOTPVersion = "24";
maximumOTPVersion = "26";
escriptPath = "lib/elixir/scripts/generate_app.escript";
}

View File

@@ -4,5 +4,6 @@ mkDerivation {
sha256 = "sha256-WUBqoz3aQvBlSG3pTxGBpWySY7I0NUcDajQBgq5xYTU=";
# https://hexdocs.pm/elixir/1.16.0/compatibility-and-deprecations.html#compatibility-between-elixir-and-erlang-otp
minimumOTPVersion = "24";
maximumOTPVersion = "26";
escriptPath = "lib/elixir/scripts/generate_app.escript";
}

View File

@@ -16,6 +16,7 @@
version,
erlang ? inputs.erlang,
minimumOTPVersion,
maximumOTPVersion ? null,
sha256 ? null,
rev ? "v${version}",
src ? fetchFromGitHub {
@@ -28,14 +29,37 @@
let
inherit (lib)
getVersion
versionAtLeast
optional
assertMsg
concatStringsSep
getVersion
optional
optionalString
toInt
versions
versionAtLeast
versionOlder
;
compatibilityMsg = ''
Unsupported elixir and erlang OTP combination.
elixir ${version}
erlang OTP ${getVersion erlang} is not >= ${minimumOTPVersion} ${
optionalString (maximumOTPVersion != null) "and <= ${maximumOTPVersion}"
}
See https://hexdocs.pm/elixir/${version}/compatibility-and-deprecations.html
'';
maxShiftMajor = builtins.toString ((toInt (versions.major maximumOTPVersion)) + 1);
maxAssert =
if (maximumOTPVersion == null) then
true
else
versionOlder (versions.major (getVersion erlang)) maxShiftMajor;
in
assert versionAtLeast (getVersion erlang) minimumOTPVersion;
assert assertMsg (versionAtLeast (getVersion erlang) minimumOTPVersion) compatibilityMsg;
assert assertMsg maxAssert compatibilityMsg;
stdenv.mkDerivation ({
pname = "${baseName}";