2022-05-05 10:09:15 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, formats
|
|
|
|
, nixosTests
|
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
|
|
|
, installShellFiles
|
|
|
|
, pkg-config
|
|
|
|
, udev
|
|
|
|
, openssl
|
|
|
|
, sqlite
|
|
|
|
, pam
|
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
arch = if stdenv.isx86_64 then "x86_64" else "generic";
|
|
|
|
in
|
|
|
|
rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "kanidm";
|
2023-03-15 14:47:53 +00:00
|
|
|
version = "1.1.0-alpha.11";
|
2022-05-05 10:09:15 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
2023-03-15 14:47:53 +00:00
|
|
|
rev = "refs/tags/v${version}";
|
|
|
|
hash = "sha256-TVGLL1Ir/Nld0kdhWmcYYmChrW42ctJPY/U7wtuEwCo=";
|
2022-05-05 10:09:15 +00:00
|
|
|
};
|
|
|
|
|
2023-03-15 14:47:53 +00:00
|
|
|
cargoSha256 = "sha256-xYnZlPpnNPzk4IWuEcPQHudYR9IVsr4/JMHV7H1HAXw=";
|
2022-05-05 10:09:15 +00:00
|
|
|
|
|
|
|
KANIDM_BUILD_PROFILE = "release_nixos_${arch}";
|
|
|
|
|
|
|
|
postPatch =
|
|
|
|
let
|
|
|
|
format = (formats.toml { }).generate "${KANIDM_BUILD_PROFILE}.toml";
|
|
|
|
profile = {
|
|
|
|
web_ui_pkg_path = "@web_ui_pkg_path@";
|
|
|
|
cpu_flags = if stdenv.isx86_64 then "x86_64_v1" else "none";
|
|
|
|
};
|
|
|
|
in
|
|
|
|
''
|
|
|
|
cp ${format profile} profiles/${KANIDM_BUILD_PROFILE}.toml
|
|
|
|
substituteInPlace profiles/${KANIDM_BUILD_PROFILE}.toml \
|
|
|
|
--replace '@web_ui_pkg_path@' "$out/ui"
|
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config
|
|
|
|
installShellFiles
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
udev
|
|
|
|
openssl
|
|
|
|
sqlite
|
|
|
|
pam
|
|
|
|
];
|
|
|
|
|
2022-09-05 12:11:48 +00:00
|
|
|
# The UI needs to be in place before the tests are run.
|
|
|
|
postBuild = ''
|
|
|
|
# We don't compile the wasm-part form source, as there isn't a rustc for
|
|
|
|
# wasm32-unknown-unknown in nixpkgs yet.
|
|
|
|
mkdir $out
|
|
|
|
cp -r kanidmd_web_ui/pkg $out/ui
|
|
|
|
'';
|
2022-05-05 10:09:15 +00:00
|
|
|
|
|
|
|
preFixup = ''
|
2022-09-05 12:11:48 +00:00
|
|
|
installShellCompletion \
|
|
|
|
--bash $releaseDir/build/completions/*.bash \
|
|
|
|
--zsh $releaseDir/build/completions/_*
|
2022-05-05 10:09:15 +00:00
|
|
|
|
|
|
|
# PAM and NSS need fix library names
|
|
|
|
mv $out/lib/libnss_kanidm.so $out/lib/libnss_kanidm.so.2
|
|
|
|
mv $out/lib/libpam_kanidm.so $out/lib/pam_kanidm.so
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru.tests = { inherit (nixosTests) kanidm; };
|
|
|
|
|
|
|
|
meta = with lib; {
|
|
|
|
description = "A simple, secure and fast identity management platform";
|
|
|
|
homepage = "https://github.com/kanidm/kanidm";
|
|
|
|
license = licenses.mpl20;
|
|
|
|
platforms = platforms.linux;
|
|
|
|
maintainers = with maintainers; [ erictapen Flakebi ];
|
|
|
|
};
|
|
|
|
}
|