Commit baecc1d3 authored by Andrew Marshall's avatar Andrew Marshall
Browse files

bitwarden: make applying patches easier

Since `sourceRoot` occurs before patching, simply setting `patches` in
the native drv to the same as the npm drv doesn’t work, as paths outside
the `sourceRoot` referenced in the patches don’t exist and cause
applying them to fail. Instead, use `applyPatches` to make `src` have
the patches already applied before `sourceRoot` comes into play. It
would be possible to not use `sourceRoot` and just `cd`, but then the
`Cargo.lock` location needs to be manually specified and it just becomes
more mess than it’s worth. `applyPatches` seems the cleanest way to
achieve this.
parent 9a8475c6
Loading
Loading
Loading
Loading
+11 −8
Original line number Diff line number Diff line
{ lib
, applyPatches
, buildNpmPackage
, dbus
, electron
@@ -25,6 +26,7 @@ let
  buildNpmPackage' = buildNpmPackage.override { nodejs = nodejs_16; };

  version = "2023.4.0";
  src = applyPatches {
    src = fetchFromGitHub {
      owner = "bitwarden";
      repo = "clients";
@@ -32,14 +34,15 @@ let
      sha256 = "sha256-TTKDl6Py3k+fAy/kcyiMbAAKQdhVnZTyRXV8D/VpKBE=";
    };

    patches = [ ];
  };

  desktop-native = rustPlatform.buildRustPackage {
    pname = "bitwarden-desktop-native";
    inherit src version;
    sourceRoot = "source/apps/desktop/desktop_native";
    sourceRoot = "source-patched/apps/desktop/desktop_native";
    cargoSha256 = "sha256-VW9DmSh9jvqFCZjH1SAYkydSGjXSVEbv4CmtoJBiw5Y=";

    patchFlags = [ "-p4" ];

    nativeBuildInputs = [
      pkg-config
      wrapGAppsHook