{ config, pkgs, lib, ... }: with builtins // lib; { imports = [ ./files.nix ]; options = { koreader = { flavor = mkOption { type = with types; nullOr <| enum [ "raw" "kobo" "pocketbook" ]; default = null; }; basePackage = mkOption { type = types.path; }; koreaderPath = mkOption { type = types.str; }; finalPackage = mkOption { type = types.package; readOnly = true; default = pkgs.runCommandLocal "merge" { nativeBuildInputs = [ pkgs.rsync ]; } '' RSYNC="rsync -a --copy-links -v" $RSYNC "${config.koreader.basePackage}/" "$out/" $RSYNC "${config._files}/" "$out/${config.koreaderPath}/" ''; }; }; }; config = mkMerge [ (mkIf (config.koreader.flavor == "kobo") { koreader = { basePackage = mkOptionDefault <| pkgs.callPackage ../pkgs/kobo.nix { }; koreaderPath = mkOptionDefault ".adds/koreader"; }; }) (mkIf (config.koreader.flavor == "pocketbook") { koreader = { basePackage = mkOptionDefault <| pkgs.callPackage ../pkgs/pocketbook.nix { }; koreaderPath = mkOptionDefault "applications/koreader"; }; }) (mkIf (config.koreader.flavor == "raw") { koreader = { basePackage = mkOptionDefault <| pkgs.runCommandLocal "raw" { } "mkdir $out"; koreaderPath = mkOptionDefault ""; }; }) ]; }