about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--hosts/home.nix2
-rw-r--r--overlays/base.nix19
-rw-r--r--packages/default.nix1
-rw-r--r--packages/kindlegen/default.nix52
-rw-r--r--patches/kcc.patch30
5 files changed, 104 insertions, 0 deletions
diff --git a/hosts/home.nix b/hosts/home.nix
index 7b7482c..ef9bb98 100644
--- a/hosts/home.nix
+++ b/hosts/home.nix
@@ -36,6 +36,8 @@ in
     custom.anime-downloader
     custom.adl
     custom.trackma
+    kcc
+    custom.kindlegen
   ];
 
   services.gpg-agent = {
diff --git a/overlays/base.nix b/overlays/base.nix
index 8685995..681fa64 100644
--- a/overlays/base.nix
+++ b/overlays/base.nix
@@ -42,4 +42,23 @@ final: prev:
       };
     };
   };
+
+  kcc = prev.kcc.overrideAttrs (oldAttrs: {
+    version = "5.5.2";
+    src = prev.fetchFromGitHub {
+      owner = "ciromattia";
+      repo = "kcc";
+      rev = "4ec4c9966c727d6dac44507d34607bd7d2c5ed5c";
+      sha256 = "sha256-vH3Cz7nL+sStogcCRLcN30Iap25f5hylXHECX52G4f0=";
+    };
+    patches = [
+      ../patches/kcc.patch
+      (prev.fetchpatch
+        {
+          url = "https://github.com/Baitinq/kcc/commit/73cd0dd107901bebe7d72e2b86ecf8b830a19758.diff";
+          sha256 = "sha256-UsWTwujCmKsFrPUHIx8O8ELHpXFQdEbBRZh5SbPPWBM=";
+        })
+    ];
+  });
+
 }
diff --git a/packages/default.nix b/packages/default.nix
index 4b239d7..508561c 100644
--- a/packages/default.nix
+++ b/packages/default.nix
@@ -6,4 +6,5 @@ final: prev:
   custom.trackma = prev.callPackage ./trackma { };
   custom.anime-downloader = prev.callPackage ./anime-downloader { pkgs = prev; };
   custom.adl = prev.callPackage ./adl { anime-downloader = final.custom.anime-downloader; trackma = final.custom.trackma; };
+  custom.kindlegen = prev.callPackage ./kindlegen { };
 }
diff --git a/packages/kindlegen/default.nix b/packages/kindlegen/default.nix
new file mode 100644
index 0000000..e2000b4
--- /dev/null
+++ b/packages/kindlegen/default.nix
@@ -0,0 +1,52 @@
+{ fetchurl, lib, stdenv, unzip }:
+
+let
+  version = "2.9";
+  fileVersion = builtins.replaceStrings [ "." ] [ "_" ] version;
+
+  sha256 = {
+    x86_64-linux = "sha256-2ZLFM5YcV2Ym38hxU8WMrRDjHDF6edqYohLeM+ASgpk=";
+    i686-linux = "15i20kzhdcmi94w7wfhqbl6j20v47cdakjm2mn3x8w495iddna4q";
+    x86_64-darwin = "0zniyn0s41fxqrajbgwxbcsj5vzf9m7a6yvdz2b11mphr00kpbbs";
+    i686-darwin = "0zniyn0s41fxqrajbgwxbcsj5vzf9m7a6yvdz2b11mphr00kpbbs";
+    x86_64-cygwin = "02slfh1bbpijay4skj85cjiv7z43ha8vm5aa1lwiqjk86qbl1f3h";
+    i686-cygwin = "02slfh1bbpijay4skj85cjiv7z43ha8vm5aa1lwiqjk86qbl1f3h";
+  }.${stdenv.hostPlatform.system} or (throw "system #{stdenv.hostPlatform.system.} is not supported");
+
+  url = {
+    x86_64-linux = "https://archive.org/download/kindlegen_linux_2_6_i386_v2_9/kindlegen_linux_2.6_i386_v2_9.tar.gz";
+    i686-linux = "http://kindlegen.s3.amazonaws.com/kindlegen_linux_2.6_i386_v${fileVersion}.tar.gz";
+    x86_64-darwin = "http://kindlegen.s3.amazonaws.com/KindleGen_Mac_i386_v${fileVersion}.zip";
+    i686-darwin = "http://kindlegen.s3.amazonaws.com/KindleGen_Mac_i386_v${fileVersion}.zip";
+    x86_64-cygwin = "http://kindlegen.s3.amazonaws.com/kindlegen_win32_v${fileVersion}.zip";
+    i686-cygwin = "http://kindlegen.s3.amazonaws.com/kindlegen_win32_v${fileVersion}.zip";
+  }.${stdenv.hostPlatform.system} or (throw "system #{stdenv.hostPlatform.system.} is not supported");
+
+in
+stdenv.mkDerivation {
+  pname = "kindlegen";
+  inherit version;
+
+  src = fetchurl {
+    inherit url;
+    inherit sha256;
+  };
+
+  sourceRoot = ".";
+
+  nativeBuildInputs = lib.optional (lib.hasSuffix ".zip" url) unzip;
+
+  installPhase = ''
+    mkdir -p $out/bin $out/share/kindlegen/doc
+    install -m755 kindlegen $out/bin/kindlegen
+    cp -r *.txt *.html docs/* $out/share/kindlegen/doc
+  '';
+
+  meta = with lib; {
+    description = "Convert documents to .mobi for use with Amazon Kindle";
+    homepage = "https://www.amazon.com/gp/feature.html?docId=1000765211";
+    license = licenses.unfree;
+    maintainers = with maintainers; [ peterhoeg ];
+    platforms = [ "x86_64-linux" "i686-linux" "x86_64-darwin" "i686-darwin" "x86_64-cygwin" "i686-cygwin" ];
+  };
+}
diff --git a/patches/kcc.patch b/patches/kcc.patch
new file mode 100644
index 0000000..73c754c
--- /dev/null
+++ b/patches/kcc.patch
@@ -0,0 +1,30 @@
+diff --git a/kindlecomicconverter/startup.py b/kindlecomicconverter/startup.py
+index c92579d..0217a76 100644
+--- a/kindlecomicconverter/startup.py
++++ b/kindlecomicconverter/startup.py
+@@ -25,7 +25,7 @@ from .shared import dependencyCheck
+ 
+ 
+ def start():
+-    dependencyCheck(3)
++    #dependencyCheck(3)
+     from . import KCC_gui
+     os.environ['QT_AUTO_SCREEN_SCALE_FACTOR'] = "1"
+     KCCAplication = KCC_gui.QApplicationMessaging(sys.argv)
+@@ -43,14 +43,14 @@ def start():
+ 
+ 
+ def startC2E():
+-    dependencyCheck(2)
++    #dependencyCheck(2)
+     from .comic2ebook import main
+     print('comic2ebook v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.')
+     sys.exit(main(sys.argv[1:]))
+ 
+ 
+ def startC2P():
+-    dependencyCheck(1)
++    #dependencyCheck(1)
+     from .comic2panel import main
+     print('comic2panel v' + __version__ + ' - Written by Ciro Mattia Gonano and Pawel Jastrzebski.')
+     sys.exit(main(sys.argv[1:]))