nixpkgs/pkgs/servers/keycloak/default.nix

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

85 lines
1.9 KiB
Nix
Raw Normal View History

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