Skip to content

Commit

Permalink
elixir: add maximumOTPVersion assertion (NixOS#367986)
Browse files Browse the repository at this point in the history
  • Loading branch information
happysalada authored Dec 24, 2024
2 parents 5cd56af + 1e73e22 commit e86d0c5
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 3 deletions.
1 change: 1 addition & 0 deletions pkgs/development/interpreters/elixir/1.14.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
1 change: 1 addition & 0 deletions pkgs/development/interpreters/elixir/1.15.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
1 change: 1 addition & 0 deletions pkgs/development/interpreters/elixir/1.16.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
30 changes: 27 additions & 3 deletions pkgs/development/interpreters/elixir/generic-builder.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
version,
erlang ? inputs.erlang,
minimumOTPVersion,
maximumOTPVersion ? null,
sha256 ? null,
rev ? "v${version}",
src ? fetchFromGitHub {
Expand All @@ -28,14 +29,37 @@

let
inherit (lib)
assertMsg
concatStringsSep
getVersion
versionAtLeast
optional
concatStringsSep
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}";
Expand Down

0 comments on commit e86d0c5

Please sign in to comment.