Unverified Commit c992eb42 authored by Gaétan Lepage's avatar Gaétan Lepage Committed by GitHub
Browse files

keepassxc: move to by-name, modernize, fix build on darwin (#398600)

parents bd8e0f40 10303bae
Loading
Loading
Loading
Loading
+73 −54
Original line number Diff line number Diff line
@@ -3,54 +3,46 @@
  stdenv,
  fetchFromGitHub,
  cmake,
  qttools,
  libsForQt5,

  apple-sdk_15,
  asciidoctor,
  botan3,
  curl,
  darwinMinVersionHook,
  kio,
  libXi,
  libXtst,
  libargon2,
  libusb1,
  minizip,
  nix-update-script,
  pcsclite,
  pkg-config,
  qrencode,
  qtbase,
  qtmacextras,
  qtsvg,
  qtx11extras,
  readline,
  wrapGAppsHook3,
  wrapQtAppsHook,
  zlib,

  LocalAuthentication,

  withKeePassBrowser ? true,
  withKeePassBrowserPasskeys ? true,
  withKeePassFDOSecrets ? true,
  withKeePassFDOSecrets ? stdenv.hostPlatform.isLinux,
  withKeePassKeeShare ? true,
  withKeePassNetworking ? true,
  withKeePassSSHAgent ? true,
  withKeePassTouchID ? true,
  withKeePassX11 ? true,
  withKeePassYubiKey ? true,
  withKeePassYubiKey ? stdenv.hostPlatform.isLinux,

  nixosTests,
}:

stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
  pname = "keepassxc";
  version = "2.7.10";

  src = fetchFromGitHub {
    owner = "keepassxreboot";
    repo = "keepassxc";
    rev = version;
    tag = finalAttrs.version;
    hash = "sha256-FBoqCYNM/leN+w4aV0AJMx/G0bjHbI9KVWrnmq3NfaI=";
  };

