2022-12-13 06:54:06 -08:00
|
|
|
{ config, options, lib, pkgs, ... }:
|
|
|
|
with lib;
|
|
|
|
let
|
|
|
|
# cfg = config.services.archivebox;
|
|
|
|
dataDir = "/var/lib/archivebox";
|
|
|
|
user = "archivebox";
|
|
|
|
port = "8123";
|
|
|
|
in
|
|
|
|
{
|
2022-12-13 07:05:56 -08:00
|
|
|
nixpkgs.config.permittedInsecurePackages = [
|
|
|
|
"python3.10-django-3.1.14"
|
|
|
|
];
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."archive.mossnet.lan" = {
|
|
|
|
enableACME = false;
|
|
|
|
forceSSL = false;
|
|
|
|
|
|
|
|
locations."/" = {
|
|
|
|
extraConfig = ''
|
|
|
|
proxy_pass http://localhost:${port}/;
|
|
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2022-12-13 06:54:06 -08:00
|
|
|
systemd.services.archivebox-install = {
|
|
|
|
description = "archivebox install service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = with pkgs; [ coreutils archivebox ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = user;
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
PermissionsStartOnly = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
preStart = ''
|
|
|
|
mkdir -p "${dataDir}"
|
|
|
|
chown ${user} "${dataDir}"
|
|
|
|
'';
|
|
|
|
|
|
|
|
script = ''
|
2022-12-13 07:05:56 -08:00
|
|
|
echo "Setting up archivebox files in ${dataDir} ..."
|
2022-12-13 06:54:06 -08:00
|
|
|
cd "${dataDir}"
|
|
|
|
|
|
|
|
archivebox init
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
|
|
|
systemd.services.archivebox-server = {
|
|
|
|
description = "archivebox server service";
|
|
|
|
wantedBy = [ "multi-user.target" ];
|
|
|
|
path = with pkgs; [ coreutils archivebox ];
|
|
|
|
|
|
|
|
serviceConfig = {
|
|
|
|
User = user;
|
|
|
|
Type = "oneshot";
|
|
|
|
RemainAfterExit = "yes";
|
|
|
|
PermissionsStartOnly = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
preStart = ''
|
|
|
|
mkdir -p "${dataDir}"
|
|
|
|
chown ${user} "${dataDir}"
|
|
|
|
'';
|
|
|
|
|
|
|
|
script = ''
|
|
|
|
echo "Setting up wallabag files in ${dataDir} ..."
|
|
|
|
cd "${dataDir}"
|
|
|
|
|
|
|
|
archivebox server 0.0.0.0:${port}
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|