2022-04-05 19:59:05 +03:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchzip
|
|
|
|
, makeWrapper
|
|
|
|
, jre
|
|
|
|
, writeText
|
|
|
|
, nixosTests
|
2021-10-03 21:08:59 +03:00
|
|
|
, callPackage
|
2022-04-05 19:59:05 +03:00
|
|
|
|
|
|
|
, confFile ? null
|
|
|
|
, plugins ? [ ]
|
2020-10-05 16:58:44 +03:00
|
|
|
}:
|
|
|
|
|
2020-02-25 10:00:40 +03:00
|
|
|
stdenv.mkDerivation rec {
|
2022-04-05 19:59:05 +03:00
|
|
|
pname = "keycloak";
|
2022-03-31 20:35:57 +03:00
|
|
|
version = "17.0.1";
|
2020-02-25 10:00:40 +03:00
|
|
|
|
|
|
|
src = fetchzip {
|
2022-04-05 19:59:05 +03:00
|
|
|
url = "https://github.com/keycloak/keycloak/releases/download/${version}/keycloak-${version}.zip";
|
|
|
|
sha256 = "sha256-z1LfTUoK+v4oQxdyIQruFhl5O333zirSrkPoTFgVfmI=";
|
2020-02-25 10:00:40 +03:00
|
|
|
};
|
|
|
|
|
2022-04-05 19:59:05 +03:00
|
|
|
nativeBuildInputs = [ makeWrapper jre ];
|
|
|
|
|
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
'' + lib.optionalString (confFile != null) ''
|
|
|
|
install -m 0600 ${confFile} conf/keycloak.conf
|
|
|
|
'' + ''
|
|
|
|
install_plugin() {
|
|
|
|
if [ -d "$1" ]; then
|
|
|
|
find "$1" -type f \( -iname \*.ear -o -iname \*.jar \) -exec install -m 0500 "{}" "providers/" \;
|
|
|
|
else
|
|
|
|
install -m 0500 "$1" "providers/"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
${lib.concatMapStringsSep "\n" (pl: "install_plugin ${lib.escapeShellArg pl}") plugins}
|
|
|
|
'' + ''
|
|
|
|
export KC_HOME_DIR=$out
|
|
|
|
export KC_CONF_DIR=$out/conf
|
|
|
|
|
|
|
|
patchShebangs bin/kc.sh
|
|
|
|
bin/kc.sh build
|
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
2020-02-25 10:00:40 +03:00
|
|
|
|
|
|
|
installPhase = ''
|
2022-04-05 19:59:05 +03:00
|
|
|
runHook preInstall
|
|
|
|
|
2020-02-25 10:00:40 +03:00
|
|
|
mkdir $out
|
|
|
|
cp -r * $out
|
|
|
|
|
2022-04-05 19:59:05 +03:00
|
|
|
rm $out/bin/*.{ps1,bat}
|
2020-02-25 10:00:40 +03:00
|
|
|
|
2022-04-05 19:59:05 +03:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
substituteInPlace $out/bin/kc.sh --replace '-Dkc.home.dir=$DIRNAME/../' '-Dkc.home.dir=$KC_HOME_DIR'
|
|
|
|
substituteInPlace $out/bin/kc.sh --replace '-Djboss.server.config.dir=$DIRNAME/../conf' '-Djboss.server.config.dir=$KC_CONF_DIR'
|
2020-10-05 16:58:44 +03:00
|
|
|
|
2022-04-05 19:59:05 +03:00
|
|
|
for script in $(find $out/bin -type f -executable); do
|
|
|
|
wrapProgram "$script" --set JAVA_HOME ${jre} --prefix PATH : ${jre}/bin
|
2022-03-22 22:03:47 +03:00
|
|
|
done
|
2020-02-25 10:00:40 +03:00
|
|
|
'';
|
|
|
|
|
2021-10-03 21:08:59 +03:00
|
|
|
passthru = {
|
|
|
|
tests = nixosTests.keycloak;
|
2022-04-05 19:59:05 +03:00
|
|
|
plugins = callPackage ./all-plugins.nix { };
|
|
|
|
enabledPlugins = plugins;
|
2021-10-03 21:08:59 +03:00
|
|
|
};
|
2020-10-13 12:44:02 +03:00
|
|
|
|
2021-01-11 10:54:33 +03:00
|
|
|
meta = with lib; {
|
2022-04-05 19:59:05 +03:00
|
|
|
homepage = "https://www.keycloak.org/";
|
2020-02-25 10:00:40 +03:00
|
|
|
description = "Identity and access management for modern applications and services";
|
2022-04-05 19:59:05 +03:00
|
|
|
license = licenses.asl20;
|
|
|
|
platforms = jre.meta.platforms;
|
2020-10-05 16:58:44 +03:00
|
|
|
maintainers = with maintainers; [ ngerstle talyz ];
|
2020-02-25 10:00:40 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|