0
0
Fork 0
mirror of https://github.com/NixOS/nixpkgs.git synced 2025-07-13 21:50:33 +03:00

element-desktop: make keytar optional

This commit is contained in:
zseri 2022-02-11 14:26:07 +01:00
parent 48c3c219bd
commit 72957a2dc0
5 changed files with 46 additions and 6 deletions

View file

@ -917,6 +917,16 @@
<literal>true</literal>. <literal>true</literal>.
</para> </para>
</listitem> </listitem>
<listitem>
<para>
The <literal>element-desktop</literal> package now has an
<literal>useKeytar</literal> option (defaults to
<literal>true</literal>), which allows disabling
<literal>keytar</literal> and in turn
<literal>libsecret</literal> usage (which binds to native
credential managers / keychain libraries).
</para>
</listitem>
<listitem> <listitem>
<para> <para>
The option <literal>services.thelounge.plugins</literal> has The option <literal>services.thelounge.plugins</literal> has

View file

@ -307,6 +307,10 @@ In addition to numerous new and upgraded packages, this release has the followin
using `fetchgit` or `fetchhg` if the argument `fetchSubmodules` using `fetchgit` or `fetchhg` if the argument `fetchSubmodules`
is set to `true`. is set to `true`.
- The `element-desktop` package now has an `useKeytar` option (defaults to `true`),
which allows disabling `keytar` and in turn `libsecret` usage
(which binds to native credential managers / keychain libraries).
- The option `services.thelounge.plugins` has been added to allow installing plugins for The Lounge. Plugins can be found in `pkgs.theLoungePlugins.plugins` and `pkgs.theLoungePlugins.themes`. - The option `services.thelounge.plugins` has been added to allow installing plugins for The Lounge. Plugins can be found in `pkgs.theLoungePlugins.plugins` and `pkgs.theLoungePlugins.themes`.
- The `firmwareLinuxNonfree` package has been renamed to `linux-firmware`. - The `firmwareLinuxNonfree` package has been renamed to `linux-firmware`.

View file

