From e84975934b30a37bc917f92501c089fd903983ad Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 14 Apr 2025 17:33:31 +0200 Subject: [PATCH 1/5] keepassxc: move to by-name --- .../ke}/keepassxc/darwin.patch | 0 .../firefox-native-messaging-host.json | 0 .../ke/keepassxc/package.nix} | 30 ++++++++----------- pkgs/top-level/all-packages.nix | 4 --- 4 files changed, 13 insertions(+), 21 deletions(-) rename pkgs/{applications/misc => by-name/ke}/keepassxc/darwin.patch (100%) rename pkgs/{applications/misc => by-name/ke}/keepassxc/firefox-native-messaging-host.json (100%) rename pkgs/{applications/misc/keepassxc/default.nix => by-name/ke/keepassxc/package.nix} (91%) diff --git a/pkgs/applications/misc/keepassxc/darwin.patch b/pkgs/by-name/ke/keepassxc/darwin.patch similarity index 100% rename from pkgs/applications/misc/keepassxc/darwin.patch rename to pkgs/by-name/ke/keepassxc/darwin.patch diff --git a/pkgs/applications/misc/keepassxc/firefox-native-messaging-host.json b/pkgs/by-name/ke/keepassxc/firefox-native-messaging-host.json similarity index 100% rename from pkgs/applications/misc/keepassxc/firefox-native-messaging-host.json rename to pkgs/by-name/ke/keepassxc/firefox-native-messaging-host.json diff --git a/pkgs/applications/misc/keepassxc/default.nix b/pkgs/by-name/ke/keepassxc/package.nix similarity index 91% rename from pkgs/applications/misc/keepassxc/default.nix rename to pkgs/by-name/ke/keepassxc/package.nix index 42d69a6f863c..41c9cefb8e80 100644 --- a/pkgs/applications/misc/keepassxc/default.nix +++ b/pkgs/by-name/ke/keepassxc/package.nix @@ -3,14 +3,13 @@ stdenv, fetchFromGitHub, cmake, - qttools, + libsForQt5, apple-sdk_15, asciidoctor, botan3, curl, darwinMinVersionHook, - kio, libXi, libXtst, libargon2, @@ -19,16 +18,11 @@ pcsclite, pkg-config, qrencode, - qtbase, - qtmacextras, - qtsvg, - qtx11extras, readline, wrapGAppsHook3, - wrapQtAppsHook, zlib, - LocalAuthentication, + darwin, withKeePassBrowser ? true, withKeePassBrowserPasskeys ? true, @@ -85,7 +79,7 @@ stdenv.mkDerivation rec { export LC_ALL="en_US.UTF-8" export QT_QPA_PLATFORM=offscreen - export QT_PLUGIN_PATH="${qtbase.bin}/${qtbase.qtPluginPrefix}" + export QT_PLUGIN_PATH="${libsForQt5.qtbase.bin}/${libsForQt5.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" @@ -96,8 +90,8 @@ stdenv.mkDerivation rec { nativeBuildInputs = [ asciidoctor cmake - wrapQtAppsHook - qttools + libsForQt5.wrapQtAppsHook + libsForQt5.qttools pkg-config ] ++ lib.optional (!stdenv.hostPlatform.isDarwin) wrapGAppsHook3; @@ -129,21 +123,23 @@ stdenv.mkDerivation rec { [ curl botan3 - kio + libsForQt5.kio libXi libXtst libargon2 minizip pcsclite qrencode - qtbase - qtsvg + libsForQt5.qtbase + libsForQt5.qtsvg readline zlib ] - ++ lib.optional (stdenv.hostPlatform.isDarwin && withKeePassTouchID) LocalAuthentication + ++ lib.optional ( + stdenv.hostPlatform.isDarwin && withKeePassTouchID + ) darwin.apple_sdk_11_0.frameworks.LocalAuthentication ++ lib.optionals stdenv.hostPlatform.isDarwin [ - qtmacextras + libsForQt5.qtmacextras apple-sdk_15 # ScreenCaptureKit, required by livekit, is only available on 12.3 and up: @@ -151,7 +147,7 @@ stdenv.mkDerivation rec { (darwinMinVersionHook "12.3") ] ++ lib.optional stdenv.hostPlatform.isLinux libusb1 - ++ lib.optional withKeePassX11 qtx11extras; + ++ lib.optional withKeePassX11 libsForQt5.qtx11extras; passthru.tests = nixosTests.keepassxc; diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index d1fb79a10b39..dd685aa63674 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -14201,10 +14201,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; From 76283b0def7307df3a90200806f8ca1b1aa3f6d3 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 14 Apr 2025 17:39:02 +0200 Subject: [PATCH 2/5] keepassxc: modernize --- pkgs/by-name/ke/keepassxc/package.nix | 83 ++++++++++++++++++--------- 1 file changed, 55 insertions(+), 28 deletions(-) diff --git a/pkgs/by-name/ke/keepassxc/package.nix b/pkgs/by-name/ke/keepassxc/package.nix index 41c9cefb8e80..26867e9ed779 100644 --- a/pkgs/by-name/ke/keepassxc/package.nix +++ b/pkgs/by-name/ke/keepassxc/package.nix @@ -15,6 +15,7 @@ libargon2, libusb1, minizip, + nix-update-script, pcsclite, pkg-config, qrencode, @@ -37,14 +38,14 @@ 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="; }; @@ -60,18 +61,34 @@ stdenv.mkDerivation rec { cmakeFlags = [ - "-DKEEPASSXC_BUILD_TYPE=Release" - "-DWITH_GUI_TESTS=ON" - "-DWITH_XC_UPDATECHECK=OFF" + (lib.cmakeFeature "KEEPASSXC_BUILD_TYPE" "Release") + (lib.cmakeBool "WITH_GUI_TESTS" true) + (lib.cmakeBool "WITH_XC_UPDATECHECK" false) ] - ++ (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"); + ++ lib.optionals (!withKeePassX11) [ + (lib.cmakeBool "WITH_XC_X11" false) + ] + ++ lib.optionals (withKeePassFDOSecrets && stdenv.hostPlatform.isLinux) [ + (lib.cmakeBool "WITH_XC_FDOSECRETS" true) + ] + ++ lib.optionals (withKeePassYubiKey && stdenv.hostPlatform.isLinux) [ + (lib.cmakeBool "WITH_XC_YUBIKEY" true) + ] + ++ lib.optionals withKeePassBrowser [ + (lib.cmakeBool "WITH_XC_BROWSER" true) + ] + ++ lib.optionals withKeePassBrowserPasskeys [ + (lib.cmakeBool "WITH_XC_BROWSER_PASSKEYS" true) + ] + ++ lib.optionals withKeePassKeeShare [ + (lib.cmakeBool "WITH_XC_KEESHARE" true) + ] + ++ lib.optionals withKeePassNetworking [ + (lib.cmakeBool "WITH_XC_NETWORKING" true) + ] + ++ lib.optionals withKeePassSSHAgent [ + (lib.cmakeBool "WITH_XC_SSHAGENT" true) + ]; doCheck = true; checkPhase = '' @@ -121,23 +138,23 @@ stdenv.mkDerivation rec { buildInputs = [ - curl botan3 - libsForQt5.kio + curl libXi libXtst libargon2 + libsForQt5.kio + libsForQt5.qtbase + libsForQt5.qtsvg minizip pcsclite qrencode - libsForQt5.qtbase - libsForQt5.qtsvg readline zlib ] - ++ lib.optional ( - stdenv.hostPlatform.isDarwin && withKeePassTouchID - ) darwin.apple_sdk_11_0.frameworks.LocalAuthentication + ++ lib.optionals (stdenv.hostPlatform.isDarwin && withKeePassTouchID) [ + darwin.apple_sdk_11_0.frameworks.LocalAuthentication + ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ libsForQt5.qtmacextras @@ -146,12 +163,21 @@ stdenv.mkDerivation rec { # https://developer.apple.com/documentation/screencapturekit (darwinMinVersionHook "12.3") ] - ++ lib.optional stdenv.hostPlatform.isLinux libusb1 - ++ lib.optional withKeePassX11 libsForQt5.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. @@ -161,12 +187,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; }; -} +}) From c2a7456605372e08440a81417a129406e3490f4d Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 14 Apr 2025 18:16:20 +0200 Subject: [PATCH 3/5] keepassxc: simplify cmakeFlags --- pkgs/by-name/ke/keepassxc/package.nix | 47 +++++++++------------------ 1 file changed, 15 insertions(+), 32 deletions(-) diff --git a/pkgs/by-name/ke/keepassxc/package.nix b/pkgs/by-name/ke/keepassxc/package.nix index 26867e9ed779..18f7b02495d7 100644 --- a/pkgs/by-name/ke/keepassxc/package.nix +++ b/pkgs/by-name/ke/keepassxc/package.nix @@ -27,13 +27,13 @@ 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, }: @@ -59,36 +59,19 @@ stdenv.mkDerivation (finalAttrs: { patches = [ ./darwin.patch ]; - cmakeFlags = - [ - (lib.cmakeFeature "KEEPASSXC_BUILD_TYPE" "Release") - (lib.cmakeBool "WITH_GUI_TESTS" true) - (lib.cmakeBool "WITH_XC_UPDATECHECK" false) - ] - ++ lib.optionals (!withKeePassX11) [ - (lib.cmakeBool "WITH_XC_X11" false) - ] - ++ lib.optionals (withKeePassFDOSecrets && stdenv.hostPlatform.isLinux) [ - (lib.cmakeBool "WITH_XC_FDOSECRETS" true) - ] - ++ lib.optionals (withKeePassYubiKey && stdenv.hostPlatform.isLinux) [ - (lib.cmakeBool "WITH_XC_YUBIKEY" true) - ] - ++ lib.optionals withKeePassBrowser [ - (lib.cmakeBool "WITH_XC_BROWSER" true) - ] - ++ lib.optionals withKeePassBrowserPasskeys [ - (lib.cmakeBool "WITH_XC_BROWSER_PASSKEYS" true) - ] - ++ lib.optionals withKeePassKeeShare [ - (lib.cmakeBool "WITH_XC_KEESHARE" true) - ] - ++ lib.optionals withKeePassNetworking [ - (lib.cmakeBool "WITH_XC_NETWORKING" true) - ] - ++ lib.optionals withKeePassSSHAgent [ - (lib.cmakeBool "WITH_XC_SSHAGENT" true) - ]; + 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 = '' From 65a178ade63ae78f227f96f9a56bd6979fbfd2f4 Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Mon, 14 Apr 2025 19:05:36 +0200 Subject: [PATCH 4/5] keepassxc: refactor and update the skipped tests --- pkgs/by-name/ke/keepassxc/package.nix | 39 ++++++++++++++++++++------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/pkgs/by-name/ke/keepassxc/package.nix b/pkgs/by-name/ke/keepassxc/package.nix index 18f7b02495d7..d62ea8fd7e6d 100644 --- a/pkgs/by-name/ke/keepassxc/package.nix +++ b/pkgs/by-name/ke/keepassxc/package.nix @@ -74,18 +74,37 @@ stdenv.mkDerivation (finalAttrs: { ]; doCheck = true; - checkPhase = '' - runHook preCheck + checkPhase = + let + disabledTests = lib.concatStringsSep "|" ( + [ + # flaky + "testcli" + "testgui" + ] + ++ lib.optionals stdenv.hostPlatform.isDarwin [ + # QWidget: Cannot create a QWidget without QApplication + "testautotype" - export LC_ALL="en_US.UTF-8" - export QT_QPA_PLATFORM=offscreen - export QT_PLUGIN_PATH="${libsForQt5.qtbase.bin}/${libsForQt5.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" + # 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 - runHook postCheck - ''; + export LC_ALL="en_US.UTF-8" + export QT_QPA_PLATFORM=offscreen + export QT_PLUGIN_PATH="${libsForQt5.qtbase.bin}/${libsForQt5.qtbase.qtPluginPrefix}" + + make test ARGS+="-E '${disabledTests}' --output-on-failure" + + runHook postCheck + ''; nativeBuildInputs = [ asciidoctor From 10303baef489ce633b660296746668402846554a Mon Sep 17 00:00:00 2001 From: Gaetan Lepage Date: Wed, 16 Apr 2025 14:43:03 +0200 Subject: [PATCH 5/5] keepassxc: remove unnecessary LocalAuthentication dependency on darwin --- pkgs/by-name/ke/keepassxc/package.nix | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkgs/by-name/ke/keepassxc/package.nix b/pkgs/by-name/ke/keepassxc/package.nix index d62ea8fd7e6d..170cc7bfe8e3 100644 --- a/pkgs/by-name/ke/keepassxc/package.nix +++ b/pkgs/by-name/ke/keepassxc/package.nix @@ -23,15 +23,12 @@ wrapGAppsHook3, zlib, - darwin, - withKeePassBrowser ? true, withKeePassBrowserPasskeys ? true, withKeePassFDOSecrets ? stdenv.hostPlatform.isLinux, withKeePassKeeShare ? true, withKeePassNetworking ? true, withKeePassSSHAgent ? true, - withKeePassTouchID ? true, withKeePassX11 ? true, withKeePassYubiKey ? stdenv.hostPlatform.isLinux, @@ -154,9 +151,6 @@ stdenv.mkDerivation (finalAttrs: { readline zlib ] - ++ lib.optionals (stdenv.hostPlatform.isDarwin && withKeePassTouchID) [ - darwin.apple_sdk_11_0.frameworks.LocalAuthentication - ] ++ lib.optionals stdenv.hostPlatform.isDarwin [ libsForQt5.qtmacextras