python3Packages.orjson: Disable failing tests on 32 bit
[NixPkgs.git] / pkgs / tools / security / cryptomator / default.nix
blob1e6833f3a8b30bad669a47eec554239cdc2a5d34
1 { lib, stdenv, fetchFromGitHub
2 , autoPatchelfHook
3 , fuse, jffi
4 , maven, jdk, jre, makeShellWrapper, glib, wrapGAppsHook
5 }:
7 let
8   pname = "cryptomator";
9   version = "1.6.14";
11   src = fetchFromGitHub {
12     owner = "cryptomator";
13     repo = "cryptomator";
14     rev = version;
15     sha256 = "sha256-ArOYL3xj2HiXXu1Bymd5mciMsmikCDvxr5M3LMqZgYA=";
16   };
18   # perform fake build to make a fixed-output derivation out of the files downloaded from maven central (120MB)
19   deps = stdenv.mkDerivation {
20     name = "cryptomator-${version}-deps";
21     inherit src;
23     nativeBuildInputs = [ jdk maven ];
24     buildInputs = [ jre ];
26     buildPhase = ''
27       while mvn -Plinux package -Dmaven.test.skip=true -Dmaven.repo.local=$out/.m2 -Dmaven.wagon.rto=5000; [ $? = 1 ]; do
28         echo "timeout, restart maven to continue downloading"
29       done
30     '';
32     # keep only *.{pom,jar,sha1,nbm} and delete all ephemeral files with lastModified timestamps inside
33     installPhase = ''
34       find $out/.m2 -type f -regex '.+\(\.lastUpdated\|resolver-status\.properties\|_remote\.repositories\)' -delete
35       find $out/.m2 -type f -iname '*.pom' -exec sed -i -e 's/\r\+$//' {} \;
36     '';
38     outputHashAlgo = "sha256";
39     outputHashMode = "recursive";
40     outputHash = "sha256-svpz1mHCHNQGWc+CBroAPvW4cXQdYuqFkK4JSmf6kXE=";
42     doCheck = false;
43   };
45 in stdenv.mkDerivation rec {
46   inherit pname version src;
48   buildPhase = ''
49     VERSION=${version}
50     SEMVER_STR=${version}
52     mvn -Plinux package --offline -Dmaven.test.skip=true -Dmaven.repo.local=$(cp -dpR ${deps}/.m2 ./ && chmod +w -R .m2 && pwd)/.m2
53   '';
56   # This is based on the instructins in https://github.com/cryptomator/cryptomator/blob/develop/dist/linux/appimage/build.sh
57   installPhase = ''
58     mkdir -p $out/bin/ $out/share/cryptomator/libs/ $out/share/cryptomator/mods/
60     cp target/libs/* $out/share/cryptomator/libs/
61     cp target/mods/* target/cryptomator-*.jar $out/share/cryptomator/mods/
63     # The bundeled jffi.so dosn't work on nixos and causes a segmentation fault
64     # we thus replace it with a version build by nixos
65     rm $out/share/cryptomator/libs/jff*.jar
66     cp -f ${jffi}/share/java/jffi-complete.jar $out/share/cryptomator/libs/
68     makeShellWrapper ${jre}/bin/java $out/bin/cryptomator \
69       --add-flags "--class-path '$out/share/cryptomator/libs/*'" \
70       --add-flags "--module-path '$out/share/cryptomator/mods'" \
71       --add-flags "-Dcryptomator.logDir='~/.local/share/Cryptomator/logs'" \
72       --add-flags "-Dcryptomator.pluginDir='~/.local/share/Cryptomator/plugins'" \
73       --add-flags "-Dcryptomator.settingsPath='~/.config/Cryptomator/settings.json'" \
74       --add-flags "-Dcryptomator.ipcSocketPath='~/.config/Cryptomator/ipc.socket'" \
75       --add-flags "-Dcryptomator.mountPointsDir='~/.local/share/Cryptomator/mnt'" \
76       --add-flags "-Dcryptomator.showTrayIcon=false" \
77       --add-flags "-Dcryptomator.buildNumber='nix'" \
78       --add-flags "-Dcryptomator.appVersion='${version}'" \
79       --add-flags "-Djdk.gtk.version=3" \
80       --add-flags "-Xss20m" \
81       --add-flags "-Xmx512m" \
82       --add-flags "-Djavafx.embed.singleThread=true " \
83       --add-flags "-Dawt.useSystemAAFontSettings=on" \
84       --add-flags "--module org.cryptomator.desktop/org.cryptomator.launcher.Cryptomator" \
85       --prefix PATH : "$out/share/cryptomator/libs/:${lib.makeBinPath [ jre glib ]}" \
86       --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ fuse ]}" \
87       --set JAVA_HOME "${jre.home}"
89     # install desktop entry and icons
90     cp -r ${src}/dist/linux/appimage/resources/AppDir/usr/* $out/
91     # The directory is read only when copied, enable read to install additional files
92     chmod +w -R $out/
93     cp ${src}/dist/linux/common/org.cryptomator.Cryptomator256.png $out/share/icons/hicolor/256x256/apps/org.cryptomator.Cryptomator.png
94     cp ${src}/dist/linux/common/org.cryptomator.Cryptomator512.png $out/share/icons/hicolor/512x512/apps/org.cryptomator.Cryptomator.png
95     cp ${src}/dist/linux/common/org.cryptomator.Cryptomator.svg $out/share/icons/hicolor/scalable/apps/org.cryptomator.Cryptomator.svg
96     cp ${src}/dist/linux/common/org.cryptomator.Cryptomator.desktop $out/share/applications/org.cryptomator.Cryptomator.desktop
97     cp ${src}/dist/linux/common/org.cryptomator.Cryptomator.metainfo.xml $out/share/metainfo/org.cryptomator.Cryptomator.metainfo.xml
98     cp ${src}/dist/linux/common/application-vnd.cryptomator.vault.xml $out/share/mime/packages/application-vnd.cryptomator.vault.xml
99   '';
101   nativeBuildInputs = [
102     autoPatchelfHook
103     maven
104     makeShellWrapper
105     wrapGAppsHook
106     jdk
107   ];
108   buildInputs = [ fuse jre glib jffi ];
110   meta = with lib; {
111     description = "Free client-side encryption for your cloud files";
112     homepage = "https://cryptomator.org";
113     sourceProvenance = with sourceTypes; [
114       fromSource
115       binaryBytecode  # deps
116     ];
117     license = licenses.gpl3Plus;
118     maintainers = with maintainers; [ bachp ];
119     platforms = platforms.linux;
120   };