@ -13,12 +13,15 @@
, AppKit , AppKit
, CoreServices , CoreServices
, desktopToDarwinBundle , desktopToDarwinBundle
, useKeytar ? true
}: }:
let let
pinData = lib.importJSON ./pin.json; pinData = lib.importJSON ./pin.json;
executableName = "element-desktop"; executableName = "element-desktop";
electron_exec = if stdenv.isDarwin then "${electron}/Applications/Electron.app/Contents/MacOS/Electron" else "${electron}/bin/electron"; electron_exec = if stdenv.isDarwin then "${electron}/Applications/Electron.app/Contents/MacOS/Electron" else "${electron}/bin/electron";
keytar = callPackage ./keytar { inherit Security AppKit; };
seshat = callPackage ./seshat { inherit CoreServices; };
in in
mkYarnPackage rec { mkYarnPackage rec {
pname = "element-desktop"; pname = "element-desktop";
@ -39,8 +42,7 @@ mkYarnPackage rec {
nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ]; nativeBuildInputs = [ makeWrapper ] ++ lib.optionals stdenv.isDarwin [ desktopToDarwinBundle ];
seshat = callPackage ./seshat { inherit CoreServices; }; inherit seshat;
keytar = callPackage ./keytar { inherit Security AppKit; };
buildPhase = '' buildPhase = ''
runHook preBuild runHook preBuild
@ -51,12 +53,14 @@ mkYarnPackage rec {
node ./scripts/copy-res.js node ./scripts/copy-res.js
popd popd
rm -rf node_modules/matrix-seshat node_modules/keytar rm -rf node_modules/matrix-seshat node_modules/keytar
ln -s $keytar node_modules/keytar ${lib.optionalString useKeytar "ln -s ${keytar} node_modules/keytar"}
ln -s $seshat node_modules/matrix-seshat ln -s $seshat node_modules/matrix-seshat
runHook postBuild runHook postBuild
''; '';
installPhase = '' installPhase = ''
runHook preInstall
# resources # resources
mkdir -p "$out/share/element" mkdir -p "$out/share/element"
ln -s '${element-web}' "$out/share/element/webapp" ln -s '${element-web}' "$out/share/element/webapp"
@ -83,6 +87,8 @@ mkYarnPackage rec {
--set LD_PRELOAD ${sqlcipher}/lib/libsqlcipher.so \ --set LD_PRELOAD ${sqlcipher}/lib/libsqlcipher.so \
--add-flags "$out/share/element/electron" \ --add-flags "$out/share/element/electron" \
--add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}" --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--enable-features=UseOzonePlatform --ozone-platform=wayland}}"
runHook postInstall
''; '';
# Do not attempt generating a tarball for element-web again. # Do not attempt generating a tarball for element-web again.
@ -107,7 +113,20 @@ mkYarnPackage rec {
''; '';
}; };
passthru.updateScript = ./update.sh; passthru = {
updateScript = ./update.sh;
# TL;DR: keytar is optional while seshat isn't.
#
# This prevents building keytar when `useKeytar` is set to `false`, because
# if libsecret is unavailable (e.g. set to `null` or fails to build), then
# this package wouldn't even considered for building because
# "one of the dependencies failed to build",
# although the dependency wouldn't even be used.
#
# It needs to be `passthru` anyways because other packages do depend on it.
inherit keytar;
};
meta = with lib; { meta = with lib; {
description = "A feature-rich client for Matrix.org"; description = "A feature-rich client for Matrix.org";

View file

@ -28,6 +28,7 @@ in stdenv.mkDerivation rec {
}; };
buildPhase = '' buildPhase = ''
runHook preBuild
cp ${./yarn.lock} ./yarn.lock cp ${./yarn.lock} ./yarn.lock
chmod u+w . ./yarn.lock chmod u+w . ./yarn.lock
export HOME=$PWD/tmp export HOME=$PWD/tmp
@ -37,16 +38,19 @@ in stdenv.mkDerivation rec {
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/ patchShebangs node_modules/
node_modules/.bin/node-gyp rebuild node_modules/.bin/node-gyp rebuild
runHook postBuild
''; '';
doCheck = false; doCheck = false;
installPhase = '' installPhase = ''
runHook preInstall
shopt -s extglob shopt -s extglob
rm -rf node_modules rm -rf node_modules
rm -rf $HOME rm -rf $HOME
mkdir -p $out mkdir -p $out
cp -r ./!(build) $out cp -r ./!(build) $out
install -D -t $out/build/Release build/Release/keytar.node install -D -t $out/build/Release build/Release/keytar.node
runHook postInstall
''; '';
} }

View file

@ -27,6 +27,7 @@ in rustPlatform.buildRustPackage rec {
}; };
buildPhase = '' buildPhase = ''
runHook preBuild
cd .. cd ..
chmod u+w . ./yarn.lock chmod u+w . ./yarn.lock
export HOME=$PWD/tmp export HOME=$PWD/tmp
@ -36,16 +37,18 @@ in rustPlatform.buildRustPackage rec {
yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive yarn install --offline --frozen-lockfile --ignore-platform --ignore-scripts --no-progress --non-interactive
patchShebangs node_modules/ patchShebangs node_modules/
node_modules/.bin/neon build --release node_modules/.bin/neon build --release
runHook postBuild
''; '';
doCheck = false; doCheck = false;
installPhase = '' installPhase = ''
runHook preInstall
shopt -s extglob shopt -s extglob
rm -rf native/!(index.node) rm -rf native/!(index.node)
rm -rf node_modules rm -rf node_modules $HOME
rm -rf $HOME
cp -r . $out cp -r . $out
runHook postInstall
''; '';
cargoSha256 = pinData.cargoHash; cargoSha256 = pinData.cargoHash;