diff options
| -rw-r--r-- | flake.nix | 62 | ||||
| -rw-r--r-- | instances/pocketbook.nix | 38 | ||||
| -rw-r--r-- | modules/default.nix | 64 | ||||
| -rw-r--r-- | modules/files.nix | 41 | ||||
| -rw-r--r-- | modules/main.nix | 23 | ||||
| -rw-r--r-- | overlays/default.nix | 6 | ||||
| -rw-r--r-- | pkgs/patches.nix | 3 | ||||
| -rw-r--r-- | pkgs/plugins.nix | 8 | ||||
| -rw-r--r-- | pkgs/pocketbook.nix | 5 |
9 files changed, 169 insertions, 81 deletions
@@ -11,39 +11,45 @@ }; }; - outputs = inputs@{self, ...}: inputs.flake-parts.lib.mkFlake { inherit inputs self; } { - systems = import inputs.systems; + outputs = + inputs@{ self, ... }: + inputs.flake-parts.lib.mkFlake { inherit inputs self; } { + systems = import inputs.systems; - flake.overlays.default = import ./overlays; + imports = [ + inputs.treefmt-nix.flakeModule + ./modules + ]; - imports = [ - inputs.treefmt-nix.flakeModule - ./modules - ]; + perSystem = + { + pkgs, + config, + system, + ... + }: + { + treefmt = { + programs = { + nixfmt = { + enable = true; + strict = true; + }; + }; + }; - perSystem = { pkgs, config, system, ... }: { - _module.args.pkgs = import inputs.nixpkgs { - inherit system; - overlays = [ self.overlays.default ]; - }; + devShells.default = pkgs.mkShellNoCC { + inputsFrom = [ config.treefmt.build.devShell ]; + nativeBuildInputs = with pkgs; [ + nixd + statix + deadnix + ]; + }; - treefmt = { - programs = { - nixfmt = { - enable = true; - strict = true; + koreader = { + pocketbook = ./instances/pocketbook.nix; }; }; - }; - - devShells.default = pkgs.mkShellNoCC { - inputsFrom = [ config.treefmt.build.devShell ]; - nativeBuildInputs = with pkgs; [ - nixd - statix - deadnix - ]; - }; }; - }; } diff --git a/instances/pocketbook.nix b/instances/pocketbook.nix index 905cf79..9d4af86 100644 --- a/instances/pocketbook.nix +++ b/instances/pocketbook.nix @@ -5,10 +5,46 @@ ... }: with builtins // lib; +let + pocketbooksync = pkgs.fetchzip { + url = "https://github.com/ckilb/pocketbooksync.koplugin/releases/download/v1.0.2/pocketbooksync.koplugin-v1.0.2.zip"; + }; + wifi = pkgs.fetchFromGitHub { + owner = "Lomig"; + repo = "koreader-pocketbook-wifi"; + rev = "1278fe9"; + }; + +in { koreader.flavor = "pocketbook"; plugins = { - pocketbooksync = "${pkgs.koreader-plugins.pocketbooksync}/pocketbooksync.koplugin"; + pocketbooksync = "${pocketbooksync}/pocketbooksync.koplugin"; + }; + + # patches = { + # "2-bookorbit-wifi-cycle.lua" = "${wifi}/patches/2-bookorbit-wifi-cycle.lua"; + # "2-menu-footer-wifi-icon.lua" = "${wifi}/patches/2-menu-footer-wifi-icon.lua"; + # "2-pocketbook-net-diag.lua" = "${wifi}/patches/2-pocketbook-net-diag.lua"; + # "2-pocketbook-wifi-off.lua" = "${wifi}/pathces/2-pocketbook-wifi-off.lua"; + # "2-pocketbook-wifi-silent-connect.lua" = "${wifi}/patches/2-pocketbook-wifi-silent-connect.lua"; + # }; + patchDirectories = [ + "${wifi}/patches" + ]; + + dictionaries = { + Wiktionary = pkgs.fetchtar { + url = "https://github.com/xxyzz/wiktionary_stardict/releases/download/20261020/en-en.tar.zst"; + }; + GNU = pkgs.fetchzip { + url = "http://tovotu.de/data/stardict/gcide.zip"; + }; + }; + + fonts = { + Alegreya = "${pkgs.alegreya}/share/fonts/truetype"; + ComputerModern = "${pkgs.cm_unicode}/share/fonts/opentype"; }; } diff --git a/modules/default.nix b/modules/default.nix index d32d8f6..d32cbe4 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -2,26 +2,48 @@ let inherit (lib) mkOption mkEnableOption types; inherit (flake-parts-lib) mkPerSystemOption; -in { - options.perSystem = mkPerSystemOption ({ pkgs, system, config, ... }: { - options.koreader = mkOption { - default = {}; - type = types.lazyAttrsOf <| types.submoduleWith { - shorthandOnlyDefinesConfig = true; - modules = [ - { - _module.args = { - inherit pkgs lib; - }; - } - ({ name, ... }: { - imports = [ ./main.nix ]; - options = { - enable = mkEnableOption name // { default = true; }; - }; - }) - ]; +in +{ + options.perSystem = mkPerSystemOption ( + { + pkgs, + system, + config, + ... + }: + { + options.koreader = mkOption { + default = { }; + type = + types.lazyAttrsOf + <| types.submoduleWith { + shorthandOnlyDefinesConfig = true; + modules = [ + { + _module.args = { + inherit pkgs lib; + }; + } + ({ name, ... }: { + imports = [ ./main.nix ]; + options = { + enable = mkEnableOption name // { + default = true; + }; + }; + }) + ]; + }; }; - }; - }); + + config.packages = + let + koreaders = lib.filterAttrs (_: v: v.enable) config.koreader; + in + lib.mapAttrs' (name: value: { + name = "koreader-${name}"; + value = value.koreader.finalPackage; + }) koreaders; + } + ); } diff --git a/modules/files.nix b/modules/files.nix index dbd9c6b..14b5319 100644 --- a/modules/files.nix +++ b/modules/files.nix @@ -49,12 +49,13 @@ with builtins // lib; internal = true; default = pkgs.linkFarm "files" - <| flip mapAttrsToList config.files ( + <| mapAttrsToList ( _: { destination, source, ... }: { name = destination; path = source; } - ); + ) + <| filterAttrs (_: v: v.enable) config.files; }; dictionaries = mkOption { @@ -76,6 +77,10 @@ with builtins // lib; default = { }; type = with types; attrsOf path; }; + + patchDirectories = mkOption { + type = with types; listOf path; + }; }; config = { @@ -107,15 +112,31 @@ with builtins // lib; }; } )) - (flip mapAttrs' config.patches ( - name: source: { - name = "patch::${name}"; - value = { - destination = "patches/${name}"; - inherit source; + (mkIf (config.patchDirectories != [ ]) { + "patches" = { + source = pkgs.symlinkJoin { + name = "patches"; + paths = config.patchDirectories; }; - } - )) + }; + }) + # (flip mapAttrs' config.patches ( + # name: source: { + # name = "patch::${name}"; + # value = { + # destination = "patches/${name}"; + # inherit source; + # }; + # } + # )) ]; + + patchDirectories = mkIf (config.patches != { }) [ + ( + pkgs.linkFarm "individual-patches" + <| mapAttrsToList (name: path: { inherit name path; }) config.patches + ) + ]; + }; } diff --git a/modules/main.nix b/modules/main.nix index b568efa..974f599 100644 --- a/modules/main.nix +++ b/modules/main.nix @@ -17,32 +17,49 @@ with builtins // lib; with types; nullOr <| enum [ + "raw" "kobo" "pocketbook" ]; default = null; }; basePackage = mkOption { - type = types.package; + 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.koreader-kobo; + basePackage = mkOptionDefault <| pkgs.callPackage ../pkgs/kobo.nix { }; koreaderPath = mkOptionDefault ".adds/koreader"; }; }) (mkIf (config.koreader.flavor == "pocketbook") { koreader = { - basePackage = mkOptionDefault pkgs.koreader-pocketbook; + 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 ""; + }; + }) ]; } diff --git a/overlays/default.nix b/overlays/default.nix deleted file mode 100644 index b5dc8f9..0000000 --- a/overlays/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -_final: prev: { - koreader-kobo = prev.callPackage ../pkgs/kobo.nix; - koreader-pocketbook = prev.callPackage ../pkgs/pocketbook.nix; - koreader-plugins = prev.callPackage ../pkgs/plugins.nix; - koreader-patches = prev.callPackage ../pkgs/patches.nix; -} diff --git a/pkgs/patches.nix b/pkgs/patches.nix deleted file mode 100644 index 0a3181d..0000000 --- a/pkgs/patches.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ fetchFromGitHub }: -{ -} diff --git a/pkgs/plugins.nix b/pkgs/plugins.nix deleted file mode 100644 index f41724a..0000000 --- a/pkgs/plugins.nix +++ /dev/null @@ -1,8 +0,0 @@ -{ fetchFromGitHub }: -{ - pocketbooksync = fetchFromGitHub { - owner = "ckilb"; - repo = "pocketbooksync.koplugin"; - tag = "v1.0.2"; - }; -} diff --git a/pkgs/pocketbook.nix b/pkgs/pocketbook.nix index 2196705..4cbeadf 100644 --- a/pkgs/pocketbook.nix +++ b/pkgs/pocketbook.nix @@ -1,4 +1,7 @@ { fetchzip }: +let + version = "2026.07.1"; +in fetchzip { - url = "https://github.com/koreader/koreader/releases/download/v2026.07.1/koreader-pocketbook-v2026.07.1.zip"; + url = "https://github.com/koreader/koreader/releases/download/v${version}/koreader-pocketbook-v${version}.zip"; } |
