System Gen24 @ 2026-08-05-16:22:31 by jonas@harbor

This commit is contained in:
2026-08-05 16:22:33 +02:00
parent 80ebbb7078
commit 03a0a0a229
2 changed files with 26 additions and 15 deletions
+1
View File
@@ -100,6 +100,7 @@
hive.matrix.registrationSecretSopsKey = config.sops.secrets.hidden-matrix-registration-secret.name; hive.matrix.registrationSecretSopsKey = config.sops.secrets.hidden-matrix-registration-secret.name;
hive.calibre.enable = true; hive.calibre.enable = true;
hive.calibre.instanceFQDN = "calibre.jroeger.de"; hive.calibre.instanceFQDN = "calibre.jroeger.de";
hive.calibre.libraries = ["Rote Bücher" "Fiction"];
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions # settings for stateful data, like file locations and database versions
+25 -15
View File
@@ -9,8 +9,24 @@
calibre = config.services.calibre-server.package; calibre = config.services.calibre-server.package;
calibre-user = config.services.calibre-server.user; calibre-user = config.services.calibre-server.user;
calibre-group = config.services.calibre-server.group; calibre-group = config.services.calibre-server.group;
calibre-library = "${cfg.basePath}/library";
calibre-users = "${cfg.basePath}/users.sqlite"; calibre-users = "${cfg.basePath}/users.sqlite";
libraries = map (n: "${cfg.basePath}/${n}") cfg.libraries;
ensure-libs = lib.concatStrings (
map (l: ''
if [ ! -d "${l}" ]; then
echo "Creating Calibre libraray directory \"${l}\""
mkdir "${l}"
chown ${calibre-user}:${calibre-group} "${l}"
fi
if [ ! -f "${l}/metadata.db" ]; then
echo "Creating Calibre libraray metadata \"${l}\""
${calibre}/bin/calibredb --with-library="${l}" list
chown -R ${calibre-user}:${calibre-group} "${l}"
fi
'')
libraries
);
in { in {
options.hive.calibre = { options.hive.calibre = {
enable = lib.mkEnableOption "Enable calibre server"; enable = lib.mkEnableOption "Enable calibre server";
@@ -31,6 +47,12 @@
example = "calibre.example.com"; example = "calibre.example.com";
description = "Fully qualified domain name of the calibre instance"; description = "Fully qualified domain name of the calibre instance";
}; };
libraries = lib.mkOption {
type = lib.types.listOf lib.types.singleLineStr;
example = ["library1" "private" "foo"];
default = ["library"];
description = "A list of libraries to serve. (Must be present in the base-path, will be initialized if not existing)";
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
@@ -44,9 +66,7 @@
host = "::1"; host = "::1";
port = cfg.localPort; port = cfg.localPort;
libraries = [ inherit libraries;
"${calibre-library}"
];
}; };
# Virtual host for calibre # Virtual host for calibre
@@ -80,17 +100,7 @@
chown ${calibre-user}:${calibre-group} ${cfg.basePath} chown ${calibre-user}:${calibre-group} ${cfg.basePath}
fi fi
if [ ! -d ${calibre-library} ]; then ${ensure-libs}
echo "Creating Calibre libraray directory \"${calibre-library}\""
mkdir ${calibre-library}
chown ${calibre-user}:${calibre-group} ${calibre-library}
fi
if [ ! -f ${calibre-library}/metadata.db ]; then
echo "Creating Calibre libraray metadata \"${calibre-library}\""
${calibre}/bin/calibredb --with-library=${calibre-library} list
chown -R ${calibre-user}:${calibre-group} ${calibre-library}
fi
''; '';
RemainAfterExit = true; RemainAfterExit = true;