2020-11-06 00:33:48 +00:00
|
|
|
{ stdenv, lib, fetchzip, makeWrapper, jre, writeText, nixosTests
|
|
|
|
, postgresql_jdbc ? null, mysql_jdbc ? null
|
|
|
|
}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
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
|
2020-04-24 23:36:52 +00:00
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "keycloak";
|
2022-01-19 23:45:15 +00:00
|
|
|
version = "16.1.0";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
src = fetchzip {
|
2021-02-05 17:12:51 +00:00
|
|
|
url = "https://github.com/keycloak/keycloak/releases/download/${version}/keycloak-${version}.zip";
|
2022-01-19 23:45:15 +00:00
|
|
|
sha256 = "sha256-QVFu3f+mwafoNUttLEVMdoZHMJjjH/TpZAGV7ZvIvh0=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
cp -r * $out
|
|
|
|
|
|
|
|
rm -rf $out/bin/*.{ps1,bat}
|
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
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}
|
2020-04-24 23:36:52 +00:00
|
|
|
'';
|
|
|
|
|
2020-11-06 00:33:48 +00:00
|
|
|
passthru.tests = nixosTests.keycloak;
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
homepage = "https://www.keycloak.org/";
|
|
|
|
description = "Identity and access management for modern applications and services";
|
|
|
|
license = licenses.asl20;
|
|
|
|
platforms = jre.meta.platforms;
|
2020-11-06 00:33:48 +00:00
|
|
|
maintainers = with maintainers; [ ngerstle talyz ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|