aboutsummaryrefslogtreecommitdiff
path: root/modules/lib/manifest.nix
diff options
context:
space:
mode:
authorChris Wells <chris@mathematicaster.org>2024-02-14 15:13:20 -0600
committerChris Wells <chris@mathematicaster.org>2024-02-14 15:13:20 -0600
commitcbde891d1ced129f6284cbadade652182aa5d2fb (patch)
tree8c09770b3e4082dd3d205695e3d1827daba14ffc /modules/lib/manifest.nix
parent51ae706e6c007cdda2ebb8317c1d438dff9ed570 (diff)
downloadkobo-manager-cbde891d1ced129f6284cbadade652182aa5d2fb.tar
kobo-manager-cbde891d1ced129f6284cbadade652182aa5d2fb.tar.gz
kobo-manager-cbde891d1ced129f6284cbadade652182aa5d2fb.tar.bz2
kobo-manager-cbde891d1ced129f6284cbadade652182aa5d2fb.tar.lz
kobo-manager-cbde891d1ced129f6284cbadade652182aa5d2fb.tar.xz
kobo-manager-cbde891d1ced129f6284cbadade652182aa5d2fb.tar.zst
kobo-manager-cbde891d1ced129f6284cbadade652182aa5d2fb.zip
Fixing my earlier mistakes
Diffstat (limited to 'modules/lib/manifest.nix')
-rw-r--r--modules/lib/manifest.nix41
1 files changed, 41 insertions, 0 deletions
diff --git a/modules/lib/manifest.nix b/modules/lib/manifest.nix
new file mode 100644
index 0000000..1acb567
--- /dev/null
+++ b/modules/lib/manifest.nix
@@ -0,0 +1,41 @@
+{ pkgs, lib, ... }:
+with builtins // lib;
+
+basePath:
+rec {
+ option = mkOption {
+ type = manifestType;
+ default = {};
+ description = "Manifest relative to ${basePath}";
+ };
+ type = types.attrsOf (types.submodule ({ name, config, ... }: {
+ options = {
+ enable = mkEnableOption name // { default = true; };
+ targets = mkOption {
+ type = with types; listOf str;
+ default = [ name ];
+ apply = map (p: if basePath = "" || isPrefix basePath p then p else "${basePath}/${p}");
+ };
+ mergeTool = mkOption {
+ type = with types; functionTo (functionTo str);
+ description = ''
+ Sometimes we don't just want to overwrite the existing kobo file; instead we need to merge them.
+ This is the executable which does this.
+ The first argument is the local file and the second is the kobo file.
+ Note that the local file path and the kobo file path only disagree in their top-level directory and otherwise are the same path.
+ '';
+ example = ''
+ localFile: koboFile: "cp ''${localFile} ''${koboFile}"
+ '';
+ };
+ # remoteOnly = mkOption {
+ # type = types.bool;
+ # default = false;
+ # description = ''
+ # In general, the manifest only considers local files that match the target/pattern.
+ # Setting this to true means that the kobo files will be scanned and the provided mergeTool will be run with the first argument set to null.
+ # '';
+ # };
+ };
+ }))
+}