System Gen24 @ 2026-08-05-16:22:31 by jonas@harbor
This commit is contained in:
@@ -100,6 +100,7 @@
|
||||
hive.matrix.registrationSecretSopsKey = config.sops.secrets.hidden-matrix-registration-secret.name;
|
||||
hive.calibre.enable = true;
|
||||
hive.calibre.instanceFQDN = "calibre.jroeger.de";
|
||||
hive.calibre.libraries = ["Rote Bücher" "Fiction"];
|
||||
|
||||
# This value determines the NixOS release from which the default
|
||||
# settings for stateful data, like file locations and database versions
|
||||
|
||||
@@ -9,8 +9,24 @@
|
||||
calibre = config.services.calibre-server.package;
|
||||
calibre-user = config.services.calibre-server.user;
|
||||
calibre-group = config.services.calibre-server.group;
|
||||
calibre-library = "${cfg.basePath}/library";
|
||||
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 {
|
||||
options.hive.calibre = {
|
||||
enable = lib.mkEnableOption "Enable calibre server";
|
||||
@@ -31,6 +47,12 @@
|
||||
example = "calibre.example.com";
|
||||
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 {
|
||||
@@ -44,9 +66,7 @@
|
||||
host = "::1";
|
||||
port = cfg.localPort;
|
||||
|
||||
libraries = [
|
||||
"${calibre-library}"
|
||||
];
|
||||
inherit libraries;
|
||||
};
|
||||
|
||||
# Virtual host for calibre
|
||||
@@ -80,17 +100,7 @@
|
||||
chown ${calibre-user}:${calibre-group} ${cfg.basePath}
|
||||
fi
|
||||
|
||||
if [ ! -d ${calibre-library} ]; then
|
||||
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
|
||||
${ensure-libs}
|
||||
'';
|
||||
|
||||
RemainAfterExit = true;
|
||||
|
||||
Reference in New Issue
Block a user