evcc: 0.131.4 -> 0.131.5
[NixPkgs.git] / pkgs / by-name / ko / koodo-reader / package.nix
blob2d5132fb4cbea1e7289ea4429f5cd59635ece68e
2   lib,
3   stdenv,
4   fetchFromGitHub,
5   fetchYarnDeps,
6   yarnConfigHook,
7   yarnBuildHook,
8   nodejs,
9   makeDesktopItem,
10   copyDesktopItems,
11   makeWrapper,
12   wrapGAppsHook3,
13   electron,
16 stdenv.mkDerivation (finalAttrs: {
17   pname = "koodo-reader";
18   version = "1.6.7";
20   src = fetchFromGitHub {
21     owner = "troyeguo";
22     repo = "koodo-reader";
23     rev = "v${finalAttrs.version}";
24     hash = "sha256-ZHRU8dJjKQFLIB1t2VK/COy6a3nShUeWR8iAM9YJdto=";
25   };
27   offlineCache = fetchYarnDeps {
28     yarnLock = "${finalAttrs.src}/yarn.lock";
29     hash = "sha256-58mxYt2wD6SGzhvo9c44CPmdX+/tLnbJCMPafo4txbY=";
30   };
32   nativeBuildInputs =
33     [
34       makeWrapper
35       yarnConfigHook
36       yarnBuildHook
37       nodejs
38     ]
39     ++ lib.optionals (!stdenv.hostPlatform.isDarwin) [
40       copyDesktopItems
41       wrapGAppsHook3
42     ];
44   dontWrapGApps = true;
46   env.ELECTRON_SKIP_BINARY_DOWNLOAD = "1";
48   # disable code signing on Darwin
49   env.CSC_IDENTITY_AUTO_DISCOVERY = "false";
51   postBuild = ''
52     cp -r ${electron.dist} electron-dist
53     chmod -R u+w electron-dist
54     yarn --offline run electron-builder --dir \
55       -c.electronDist=electron-dist \
56       -c.electronVersion=${electron.version}
57   '';
59   installPhase = ''
60     runHook preInstall
62     ${lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
63       install -Dm644 assets/icons/256x256.png $out/share/icons/hicolor/256x256/apps/koodo-reader.png
64       install -Dm644 ${./mime-types.xml} $out/share/mime/packages/koodo-reader.xml
66       mkdir -p $out/share/lib/koodo-reader
67       cp -r dist/*-unpacked/{locales,resources{,.pak}} $out/share/lib/koodo-reader
68     ''}
70     ${lib.optionalString stdenv.hostPlatform.isDarwin ''
71       mkdir -p $out/Applications
72       cp -r dist/mac*/"Koodo Reader.app" $out/Applications
73       makeWrapper "$out/Applications/Koodo Reader.app/Contents/MacOS/Koodo Reader" $out/bin/koodo-reader
74     ''}
76     runHook postInstall
77   '';
79   # we use makeShellWrapper instead of the makeBinaryWrapper provided by wrapGAppsHook for proper shell variable expansion
80   postFixup = lib.optionalString (!stdenv.hostPlatform.isDarwin) ''
81     makeShellWrapper ${lib.getExe electron} $out/bin/koodo-reader \
82       --add-flags $out/share/lib/koodo-reader/resources/app.asar \
83       "''${gappsWrapperArgs[@]}" \
84       --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform-hint=auto --enable-features=WaylandWindowDecorations}}" \
85       --set-default ELECTRON_IS_DEV 0 \
86       --inherit-argv0
87   '';
89   desktopItems = [
90     (makeDesktopItem {
91       name = "koodo-reader";
92       desktopName = "Koodo Reader";
93       exec = "koodo-reader %U";
94       icon = "koodo-reader";
95       comment = finalAttrs.meta.description;
96       categories = [ "Office" ];
97       mimeTypes = [
98         "application/epub+zip"
99         "application/pdf"
100         "image/vnd.djvu"
101         "application/x-mobipocket-ebook"
102         "application/vnd.amazon.ebook"
103         "application/vnd.amazon.ebook"
104         "application/x-cbz"
105         "application/x-cbr"
106         "application/x-cbt"
107         "application/x-cb7"
108         "application/x-fictionbook+xml"
109       ];
110       startupWMClass = "Koodo Reader";
111       terminal = false;
112     })
113   ];
115   meta = {
116     changelog = "https://github.com/troyeguo/koodo-reader/releases/tag/v${finalAttrs.version}";
117     description = "Cross-platform ebook reader";
118     longDescription = ''
119       A modern ebook manager and reader with sync and backup capacities
120       for Windows, macOS, Linux and Web
121     '';
122     homepage = "https://github.com/troyeguo/koodo-reader";
123     license = lib.licenses.agpl3Only;
124     mainProgram = "koodo-reader";
125     maintainers = with lib.maintainers; [ tomasajt ];
126     platforms = electron.meta.platforms;
127   };