biglybt: 3.5.0.0 -> 3.6.0.0
[NixPkgs.git] / pkgs / applications / misc / keepassxc / default.nix
blobe74a45c02f311ffb0077673e7b491b96ab243713
1 { lib
2 , stdenv
3 , fetchFromGitHub
4 , cmake
5 , qttools
7 , asciidoctor
8 , botan2
9 , curl
10 , libXi
11 , libXtst
12 , libargon2
13 , libusb1
14 , minizip
15 , pcsclite
16 , pkg-config
17 , qrencode
18 , qtbase
19 , qtmacextras
20 , qtsvg
21 , qtx11extras
22 , readline
23 , wrapGAppsHook
24 , wrapQtAppsHook
25 , zlib
27 , LocalAuthentication
29 , withKeePassBrowser ? true
30 , withKeePassBrowserPasskeys ? true
31 , withKeePassFDOSecrets ? true
32 , withKeePassKeeShare ? true
33 , withKeePassNetworking ? true
34 , withKeePassSSHAgent ? true
35 , withKeePassTouchID ? true
36 , withKeePassX11 ? true
37 , withKeePassYubiKey ? true
39 , nixosTests
42 stdenv.mkDerivation rec {
43   pname = "keepassxc";
44   version = "2.7.7";
46   src = fetchFromGitHub {
47     owner = "keepassxreboot";
48     repo = "keepassxc";
49     rev = version;
50     hash = "sha256-HjDzb1H3eMSraKbfHgg9S+w4TXNt40lQkDz+EChb5Ks=";
51   };
53   env.NIX_CFLAGS_COMPILE = lib.optionalString stdenv.cc.isClang (toString [
54     "-Wno-old-style-cast"
55     "-Wno-error"
56     "-D__BIG_ENDIAN__=${if stdenv.isBigEndian then "1" else "0"}"
57   ]);
59   NIX_LDFLAGS = lib.optionalString stdenv.isDarwin "-rpath ${libargon2}/lib";
61   patches = [
62     ./darwin.patch
63   ];
65   cmakeFlags = [
66     "-DKEEPASSXC_BUILD_TYPE=Release"
67     "-DWITH_GUI_TESTS=ON"
68     "-DWITH_XC_UPDATECHECK=OFF"
69   ]
70   ++ (lib.optional (!withKeePassX11) "-DWITH_XC_X11=OFF")
71   ++ (lib.optional (withKeePassFDOSecrets && stdenv.isLinux) "-DWITH_XC_FDOSECRETS=ON")
72   ++ (lib.optional (withKeePassYubiKey && stdenv.isLinux) "-DWITH_XC_YUBIKEY=ON")
73   ++ (lib.optional withKeePassBrowser "-DWITH_XC_BROWSER=ON")
74   ++ (lib.optional withKeePassBrowserPasskeys "-DWITH_XC_BROWSER_PASSKEYS=ON")
75   ++ (lib.optional withKeePassKeeShare "-DWITH_XC_KEESHARE=ON")
76   ++ (lib.optional withKeePassNetworking "-DWITH_XC_NETWORKING=ON")
77   ++ (lib.optional withKeePassSSHAgent "-DWITH_XC_SSHAGENT=ON");
79   doCheck = true;
80   checkPhase = ''
81     runHook preCheck
83     export LC_ALL="en_US.UTF-8"
84     export QT_QPA_PLATFORM=offscreen
85     export QT_PLUGIN_PATH="${qtbase.bin}/${qtbase.qtPluginPrefix}"
86     # testcli, testgui and testkdbx4 are flaky - skip them all
87     # testautotype on darwin throws "QWidget: Cannot create a QWidget without QApplication"
88     make test ARGS+="-E 'testcli|testgui${lib.optionalString stdenv.isDarwin "|testautotype|testkdbx4"}' --output-on-failure"
90     runHook postCheck
91   '';
93   nativeBuildInputs = [
94     asciidoctor
95     cmake
96     wrapQtAppsHook
97     qttools
98     pkg-config
99   ]
100   ++ lib.optional (!stdenv.isDarwin) wrapGAppsHook;
102   dontWrapGApps = true;
103   preFixup = ''
104     qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
105   '' + lib.optionalString stdenv.isDarwin ''
106     wrapQtApp "$out/Applications/KeePassXC.app/Contents/MacOS/KeePassXC"
107   '';
109   # See https://github.com/keepassxreboot/keepassxc/blob/cd7a53abbbb81e468efb33eb56eefc12739969b8/src/browser/NativeMessageInstaller.cpp#L317
110   postInstall = lib.optionalString withKeePassBrowser ''
111     mkdir -p "$out/lib/mozilla/native-messaging-hosts"
112     substituteAll "${./firefox-native-messaging-host.json}" "$out/lib/mozilla/native-messaging-hosts/org.keepassxc.keepassxc_browser.json"
113   '';
115   buildInputs = [
116     curl
117     botan2
118     libXi
119     libXtst
120     libargon2
121     minizip
122     pcsclite
123     qrencode
124     qtbase
125     qtsvg
126     readline
127     zlib
128   ]
129   ++ lib.optional (stdenv.isDarwin && withKeePassTouchID) LocalAuthentication
130   ++ lib.optional stdenv.isDarwin qtmacextras
131   ++ lib.optional stdenv.isLinux libusb1
132   ++ lib.optional withKeePassX11 qtx11extras;
134   passthru.tests = nixosTests.keepassxc;
136   meta = with lib; {
137     description = "Offline password manager with many features.";
138     longDescription = ''
139       A community fork of KeePassX, which is itself a port of KeePass Password Safe.
140       The goal is to extend and improve KeePassX with new features and bugfixes,
141       to provide a feature-rich, fully cross-platform and modern open-source password manager.
142       Accessible via native cross-platform GUI, CLI, has browser integration
143       using the KeePassXC Browser Extension (https://github.com/keepassxreboot/keepassxc-browser)
144     '';
145     homepage = "https://keepassxc.org/";
146     license = licenses.gpl2Plus;
147     maintainers = with maintainers; [ jonafato blankparticle ];
148     platforms = platforms.linux ++ platforms.darwin;
149   };