[skip ci] feat: some more changes based on https://github.com/NixOS/nixpkgs/pull/265783

This commit is contained in:
silver 2023-12-30 10:38:31 +00:00
parent a19d1cc915
commit 5900c41ab7
3 changed files with 54 additions and 57 deletions

View file

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

View file

@ -5,12 +5,12 @@
... ...
}: }:
with lib; let with lib; let
cfg = config.services.bitwarden-directory-connector; cfg = config.services.bitwarden-directory-connector-cli;
in { in {
options.services.bitwarden-directory-connector = { options.services.bitwarden-directory-connector-cli = {
enable = mkEnableOption "Bitwarden Directory Connector"; enable = mkEnableOption "Bitwarden Directory Connector";
package = mkPackageOption pkgs "bitwarden-directory-connector" {}; package = mkPackageOption pkgs "bitwarden-directory-connector-cli" {};
domain = mkOption { domain = mkOption {
type = types.str; type = types.str;
@ -36,7 +36,6 @@ in {
If you used the desktop application to test the configuration you can find the settings by searching for `ldap` in `~/.config/Bitwarden\ Directory\ Connector/data.json`. If you used the desktop application to test the configuration you can find the settings by searching for `ldap` in `~/.config/Bitwarden\ Directory\ Connector/data.json`.
''; '';
default = {}; default = {};
type = types.submodule ({ type = types.submodule ({
config, config,
options, options,
@ -110,7 +109,6 @@ in {
If you used the desktop application to test the configuration you can find the settings by searching for `sync` in `~/.config/Bitwarden\ Directory\ Connector/data.json`. If you used the desktop application to test the configuration you can find the settings by searching for `sync` in `~/.config/Bitwarden\ Directory\ Connector/data.json`.
''; '';
default = {}; default = {};
type = types.submodule ({ type = types.submodule ({
config, config,
options, options,
@ -259,18 +257,18 @@ in {
}; };
systemd = { systemd = {
timers.bitwarden-directory-connector = { timers.bitwarden-directory-connector-cli = {
description = "Sync timer for Bitwarden Directory Connector"; description = "Sync timer for Bitwarden Directory Connector";
wantedBy = ["timers.target"]; wantedBy = ["timers.target"];
after = ["network-online.target"]; after = ["network-online.target"];
timerConfig = { timerConfig = {
OnCalendar = cfg.interval; OnCalendar = cfg.interval;
Unit = "bitwarden-directory-connector.service"; Unit = "bitwarden-directory-connector-cli.service";
Persistent = true; Persistent = true;
}; };
}; };
services.bitwarden-directory-connector = { services.bitwarden-directory-connector-cli = {
description = "Main process for Bitwarden Directory Connector"; description = "Main process for Bitwarden Directory Connector";
path = [pkgs.jq]; path = [pkgs.jq];

View file

@ -29,7 +29,7 @@ in {
group = user; group = user;
}; };
services.bitwarden-directory-connector = { services.bitwarden-directory-connector-cli = {
enable = true; enable = true;
user = user; user = user;