nixpkgs/pkgs/servers/keycloak/default.nix

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

75 lines
2.4 KiB
Nix
Raw Normal View History

{ stdenv, lib, fetchzip, makeWrapper, jre, writeText, nixosTests
, postgresql_jdbc ? null, mysql_jdbc ? null
2021-10-03 20:08:59 +02:00
, callPackage
2020-10-05 15:58:44 +02:00
}:
let
mkModuleXml = name: jarFile: writeText "module.xml" ''
<?xml version="1.0" ?>
<module xmlns="urn:jboss:module:1.3" name="${name}">
2020-10-05 15:58:44 +02:00
<resources>
<resource-root path="${jarFile}"/>
</resources>
<dependencies>
<module name="javax.api"/>
<module name="javax.transaction.api"/>
</dependencies>
</module>
'';
in
2020-02-25 08:00:40 +01:00
stdenv.mkDerivation rec {
pname = "keycloak";
2022-03-31 19:35:57 +02:00
version = "17.0.1";
2020-02-25 08:00:40 +01:00
src = fetchzip {
2022-03-31 19:35:57 +02:00
url = "https://github.com/keycloak/keycloak/releases/download/${version}/keycloak-legacy-${version}.zip";
sha256 = "sha256-oqANNk7T6+CAS818v3I1QNsuxetL/JFZMqxouRn+kdE=";
2020-02-25 08:00:40 +01:00
};
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
mkdir $out
cp -r * $out
rm -rf $out/bin/*.{ps1,bat}
module_path=$out/modules/system/layers/keycloak
2020-10-05 15:58:44 +02:00
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
''}
2020-10-05 15:58:44 +02:00
for script in add-user-keycloak.sh add-user.sh domain.sh elytron-tool.sh jboss-cli.sh jconsole.sh jdr.sh standalone.sh wsconsume.sh wsprovide.sh; do
wrapProgram $out/bin/$script --set JAVA_HOME ${jre}
done
wrapProgram $out/bin/kcadm.sh --prefix PATH : ${jre}/bin
wrapProgram $out/bin/kcreg.sh --prefix PATH : ${jre}/bin
2020-02-25 08:00:40 +01:00
'';
2021-10-03 20:08:59 +02:00
passthru = {
tests = nixosTests.keycloak;
plugins = callPackage ./all-plugins.nix {};
};
2020-10-13 11:44:02 +02:00
meta = with lib; {
2020-02-25 08:00:40 +01:00
homepage = "https://www.keycloak.org/";
description = "Identity and access management for modern applications and services";
license = licenses.asl20;
2020-03-27 10:20:00 +01:00
platforms = jre.meta.platforms;
2020-10-05 15:58:44 +02:00
maintainers = with maintainers; [ ngerstle talyz ];
2020-02-25 08:00:40 +01:00
};
}