about summary refs log tree commit diff
path: root/third_party/apereo-cas/default.nix
diff options
context:
space:
mode:
authorLuke Granger-Brown <git@lukegb.com>2020-07-05T19·08+0000
committerlukegb <lukegb@tvl.fyi>2020-07-05T22·42+0000
commit1915fbccd69c102cde4239285ebcb4c9ca9f9322 (patch)
treea279ebc0867a6cf0c91156ab9b1432483a67bddd /third_party/apereo-cas/default.nix
parent4b9fde0abe01bb09e0c30402ce89ff02bc0afb49 (diff)
feat(3p/apereo-cas): initial Nix derivation (no TVL-specific config yet) r/1219
Change-Id: Ie7d52370dd554b110bbfa041b943fcf246373b94
Reviewed-on: https://cl.tvl.fyi/c/depot/+/933
Tested-by: BuildkiteCI
Reviewed-by: tazjin <mail@tazj.in>
Diffstat (limited to 'third_party/apereo-cas/default.nix')
-rw-r--r--third_party/apereo-cas/default.nix63
1 files changed, 63 insertions, 0 deletions
diff --git a/third_party/apereo-cas/default.nix b/third_party/apereo-cas/default.nix
new file mode 100644
index 000000000000..5f628ce8e709
--- /dev/null
+++ b/third_party/apereo-cas/default.nix
@@ -0,0 +1,63 @@
+{ pkgs, ... }:
+
+let
+  name = "apereo-cas-${version}";
+  version = "6.2.0";
+  overlay = ./overlay;
+
+  jdk = pkgs.jdk11;
+  gradle = pkgs.gradle_6;
+
+  meta = with pkgs.stdenvNoCC.lib; {
+    homepage = "https://www.apereo.org/projects/cas";
+    description = "CAS provides enterprise single sign-on for the Web";
+    platforms = platforms.linux;
+    licenses = licenses.asl20;
+  };
+
+  deps = pkgs.stdenvNoCC.mkDerivation {
+    inherit meta;
+
+    name = "${name}-deps";
+    src = overlay;
+    nativeBuildInputs = with pkgs; [ gradle perl ];
+
+    buildPhase = ''
+      export GRADLE_USER_HOME="$(mktemp -d)"
+      gradle --no-daemon build -x test downloadShell
+    '';
+
+    # perl code mavenizes paths (see pkgs/servers/ma1sd from nixpkgs)
+    installPhase = ''
+      find $GRADLE_USER_HOME/caches/modules-2 -type f -regex '.*\.\([wj]ar\|pom\)' \
+        | perl -pe 's#(.*/([^/]+)/([^/]+)/([^/]+)/[0-9a-f]{30,40}/([^/\s]+))$# $src = $1; ($x = $2) =~ tr|\.|/|; $dir1 = $3; $dir2 = $4; ($y = $5) =~ s|-jvm||n; "install -Dm444 $src \$out/$x/$dir1/$dir2/$y" #e' \
+        | sh
+      install -m444 build/libs/cas-server-support-shell-* $out/cas-server-shell.jar
+    '';
+
+    outputHashAlgo = "sha256";
+    outputHashMode = "recursive";
+    outputHash = "0lggx83g0nl5xwxgadgjrz62ch5qkwcyxwrd1zq8y1r7fir3m8pq";
+  };
+in
+pkgs.stdenvNoCC.mkDerivation {
+  inherit name version meta;
+
+  src = overlay;
+  nativeBuildInputs = with pkgs; [ gradle makeWrapper ];
+  buildInputs = with pkgs; [ jdk ];
+
+  buildPhase = ''
+    export GRADLE_USER_HOME="$(mktemp -d)"
+
+    gradle -PcacheLocation="${deps}" --offline --no-daemon build -x test
+  '';
+
+  installPhase = ''
+    install -D build/libs/cas.war $out/lib/cas.war
+    cp ${deps}/cas-server-shell.jar $out/lib/cas-server-shell.jar
+    cp -R etc $out/etc
+    makeWrapper ${jdk}/bin/java $out/bin/cas --add-flags "-Dcas.standalone.configurationDirectory=$out/etc/cas/config -jar $out/lib/cas.war"
+    makeWrapper ${jdk}/bin/java $out/bin/cas-shell --add-flags "-Dcas.standalone.configurationDirectory=$out/etc/cas/config -jar $out/lib/cas-server-shell.jar"
+  '';
+}