@@ -64,31 +56,49 @@ stdenv.mkDerivation rec {

  patches = [ ./darwin.patch ];

  cmakeFlags =
    [
      "-DKEEPASSXC_BUILD_TYPE=Release"
      "-DWITH_GUI_TESTS=ON"
      "-DWITH_XC_UPDATECHECK=OFF"
    ]
    ++ (lib.optional (!withKeePassX11) "-DWITH_XC_X11=OFF")
    ++ (lib.optional (withKeePassFDOSecrets && stdenv.hostPlatform.isLinux) "-DWITH_XC_FDOSECRETS=ON")
    ++ (lib.optional (withKeePassYubiKey && stdenv.hostPlatform.isLinux) "-DWITH_XC_YUBIKEY=ON")
    ++ (lib.optional withKeePassBrowser "-DWITH_XC_BROWSER=ON")
    ++ (lib.optional withKeePassBrowserPasskeys "-DWITH_XC_BROWSER_PASSKEYS=ON")
    ++ (lib.optional withKeePassKeeShare "-DWITH_XC_KEESHARE=ON")
    ++ (lib.optional withKeePassNetworking "-DWITH_XC_NETWORKING=ON")
    ++ (lib.optional withKeePassSSHAgent "-DWITH_XC_SSHAGENT=ON");
  cmakeFlags = [
    (lib.cmakeFeature "KEEPASSXC_BUILD_TYPE" "Release")
    (lib.cmakeBool "WITH_GUI_TESTS" true)
    (lib.cmakeBool "WITH_XC_UPDATECHECK" false)
    (lib.cmakeBool "WITH_XC_X11" withKeePassX11)
    (lib.cmakeBool "WITH_XC_BROWSER" withKeePassBrowser)
    (lib.cmakeBool "WITH_XC_BROWSER_PASSKEYS" withKeePassBrowserPasskeys)
    (lib.cmakeBool "WITH_XC_KEESHARE" withKeePassKeeShare)
    (lib.cmakeBool "WITH_XC_NETWORKING" withKeePassNetworking)
    (lib.cmakeBool "WITH_XC_SSHAGENT" withKeePassSSHAgent)
    (lib.cmakeBool "WITH_XC_FDOSECRETS" withKeePassFDOSecrets)
    (lib.cmakeBool "WITH_XC_YUBIKEY" withKeePassYubiKey)
  ];

  doCheck = true;
  checkPhase = ''
  checkPhase =
    let
      disabledTests = lib.concatStringsSep "|" (
        [
          # flaky
          "testcli"
          "testgui"
        ]
        ++ lib.optionals stdenv.hostPlatform.isDarwin [
          # QWidget: Cannot create a QWidget without QApplication
          "testautotype"

          # FAIL!  : TestDatabase::testExternallyModified() Compared values are not the same
          #   Actual   (((spyFileChanged.count()))): 0
          #   Expected (1)                         : 1
          #   Loc: [/tmp/nix-build-keepassxc-2.7.10.drv-2/source/tests/TestDatabase.cpp(288)]
          "testdatabase"
        ]
      );
    in
    ''
      runHook preCheck

      export LC_ALL="en_US.UTF-8"
      export QT_QPA_PLATFORM=offscreen
    export QT_PLUGIN_PATH="${qtbase.bin}/${qtbase.qtPluginPrefix}"
    # testcli, testgui and testkdbx4 are flaky - skip them all
    # testautotype on darwin throws "QWidget: Cannot create a QWidget without QApplication"
    make test ARGS+="-E 'testcli|testgui${lib.optionalString stdenv.hostPlatform.isDarwin "|testautotype|testkdbx4"}' --output-on-failure"
      export QT_PLUGIN_PATH="${libsForQt5.qtbase.bin}/${libsForQt5.qtbase.qtPluginPrefix}"

      make test ARGS+="-E '${disabledTests}' --output-on-failure"

      runHook postCheck
    '';
@@ -96,8 +106,8 @@ stdenv.mkDerivation rec {
  nativeBuildInputs = [
    asciidoctor
    cmake
    wrapQtAppsHook
    qttools
    libsForQt5.wrapQtAppsHook
    libsForQt5.qttools
    pkg-config
  ] ++ lib.optional (!stdenv.hostPlatform.isDarwin) wrapGAppsHook3;

@@ -127,35 +137,43 @@ stdenv.mkDerivation rec {

  buildInputs =
    [
      curl
      botan3
      kio
      curl
      libXi
      libXtst
      libargon2
      libsForQt5.kio
      libsForQt5.qtbase
      libsForQt5.qtsvg
      minizip
      pcsclite
      qrencode
      qtbase
      qtsvg
      readline
      zlib
    ]
    ++ lib.optional (stdenv.hostPlatform.isDarwin && withKeePassTouchID) LocalAuthentication
    ++ lib.optionals stdenv.hostPlatform.isDarwin [
      qtmacextras
      libsForQt5.qtmacextras

      apple-sdk_15
      # ScreenCaptureKit, required by livekit, is only available on 12.3 and up:
      # https://developer.apple.com/documentation/screencapturekit
      (darwinMinVersionHook "12.3")
    ]
    ++ lib.optional stdenv.hostPlatform.isLinux libusb1
    ++ lib.optional withKeePassX11 qtx11extras;
    ++ lib.optionals stdenv.hostPlatform.isLinux [
      libusb1
    ]
    ++ lib.optionals withKeePassX11 [
      libsForQt5.qtx11extras
    ];

  passthru.tests = nixosTests.keepassxc;
  passthru = {
    tests = {
      inherit (nixosTests) keepassxc;
    };
    updateScript = nix-update-script { };
  };

  meta = with lib; {
  meta = {
    description = "Offline password manager with many features";
    longDescription = ''
      A community fork of KeePassX, which is itself a port of KeePass Password Safe.
@@ -165,12 +183,13 @@ stdenv.mkDerivation rec {
      using the KeePassXC Browser Extension (https://github.com/keepassxreboot/keepassxc-browser)
    '';
    homepage = "https://keepassxc.org/";
    license = licenses.gpl2Plus;
    changelog = "https://github.com/keepassxreboot/keepassxc/blob/${finalAttrs.version}/CHANGELOG.md";
    license = lib.licenses.gpl2Plus;
    mainProgram = "keepassxc";
    maintainers = with maintainers; [
    maintainers = with lib.maintainers; [
      blankparticle
      sigmasquadron
    ];
    platforms = platforms.linux ++ platforms.darwin;
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
  };
}
})
+0 −4
Original line number Diff line number Diff line
@@ -14197,10 +14197,6 @@ with pkgs;
    avahi = avahi.override { withLibdnssdCompat = true; };
  };
  keepassxc = libsForQt5.callPackage ../applications/misc/keepassxc {
    inherit (darwin.apple_sdk_11_0.frameworks) LocalAuthentication;
  };
  evolution-data-server-gtk4 = evolution-data-server.override {
    withGtk3 = false;
    withGtk4 = true;