summary refs log tree commit diff
path: root/pkgs/development/compilers/llvm/15/default.nix
diff options
context:
space:
mode:
authorRahul Butani <rrbutani@users.noreply.github.com>2023-01-27 14:51:38 -0800
committerRahul Butani <rrbutani@users.noreply.github.com>2023-01-27 14:51:38 -0800
commitd231d18e4aa5e1d00f86b4f484f9e4344538e3ea (patch)
tree411a5dd3e945b76a5af29f83806e7a86511c7e6a /pkgs/development/compilers/llvm/15/default.nix
parent8afa321b8ac7a52c479c5226364c48c544038c06 (diff)
downloadnixpkgs-d231d18e4aa5e1d00f86b4f484f9e4344538e3ea.tar
nixpkgs-d231d18e4aa5e1d00f86b4f484f9e4344538e3ea.tar.gz
nixpkgs-d231d18e4aa5e1d00f86b4f484f9e4344538e3ea.tar.bz2
nixpkgs-d231d18e4aa5e1d00f86b4f484f9e4344538e3ea.tar.lz
nixpkgs-d231d18e4aa5e1d00f86b4f484f9e4344538e3ea.tar.xz
nixpkgs-d231d18e4aa5e1d00f86b4f484f9e4344538e3ea.tar.zst
nixpkgs-d231d18e4aa5e1d00f86b4f484f9e4344538e3ea.zip
llvmPackages_15: expose the release information and monorepo source as overridable args
this makes it easier for users to use their own LLVM in nixpkgs
Diffstat (limited to 'pkgs/development/compilers/llvm/15/default.nix')
-rw-r--r--pkgs/development/compilers/llvm/15/default.nix71
1 files changed, 60 insertions, 11 deletions
diff --git a/pkgs/development/compilers/llvm/15/default.nix b/pkgs/development/compilers/llvm/15/default.nix
index 08647a736f1..db98f2854a0 100644
--- a/pkgs/development/compilers/llvm/15/default.nix
+++ b/pkgs/development/compilers/llvm/15/default.nix
@@ -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;