Skip to content

Commit

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

this makes it easier for users to use their own LLVM in nixpkgs
  • Loading branch information
rrbutani committed Jan 27, 2023
1 parent 8afa321 commit d231d18
Showing 1 changed file with 60 additions and 11 deletions.
71 changes: 60 additions & 11 deletions pkgs/development/compilers/llvm/15/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,73 @@
then null
else pkgs.bintools
, darwin
# LLVM release information; specify one of these but not both:
, gitRelease ? null
# 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 ? { version = "15.0.7"; sha256 = "sha256-wjuZQyXQ/jsmvy6y1aksCcEDXGBjuhpgngF3XQJ/T4s="; }
# 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.7";
candidate = ""; # empty or "rcN"
dash-candidate = lib.optionalString (candidate != "") "-${candidate}";
rev = ""; # When using a Git commit
rev-version = ""; # 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 = "sha256-wjuZQyXQ/jsmvy6y1aksCcEDXGBjuhpgngF3XQJ/T4s=";
inherit rev sha256;
};

inherit (releaseInfo) release_version version;

llvm_meta = {
license = with lib.licenses; [ ncsa llvm-exception ];
maintainers = lib.teams.llvm.members;
Expand Down

0 comments on commit d231d18

Please sign in to comment.