mirror of
https://github.com/nmasur/dotfiles
synced 2024-11-10 01:42:55 +00:00
setup caddy and calibre-web
This commit is contained in:
parent
8a97d9b2da
commit
19de583433
@ -9,10 +9,10 @@ nixpkgs.lib.nixosSystem {
|
|||||||
home-manager.nixosModules.home-manager
|
home-manager.nixosModules.home-manager
|
||||||
{
|
{
|
||||||
networking.hostName = "oracle";
|
networking.hostName = "oracle";
|
||||||
|
bookServer = "books.masu.rs";
|
||||||
gui.enable = false;
|
gui.enable = false;
|
||||||
colorscheme = (import ../../modules/colorscheme/gruvbox);
|
colorscheme = (import ../../modules/colorscheme/gruvbox);
|
||||||
passwordHash =
|
passwordHash = null;
|
||||||
"$6$PZYiMGmJIIHAepTM$Wx5EqTQ5GApzXx58nvi8azh16pdxrN6Qrv1wunDlzveOgawitWzcIxuj76X9V868fsPi/NOIEO8yVXqwzS9UF.";
|
|
||||||
publicKey =
|
publicKey =
|
||||||
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s";
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s";
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
options = {
|
options = {
|
||||||
|
|
||||||
passwordHash = lib.mkOption {
|
passwordHash = lib.mkOption {
|
||||||
type = lib.types.str;
|
type = lib.types.nullOr lib.types.str;
|
||||||
description = "Password created with mkpasswd -m sha-512";
|
description = "Password created with mkpasswd -m sha-512";
|
||||||
# Test it by running: mkpasswd -m sha-512 --salt "PZYiMGmJIIHAepTM"
|
# Test it by running: mkpasswd -m sha-512 --salt "PZYiMGmJIIHAepTM"
|
||||||
};
|
};
|
||||||
|
@ -2,27 +2,67 @@
|
|||||||
|
|
||||||
let
|
let
|
||||||
|
|
||||||
libraryPath = "/var/lib/calibre-server";
|
# Must set group owner to calibre-web
|
||||||
|
libraryPath = "/var/books";
|
||||||
|
|
||||||
in {
|
in {
|
||||||
|
|
||||||
options = { };
|
options = {
|
||||||
|
bookServer = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
description = "Hostname for Calibre library";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
services.calibre-server = {
|
|
||||||
enable = true;
|
|
||||||
libraries = [ libraryPath ];
|
|
||||||
};
|
|
||||||
|
|
||||||
services.calibre-web = {
|
services.calibre-web = {
|
||||||
enable = true;
|
enable = true;
|
||||||
openFirewall = true;
|
openFirewall = true;
|
||||||
options = {
|
options = {
|
||||||
|
calibreLibrary = libraryPath;
|
||||||
reverseProxyAuth.enable = false;
|
reverseProxyAuth.enable = false;
|
||||||
enableBookConversion = true;
|
enableBookConversion = true;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.caddy = {
|
||||||
|
enable = true;
|
||||||
|
adapter = "''"; # Required to enable JSON
|
||||||
|
configFile = pkgs.writeText "Caddyfile" (builtins.toJSON {
|
||||||
|
apps.http.servers = {
|
||||||
|
calibre = {
|
||||||
|
listen = [ ":443" ];
|
||||||
|
routes = [{
|
||||||
|
match = [{ host = [ config.bookServer ]; }];
|
||||||
|
handle = [{
|
||||||
|
handler = "reverse_proxy";
|
||||||
|
upstreams = [{ dial = "localhost:8083"; }];
|
||||||
|
headers.request.add."X-Script-Name" = [ "/calibre-web" ];
|
||||||
|
}];
|
||||||
|
}];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
networking.firewall.interfaces.calibre = { allowedTCPPorts = [ 80 443 ]; };
|
||||||
|
|
||||||
|
# Create directory and set permissions
|
||||||
|
system.activationScripts.calibreLibrary.text = ''
|
||||||
|
if [ ! -d "${libraryPath}" ]; then
|
||||||
|
$DRY_RUN_CMD mkdir --parents $VERBOSE_ARG ${libraryPath}
|
||||||
|
fi
|
||||||
|
if [ ! "$(stat -c "%G" ${libraryPath})" = "calibre-web" ]; then
|
||||||
|
$DRY_RUN_CMD chown $VERBOSE_ARG -R calibre-web:calibre-web ${libraryPath}
|
||||||
|
fi
|
||||||
|
if [ ! "$(stat -c "%a" ${libraryPath})" = "775" ]; then
|
||||||
|
$DRY_RUN_CMD chmod $VERBOSE_ARG 0775 ${libraryPath}
|
||||||
|
$DRY_RUN_CMD chmod $VERBOSE_ARG -R 0640 ${libraryPath}/*
|
||||||
|
fi
|
||||||
|
'';
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user