2022-05-05 10:09:15 +00:00
|
|
|
{ stdenv
|
|
|
|
, lib
|
|
|
|
, formats
|
|
|
|
, nixosTests
|
|
|
|
, rustPlatform
|
|
|
|
, fetchFromGitHub
|
2023-05-01 10:39:28 +00:00
|
|
|
, fetchpatch
|
2022-05-05 10:09:15 +00:00
|
|
|
, 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-05-01 10:39:28 +00:00
|
|
|
version = "1.1.0-alpha.12";
|
2022-05-05 10:09:15 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = pname;
|
|
|
|
repo = pname;
|
2023-07-03 12:08:13 +00:00
|
|
|
rev = "f5924443f08e462067937a5dd0e2c19e5e1255da";
|
|
|
|
hash = "sha256-kJUxVrGpczIdOqKQbgRp1xERfKP6C0SDQgWdjtSuvZ8=";
|
2022-05-05 10:09:15 +00:00
|
|
|
};
|
|
|
|
|
2023-03-25 23:16:46 +00:00
|
|
|
cargoLock = {
|
|
|
|
lockFile = ./Cargo.lock;
|
|
|
|
outputHashes = {
|
2023-05-01 10:39:28 +00:00
|
|
|
"tracing-forest-0.1.5" = "sha256-L6auSKB4DCnZBZpx7spiikhSOD6i1W3erc3zjn+26Ao=";
|
2023-03-25 23:16:46 +00:00
|
|
|
};
|
|
|
|
};
|
2022-05-05 10:09:15 +00:00
|
|
|
|
|
|
|
KANIDM_BUILD_PROFILE = "release_nixos_${arch}";
|
|
|
|
|
2023-05-01 10:39:28 +00:00
|
|
|
patches = [
|
|
|
|
(fetchpatch {
|
|
|
|
# Bring back x86_64-v1 microarchitecture level
|
|
|
|
name = "cpu-opt-level.patch";
|
|
|
|
url = "https://github.com/kanidm/kanidm/commit/59c6723f7dfb2266eae45c3b2ddd377872a7a113.patch";
|
|
|
|
hash = "sha256-8rVEYitxvdVduQ/+AD/UG3v+mgT/VxkLoxNIXczUfCQ=";
|
|
|
|
})
|
|
|
|
];
|
|
|
|
|
2022-05-05 10:09:15 +00:00
|
|
|
postPatch =
|
|
|
|
let
|
|
|
|
format = (formats.toml { }).generate "${KANIDM_BUILD_PROFILE}.toml";
|
|
|
|
profile = {
|
|
|
|
web_ui_pkg_path = "@web_ui_pkg_path@";
|
2023-05-01 10:39:28 +00:00
|
|
|
cpu_flags = if stdenv.isx86_64 then "x86_64_legacy" else "none";
|
2022-05-05 10:09:15 +00:00
|
|
|
};
|
|
|
|
in
|
|
|
|
''
|
2023-05-01 10:39:28 +00:00
|
|
|
cp ${format profile} libs/profiles/${KANIDM_BUILD_PROFILE}.toml
|
|
|
|
substituteInPlace libs/profiles/${KANIDM_BUILD_PROFILE}.toml \
|
2022-05-05 10:09:15 +00:00
|
|
|
--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
|
2023-05-01 10:39:28 +00:00
|
|
|
cp -r server/web_ui/pkg $out/ui
|
2022-09-05 12:11:48 +00:00
|
|
|
'';
|
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 ];
|
|
|
|
};
|
|
|
|
}
|