nixos/applications/bitwarden/_bitwarden-directory-connector.nix

69 lines
1.7 KiB
Nix

{
lib,
buildNpmPackage,
fetchFromGitHub,
pkgs,
jq,
python3,
pkg-config,
libsecret,
nodejs_18,
}: let
buildNpmPackage' = buildNpmPackage.override {nodejs = nodejs_18;};
in
buildNpmPackage' rec {
pname = "bitwarden-directory-connector";
version = "2023.10.0";
src = fetchFromGitHub {
owner = "bitwarden";
repo = "directory-connector";
rev = "v${version}";
hash = "sha256-PlOtTh+rpTxAv8ajHBDHZuL7yeeLVpbAfKEDPQlejIg=";
};
patch = ''
jq 'del(.scripts.preinstall)' package.json > package.json.tmp
mv -f package.json{.tmp,}
'';
npmDepsHash = "sha256-jBAWWY12qeX2EDhUvT3TQpnQvYXRsIilRrXGpVzxYvw=";
env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
makeCacheWritable = true;
npmBuildScript = "build:cli:prod";
installPhase = ''
runHook preInstall
mkdir -p $out/libexec/bitwarden-directory-connector
cp -R {build-cli,node_modules} $out/libexec/bitwarden-directory-connector
runHook postInstall
'';
# needs to be wrapped with nodejs so that it can be executed
postInstall = ''
chmod +x $out/libexec/bitwarden-directory-connector/build-cli/bwdc.js
mkdir -p $out/bin
ln -s $out/libexec/bitwarden-directory-connector/build-cli/bwdc.js $out/bin/bitwarden-directory-connector
'';
buildInputs = [
libsecret
];
nativeBuildInputs = [
jq
python3
pkg-config
];
meta = with lib; {
description = "LDAP connector for Bitwarden";
homepage = "https://github.com/bitwarden/directory-connector";
license = licenses.gpl3Only;
maintainers = with maintainers; [Silver-Golden];
platforms = platforms.linux;
mainProgram = "bitwarden-directory-connector";
};
}