mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-11 03:21:08 +01:00
calibre: add module
This commit is contained in:
parent
df7bac2b2b
commit
24cc5c080c
6 changed files with 60 additions and 0 deletions
44
modules/programs/calibre.nix
Normal file
44
modules/programs/calibre.nix
Normal file
|
|
@ -0,0 +1,44 @@
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
inherit (lib)
|
||||||
|
types
|
||||||
|
mkIf
|
||||||
|
mkEnableOption
|
||||||
|
mkPackageOption
|
||||||
|
mkOption
|
||||||
|
;
|
||||||
|
|
||||||
|
cfg = config.programs.calibre;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
meta.maintainers = with lib.hm.maintainers; [ aguirre-matteo ];
|
||||||
|
options.programs.calibre = {
|
||||||
|
enable = mkEnableOption "calibre";
|
||||||
|
package = mkPackageOption pkgs "calibre" { nullable = true; };
|
||||||
|
plugins = mkOption {
|
||||||
|
type = with types; listOf path;
|
||||||
|
default = [ ];
|
||||||
|
description = "List of plugins to install for calibre";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
home.packages = mkIf (cfg.package != null) [ cfg.package ];
|
||||||
|
xdg.configFile = mkIf (cfg.plugins != [ ]) (
|
||||||
|
let
|
||||||
|
symlinkedPlugins = pkgs.symlinkJoin {
|
||||||
|
name = "calibre-plugins";
|
||||||
|
paths = cfg.plugins;
|
||||||
|
};
|
||||||
|
in
|
||||||
|
lib.mapAttrs' (
|
||||||
|
k: _: lib.nameValuePair "calibre/plugins/${k}" { source = (symlinkedPlugins + "/${k}"); }
|
||||||
|
) (builtins.readDir symlinkedPlugins)
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
@ -27,6 +27,7 @@ let
|
||||||
"broot"
|
"broot"
|
||||||
"browserpass"
|
"browserpass"
|
||||||
"btop"
|
"btop"
|
||||||
|
"calibre"
|
||||||
"carapace"
|
"carapace"
|
||||||
"cava"
|
"cava"
|
||||||
"claude-code"
|
"claude-code"
|
||||||
|
|
|
||||||
1
tests/modules/programs/calibre/default.nix
Normal file
1
tests/modules/programs/calibre/default.nix
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
{ calibre-settings = ./settings.nix; }
|
||||||
0
tests/modules/programs/calibre/plugins/a/a.zip
Normal file
0
tests/modules/programs/calibre/plugins/a/a.zip
Normal file
0
tests/modules/programs/calibre/plugins/b/b.zip
Normal file
0
tests/modules/programs/calibre/plugins/b/b.zip
Normal file
14
tests/modules/programs/calibre/settings.nix
Normal file
14
tests/modules/programs/calibre/settings.nix
Normal file
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
programs.calibre = {
|
||||||
|
enable = true;
|
||||||
|
plugins = [
|
||||||
|
./plugins/a
|
||||||
|
./plugins/b
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
nmt.script = ''
|
||||||
|
assertFileExists home-files/.config/calibre/plugins/a.zip
|
||||||
|
assertFileExists home-files/.config/calibre/plugins/b.zip
|
||||||
|
'';
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue