summary refs log tree commit diff
path: root/pkgs/servers
diff options
context:
space:
mode:
authorKim Lindberger <kim.lindberger@gmail.com>2020-11-03 18:31:19 +0100
committerGitHub <noreply@github.com>2020-11-03 18:31:19 +0100
commitcf2d180a124284ccaaaae60ca928071eec9f0a1d (patch)
tree0114f718bdff4d58a90933f69fcfb237dd193b49 /pkgs/servers
parente90cfc722dceae9ac947e51fe33f66e972beb0ea (diff)
parent89e83833af35bd0ec3fdc65c435358a676a41d89 (diff)
downloadnixpkgs-cf2d180a124284ccaaaae60ca928071eec9f0a1d.tar
nixpkgs-cf2d180a124284ccaaaae60ca928071eec9f0a1d.tar.gz
nixpkgs-cf2d180a124284ccaaaae60ca928071eec9f0a1d.tar.bz2
nixpkgs-cf2d180a124284ccaaaae60ca928071eec9f0a1d.tar.lz
nixpkgs-cf2d180a124284ccaaaae60ca928071eec9f0a1d.tar.xz
nixpkgs-cf2d180a124284ccaaaae60ca928071eec9f0a1d.tar.zst
nixpkgs-cf2d180a124284ccaaaae60ca928071eec9f0a1d.zip
Merge pull request #99906 from talyz/keycloak
nixos/keycloak: Init
Diffstat (limited to 'pkgs/servers')
-rw-r--r--pkgs/servers/keycloak/default.nix47
1 files changed, 40 insertions, 7 deletions
diff --git a/pkgs/servers/keycloak/default.nix b/pkgs/servers/keycloak/default.nix
index 614eb2a4679..67d3d9bd45a 100644
--- a/pkgs/servers/keycloak/default.nix
+++ b/pkgs/servers/keycloak/default.nix
@@ -1,5 +1,21 @@
-{ stdenv, fetchzip, makeWrapper, jre }:
+{ stdenv, lib, fetchzip, makeWrapper, jre, writeText, nixosTests
+, postgresql_jdbc ? null, mysql_jdbc ? null
+}:
 
+let
+  mkModuleXml = name: jarFile: writeText "module.xml" ''
+    <?xml version="1.0" ?>
+    <module xmlns="urn:jboss:module:1.3" name="${name}">
+        <resources>
+            <resource-root path="${jarFile}"/>
+        </resources>
+        <dependencies>
+            <module name="javax.api"/>
+            <module name="javax.transaction.api"/>
+        </dependencies>
+    </module>
+  '';
+in
 stdenv.mkDerivation rec {
   pname   = "keycloak";
   version = "11.0.2";
@@ -16,20 +32,37 @@ stdenv.mkDerivation rec {
     cp -r * $out
 
     rm -rf $out/bin/*.{ps1,bat}
-    rm -rf $out/bin/add-user-keycloak.sh
-    rm -rf $out/bin/jconsole.sh
 
-    chmod +x $out/bin/standalone.sh
-    wrapProgram $out/bin/standalone.sh \
-      --prefix PATH ":" ${jre}/bin ;
+    module_path=$out/modules/system/layers/keycloak
+    if ! [[ -d $module_path ]]; then
+        echo "The module path $module_path not found!"
+        exit 1
+    fi
+
+    ${lib.optionalString (postgresql_jdbc != null) ''
+      mkdir -p $module_path/org/postgresql/main
+      ln -s ${postgresql_jdbc}/share/java/postgresql-jdbc.jar $module_path/org/postgresql/main/
+      ln -s ${mkModuleXml "org.postgresql" "postgresql-jdbc.jar"} $module_path/org/postgresql/main/module.xml
+    ''}
+    ${lib.optionalString (mysql_jdbc != null) ''
+      mkdir -p $module_path/com/mysql/main
+      ln -s ${mysql_jdbc}/share/java/mysql-connector-java.jar $module_path/com/mysql/main/
+      ln -s ${mkModuleXml "com.mysql" "mysql-connector-java.jar"} $module_path/com/mysql/main/module.xml
+    ''}
+
+    wrapProgram $out/bin/standalone.sh --set JAVA_HOME ${jre}
+    wrapProgram $out/bin/add-user-keycloak.sh --set JAVA_HOME ${jre}
+    wrapProgram $out/bin/jboss-cli.sh --set JAVA_HOME ${jre}
   '';
 
+  passthru.tests = nixosTests.keycloak;
+
   meta = with stdenv.lib; {
     homepage    = "https://www.keycloak.org/";
     description = "Identity and access management for modern applications and services";
     license     = licenses.asl20;
     platforms   = jre.meta.platforms;
-    maintainers = [ maintainers.ngerstle ];
+    maintainers = with maintainers; [ ngerstle talyz ];
   };
 
 }