aboutsummaryrefslogtreecommitdiff
path: root/modules/kobo.nix
diff options
context:
space:
mode:
Diffstat (limited to 'modules/kobo.nix')
-rw-r--r--modules/kobo.nix61
1 files changed, 61 insertions, 0 deletions
diff --git a/modules/kobo.nix b/modules/kobo.nix
new file mode 100644
index 0000000..d46da7e
--- /dev/null
+++ b/modules/kobo.nix
@@ -0,0 +1,61 @@
+{ config, pkgs, lib, ... }:
+with builtins // lib;
+let
+ cfg = config.kobo;
+in {
+ imports = [
+ ./kfmon.nix
+ ./koreader.nix
+ ./plato.nix
+ ];
+
+ options.kobo = {
+ package = mkOption {
+ type = types.package;
+ description = "The resulting kobo configuration";
+ default = if cfg.generate == "" then cfg.src else pkgs.stdenvNoCC.mkDerivation {
+ inherit (cfg) src;
+ name = "kobo-config";
+
+ dontBuild = true;
+ dontFixup = true;
+ dontConfigure = true;
+ dontPatch = true;
+
+ installPhase = ''
+ mkdir -p $out
+ cp -rv . $out
+
+ ${cfg.generate}
+ '';
+ };
+ };
+
+ src = mkOption {
+ type = types.package;
+ description = "The base source files to use";
+ default = with pkgs.kobo.src;
+ if config.plato.enable && config.koreader.enable then KOReader-Plato
+ else if config.plato.enable then Plato
+ else if config.koreader.enable then KOReader
+ else if config.kfmon.enable then KFMon
+ else error "At least one of plato, koreader or kfmon must be enabled in order to use a default package";
+ };
+
+ generate = mkOption {
+ type = types.lines;
+ default = "";
+ description = "Script used to generate the kobo config";
+ };
+ };
+
+ config = {
+ kobo = {
+ generate = mkBefore (concatStringsSep "\n" (
+ optional config.kfmon.enable config.kfmon.generate ++
+ optional config.plato.enable config.plato.generate ++
+ optional config.koreader.enable config.koreader.generate
+ ));
+ };
+ };
+}