Skip to content

Commit

Permalink
llvmPackages_git: expose the release information and monorepo source …
Browse files Browse the repository at this point in the history
…as overridable args

backport of d231d18 from #194634
(llvmPackages_15)
  • Loading branch information
rrbutani committed Apr 3, 2023
1 parent f74a6ce commit 20674e4
Showing 1 changed file with 65 additions and 12 deletions.
77 changes: 65 additions & 12 deletions pkgs/development/compilers/llvm/git/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,77 @@
then null
else pkgs.bintools
, darwin
# LLVM release information; specify one of these but not both:
, gitRelease ? {
version = "15.0.0";
rev = "a5640968f2f7485b2aa4919f5fa68fd8f23e2d1f";
rev-version = "unstable-2022-26-07";
sha256 = "1sh5xihdfdn2hp7ds3lkaq1bfrl4alj36gl1aidmhlw65p5rdvl7";
}
# i.e.:
# {
# version = /* i.e. "15.0.0" */;
# rev = /* commit SHA */;
# rev-version = /* human readable version; i.e. "unstable-2022-26-07" */;
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
# }
, officialRelease ? null
# i.e.:
# {
# version = /* i.e. "15.0.0" */;
# candidate = /* optional; if specified, should be: "rcN" */
# sha256 = /* checksum for this release, can omit if specifying your own `monorepoSrc` */;
# }
# By default, we'll try to fetch a release from `github:llvm/llvm-project`
# corresponding to the `gitRelease` or `officialRelease` specified.
#
# You can provide your own LLVM source by specifying this arg but then it's up
# to you to make sure that the LLVM repo given matches the release configuration
# specified.
, monorepoSrc ? null
}:

assert let
int = a: if a then 1 else 0;
xor = a: b: ((builtins.bitXor (int a) (int b)) == 1);
in
lib.assertMsg
(xor
(gitRelease != null)
(officialRelease != null))
("must specify `gitRelease` or `officialRelease`" +
(lib.optionalString (gitRelease != null) " — not both"));
let
release_version = "15.0.0";
candidate = ""; # empty or "rcN"
dash-candidate = lib.optionalString (candidate != "") "-${candidate}";
rev = "a5640968f2f7485b2aa4919f5fa68fd8f23e2d1f"; # When using a Git commit
rev-version = "unstable-2022-26-07"; # When using a Git commit
version = if rev != "" then rev-version else "${release_version}${dash-candidate}";
targetConfig = stdenv.targetPlatform.config;

monorepoSrc = fetchFromGitHub {
monorepoSrc' = monorepoSrc;
in let
releaseInfo = if gitRelease != null then rec {
original = gitRelease;
release_version = original.version;
version = gitRelease.rev-version;
} else rec {
original = officialRelease;
release_version = original.version;
version = if original ? candidate then
"${release_version}-${original.candidate}"
else
release_version;
};

monorepoSrc = if monorepoSrc' != null then
monorepoSrc'
else let
sha256 = releaseInfo.original.sha256;
rev = if gitRelease != null then
gitRelease.rev
else
"llvmorg-${releaseInfo.version}";
in fetchFromGitHub {
owner = "llvm";
repo = "llvm-project";
rev = if rev != "" then rev else "llvmorg-${version}";
sha256 = "1sh5xihdfdn2hp7ds3lkaq1bfrl4alj36gl1aidmhlw65p5rdvl7";
inherit rev sha256;
};

inherit (releaseInfo) release_version version;

llvm_meta = {
license = lib.licenses.ncsa;
maintainers = lib.teams.llvm.members;
Expand Down

0 comments on commit 20674e4

Please sign in to comment.