2022-04-05 18:59:05 +02:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, fetchzip
|
|
|
|
, makeWrapper
|
|
|
|
, jre
|
|
|
|
, nixosTests
|
2021-10-03 20:08:59 +02:00
|
|
|
, callPackage
|
2022-04-05 18:59:05 +02:00
|
|
|
, confFile ? null
|
|
|
|
, plugins ? [ ]
|
2023-06-10 00:27:24 +02:00
|
|
|
, extraFeatures ? [ ]
|
|
|
|
, disabledFeatures ? [ ]
|
2020-10-05 15:58:44 +02:00
|
|
|
}:
|
|
|
|
|
2023-06-10 00:27:24 +02:00
|
|
|
let
|
|
|
|
featuresSubcommand = ''
|
|
|
|
${lib.optionalString (extraFeatures != [ ]) "--features=${lib.concatStringsSep "," extraFeatures}"} \
|
|
|
|
${lib.optionalString (disabledFeatures != [ ]) "--features-disabled=${lib.concatStringsSep "," disabledFeatures}"}
|
|
|
|
'';
|
|
|
|
in stdenv.mkDerivation rec {
|
2022-04-05 18:59:05 +02:00
|
|
|
pname = "keycloak";
|
2023-10-24 19:30:44 +02:00
|
|
|
version = "22.0.5";
|
2020-02-25 08:00:40 +01:00
|
|
|
|
|
|
|
src = fetchzip {
|
2022-04-05 18:59:05 +02:00
|
|
|
url = "https://github.com/keycloak/keycloak/releases/download/${version}/keycloak-${version}.zip";
|
2023-10-24 19:30:44 +02:00
|
|
|
hash = "sha256-D08WPJUOIIDD9JTTq4C4+wzj/fTZvFbxVXWbVzx0MKY=";
|
2020-02-25 08:00:40 +01:00
|
|
|
};
|
|
|
|
|
2022-04-05 18:59:05 +02:00
|
|
|
nativeBuildInputs = [ makeWrapper jre ];
|
|
|
|
|
2022-11-02 16:08:10 +01:00
|
|
|
patches = [
|
|
|
|
# Make home.dir and config.dir configurable through the
|
|
|
|
# KC_HOME_DIR and KC_CONF_DIR environment variables.
|
|
|
|
./config_vars.patch
|
|
|
|
];
|
|
|
|
|
2022-04-05 18:59:05 +02:00
|
|
|
buildPhase = ''
|
|
|
|
runHook preBuild
|
|
|
|
'' + lib.optionalString (confFile != null) ''
|
|
|
|
install -m 0600 ${confFile} conf/keycloak.conf
|
|
|
|
'' + ''
|
|
|
|
install_plugin() {
|
2022-08-31 13:18:56 +02:00
|
|
|
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
|
2022-04-05 18:59:05 +02:00
|
|
|
}
|
|
|
|
${lib.concatMapStringsSep "\n" (pl: "install_plugin ${lib.escapeShellArg pl}") plugins}
|
|
|
|
'' + ''
|
|
|
|
patchShebangs bin/kc.sh
|
2022-11-02 16:08:10 +01:00
|
|
|
export KC_HOME_DIR=$(pwd)
|
|
|
|
export KC_CONF_DIR=$(pwd)/conf
|
2023-06-10 00:27:24 +02:00
|
|
|
bin/kc.sh build ${featuresSubcommand}
|
2022-04-05 18:59:05 +02:00
|
|
|
|
|
|
|
runHook postBuild
|
|
|
|
'';
|
2020-02-25 08:00:40 +01:00
|
|
|
|
|
|
|
installPhase = ''
|
2022-04-05 18:59:05 +02:00
|
|
|
runHook preInstall
|
|
|
|
|
2020-02-25 08:00:40 +01:00
|
|
|
mkdir $out
|
|
|
|
cp -r * $out
|
|
|
|
|
2022-04-05 18:59:05 +02:00
|
|
|
rm $out/bin/*.{ps1,bat}
|
2020-02-25 08:00:40 +01:00
|
|
|
|
2022-04-05 18:59:05 +02:00
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
postFixup = ''
|
|
|
|
for script in $(find $out/bin -type f -executable); do
|
|
|
|
wrapProgram "$script" --set JAVA_HOME ${jre} --prefix PATH : ${jre}/bin
|
2022-03-22 20:03:47 +01:00
|
|
|
done
|
2020-02-25 08:00:40 +01:00
|
|
|
'';
|
|
|
|
|
2021-10-03 20:08:59 +02:00
|
|
|
passthru = {
|
|
|
|
tests = nixosTests.keycloak;
|
2022-04-05 18:59:05 +02:00
|
|
|
plugins = callPackage ./all-plugins.nix { };
|
|
|
|
enabledPlugins = plugins;
|
2021-10-03 20:08:59 +02:00
|
|
|
};
|
2020-10-13 11:44:02 +02:00
|
|
|
|
2021-01-11 08:54:33 +01:00
|
|
|
meta = with lib; {
|
2022-04-05 18:59:05 +02:00
|
|
|
homepage = "https://www.keycloak.org/";
|
2020-02-25 08:00:40 +01:00
|
|
|
description = "Identity and access management for modern applications and services";
|
2022-06-02 15:38:41 +02:00
|
|
|
sourceProvenance = with sourceTypes; [ binaryBytecode ];
|
2022-04-05 18:59:05 +02:00
|
|
|
license = licenses.asl20;
|
|
|
|
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
|
|
|
};
|
|
|
|
|
|
|
|
}
|