summaryrefslogtreecommitdiff
path: root/modules
diff options
context:
space:
mode:
authorChris Wells <chris@mathematicaster.org>2026-10-28 11:49:51 -0400
committerChris Wells <chris@mathematicaster.org>2026-10-28 11:49:51 -0400
commitb87ced9a95fd0de4e3631e67cc5a7a929adee464 (patch)
tree3f02b2679ba3397fbbc5b172cfa613b2f6c93134 /modules
parentf9bdbf51aa61503d77e387095e7a4e1f34acdde3 (diff)
downloadko-manager-b87ced9a95fd0de4e3631e67cc5a7a929adee464.tar
ko-manager-b87ced9a95fd0de4e3631e67cc5a7a929adee464.tar.gz
ko-manager-b87ced9a95fd0de4e3631e67cc5a7a929adee464.tar.bz2
ko-manager-b87ced9a95fd0de4e3631e67cc5a7a929adee464.tar.lz
ko-manager-b87ced9a95fd0de4e3631e67cc5a7a929adee464.tar.xz
ko-manager-b87ced9a95fd0de4e3631e67cc5a7a929adee464.tar.zst
ko-manager-b87ced9a95fd0de4e3631e67cc5a7a929adee464.zip
Working concept with an instance for my pocketbook
Diffstat (limited to 'modules')
-rw-r--r--modules/default.nix64
-rw-r--r--modules/files.nix41
-rw-r--r--modules/main.nix23
3 files changed, 94 insertions, 34 deletions
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 "";
+ };
+ })
];
}