4a7f99d55d
Part of: https://github.com/NixOS/nixpkgs/issues/108938 meta = with stdenv.lib; is a widely used pattern. We want to slowly remove the `stdenv.lib` indirection and encourage people to use `lib` directly. Thus let’s start with the meta field. This used a rewriting script to mostly automatically replace all occurances of this pattern, and add the `lib` argument to the package header if it doesn’t exist yet. The script in its current form is available at https://cs.tvl.fyi/depot@2f807d7f141068d2d60676a89213eaa5353ca6e0/-/blob/users/Profpatsch/nixpkgs-rewriter/default.nix
69 lines
2.1 KiB
Nix
69 lines
2.1 KiB
Nix
{ 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.3";
|
|
|
|
src = fetchzip {
|
|
url = "https://downloads.jboss.org/keycloak/${version}/keycloak-${version}.zip";
|
|
sha256 = "15fw49rhnjky108hh71dkdlafd0ajr1n13vhivqcw6c18zvyan35";
|
|
};
|
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
installPhase = ''
|
|
mkdir $out
|
|
cp -r * $out
|
|
|
|
rm -rf $out/bin/*.{ps1,bat}
|
|
|
|
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 lib; {
|
|
homepage = "https://www.keycloak.org/";
|
|
description = "Identity and access management for modern applications and services";
|
|
license = licenses.asl20;
|
|
platforms = jre.meta.platforms;
|
|
maintainers = with maintainers; [ ngerstle talyz ];
|
|
};
|
|
|
|
}
|