2023-03-04 12:14:45 +00:00
|
|
|
{ lib
|
|
|
|
, buildNpmPackage
|
|
|
|
, dbus
|
|
|
|
, electron
|
|
|
|
, fetchFromGitHub
|
|
|
|
, glib
|
|
|
|
, gnome
|
|
|
|
, gtk3
|
|
|
|
, jq
|
2020-04-24 23:36:52 +00:00
|
|
|
, libsecret
|
|
|
|
, makeDesktopItem
|
|
|
|
, makeWrapper
|
2023-03-04 12:14:45 +00:00
|
|
|
, moreutils
|
|
|
|
, nodejs-16_x
|
|
|
|
, pkg-config
|
|
|
|
, python3
|
|
|
|
, rustPlatform
|
2020-04-24 23:36:52 +00:00
|
|
|
, wrapGAppsHook
|
|
|
|
}:
|
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
let
|
|
|
|
description = "A secure and free password manager for all of your devices";
|
|
|
|
icon = "bitwarden";
|
|
|
|
|
|
|
|
buildNpmPackage' = buildNpmPackage.override { nodejs = nodejs-16_x; };
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
version = "2023.2.0";
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "bitwarden";
|
|
|
|
repo = "clients";
|
|
|
|
rev = "desktop-v${version}";
|
|
|
|
sha256 = "/k2r+TikxVGlz8cnOq5zF3oUYw4zj31vDAD7OQFQlC4=";
|
|
|
|
};
|
|
|
|
|
|
|
|
desktop-native = rustPlatform.buildRustPackage rec {
|
|
|
|
pname = "bitwarden-desktop-native";
|
|
|
|
inherit src version;
|
|
|
|
sourceRoot = "source/apps/desktop/desktop_native";
|
|
|
|
cargoSha256 = "sha256-zLftfmWYYUAaMvIT21qhVsHzxnNdQhFBH0fRBwVduAc=";
|
|
|
|
|
|
|
|
patchFlags = [ "-p4" ];
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
pkg-config
|
|
|
|
wrapGAppsHook
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [
|
|
|
|
glib
|
|
|
|
gtk3
|
|
|
|
libsecret
|
|
|
|
];
|
|
|
|
|
|
|
|
nativeCheckInputs = [
|
|
|
|
dbus
|
|
|
|
(gnome.gnome-keyring.override { useWrappedDaemon = false; })
|
|
|
|
];
|
|
|
|
|
|
|
|
checkFlags = [
|
|
|
|
"--skip=password::password::tests::test"
|
|
|
|
];
|
|
|
|
|
|
|
|
checkPhase = ''
|
|
|
|
runHook preCheck
|
|
|
|
|
|
|
|
export HOME=$(mktemp -d)
|
|
|
|
export -f cargoCheckHook runHook _eval _callImplicitHook
|
|
|
|
dbus-run-session \
|
|
|
|
--config-file=${dbus}/share/dbus-1/session.conf \
|
|
|
|
-- bash -e -c cargoCheckHook
|
|
|
|
runHook postCheck
|
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
desktopItem = makeDesktopItem {
|
|
|
|
name = "bitwarden";
|
|
|
|
exec = "bitwarden %U";
|
2023-03-04 12:14:45 +00:00
|
|
|
inherit icon;
|
|
|
|
comment = description;
|
2021-12-06 16:07:01 +00:00
|
|
|
desktopName = "Bitwarden";
|
2022-03-05 16:20:37 +00:00
|
|
|
categories = [ "Utility" ];
|
2021-12-06 16:07:01 +00:00
|
|
|
};
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
in
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
buildNpmPackage' {
|
|
|
|
pname = "bitwarden";
|
|
|
|
inherit src version;
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
makeCacheWritable = true;
|
|
|
|
npmBuildFlags = [
|
|
|
|
"--workspace apps/desktop"
|
|
|
|
];
|
|
|
|
npmDepsHash = "sha256-aFjN1S0+lhHjK3VSYfx0F5X8wSJwRRr6zQpPGt2VpxE=";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
nativeBuildInputs = [
|
|
|
|
jq
|
|
|
|
makeWrapper
|
|
|
|
moreutils
|
|
|
|
python3
|
|
|
|
];
|
|
|
|
|
|
|
|
preBuild = ''
|
|
|
|
jq 'del(.scripts.postinstall)' apps/desktop/package.json | sponge apps/desktop/package.json
|
|
|
|
jq '.scripts.build = ""' apps/desktop/desktop_native/package.json | sponge apps/desktop/desktop_native/package.json
|
|
|
|
cp ${desktop-native}/lib/libdesktop_native.so apps/desktop/desktop_native/desktop_native.linux-x64-musl.node
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
postBuild = ''
|
|
|
|
pushd apps/desktop
|
|
|
|
|
|
|
|
"$(npm bin)"/electron-builder \
|
|
|
|
--dir \
|
|
|
|
-c.electronDist=${electron}/lib/electron \
|
|
|
|
-c.electronVersion=${electron.version}
|
|
|
|
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
mkdir $out
|
|
|
|
|
|
|
|
pushd apps/desktop/dist/linux-unpacked
|
|
|
|
mkdir -p $out/opt/Bitwarden
|
|
|
|
cp -r locales resources{,.pak} $out/opt/Bitwarden
|
|
|
|
popd
|
|
|
|
|
|
|
|
makeWrapper '${electron}/bin/electron' "$out/bin/bitwarden" \
|
|
|
|
--add-flags $out/opt/Bitwarden/resources/app.asar \
|
|
|
|
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
|
|
|
|
--set-default ELECTRON_IS_DEV 0 \
|
|
|
|
--inherit-argv0
|
|
|
|
|
|
|
|
mkdir -p $out/share/applications
|
|
|
|
cp ${desktopItem}/share/applications/* $out/share/applications
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2023-03-04 12:14:45 +00:00
|
|
|
pushd apps/desktop/resources/icons
|
|
|
|
for icon in *.png; do
|
|
|
|
dir=$out/share/icons/hicolor/"''${icon%.png}"/apps
|
|
|
|
mkdir -p "$dir"
|
|
|
|
cp "$icon" "$dir"/${icon}.png
|
|
|
|
done
|
|
|
|
popd
|
2021-12-06 16:07:01 +00:00
|
|
|
'';
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2021-12-06 16:07:01 +00:00
|
|
|
meta = with lib; {
|
2023-03-04 12:14:45 +00:00
|
|
|
inherit description;
|
2021-12-06 16:07:01 +00:00
|
|
|
homepage = "https://bitwarden.com";
|
2023-03-04 12:14:45 +00:00
|
|
|
license = lib.licenses.gpl3;
|
|
|
|
maintainers = with maintainers; [ amarshall kiwi ];
|
2021-12-06 16:07:01 +00:00
|
|
|
platforms = [ "x86_64-linux" ];
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
2021-12-06 16:07:01 +00:00
|
|
|
}
|