summary refs log tree commit diff
path: root/pkgs/servers
diff options
context:
space:
mode:
authortalyz <kim.lindberger@gmail.com>2020-10-05 15:58:44 +0200
committertalyz <kim.lindberger@gmail.com>2020-10-27 19:01:26 +0100
commit513599a6d783d2a76d5e0d9759d6b18ce4b9d71b (patch)
treec5c8b86007fe939badb1cb1c77aaa94ca8d0d32f /pkgs/servers
parentad9c8e6f048f6e2259d5626fdef892caae0c2cb3 (diff)
downloadnixpkgs-513599a6d783d2a76d5e0d9759d6b18ce4b9d71b.tar
nixpkgs-513599a6d783d2a76d5e0d9759d6b18ce4b9d71b.tar.gz
nixpkgs-513599a6d783d2a76d5e0d9759d6b18ce4b9d71b.tar.bz2
nixpkgs-513599a6d783d2a76d5e0d9759d6b18ce4b9d71b.tar.lz
nixpkgs-513599a6d783d2a76d5e0d9759d6b18ce4b9d71b.tar.xz
nixpkgs-513599a6d783d2a76d5e0d9759d6b18ce4b9d71b.tar.zst
nixpkgs-513599a6d783d2a76d5e0d9759d6b18ce4b9d71b.zip
nixos/keycloak: Init
Diffstat (limited to 'pkgs/servers')
-rw-r--r--pkgs/servers/keycloak/default.nix42
1 files changed, 34 insertions, 8 deletions
diff --git a/pkgs/servers/keycloak/default.nix b/pkgs/servers/keycloak/default.nix
index 614eb2a4679..c694b6a419f 100644
--- a/pkgs/servers/keycloak/default.nix
+++ b/pkgs/servers/keycloak/default.nix
@@ -1,5 +1,21 @@
-{ stdenv, fetchzip, makeWrapper, jre }:
-
+{ stdenv, fetchzip, makeWrapper, jre, writeText
+, postgresql_jdbc ? null
+}:
+
+let
+  mkModuleXml = name: jarFile: writeText "module.xml" ''
+    <?xml version="1.0" ?>
+    <module xmlns="urn:jboss:module:1.3" name="org.${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,12 +32,22 @@ 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/org
+    if ! [[ -d $module_path ]]; then
+        echo "The module path $module_path not found!"
+        exit 1
+    fi
+
+    ${if postgresql_jdbc != null then ''
+      mkdir -p $module_path/postgresql/main
+      ln -s ${postgresql_jdbc}/share/java/postgresql-jdbc.jar $module_path/postgresql/main
+      ln -s ${mkModuleXml "postgresql" "postgresql-jdbc.jar"} $module_path/postgresql/main/module.xml
+    '' else ""}
+
+    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}
   '';
 
   meta = with stdenv.lib; {
@@ -29,7 +55,7 @@ stdenv.mkDerivation rec {
     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 ];
   };
 
 }