mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-30 22:57:55 +00:00
users/foo-dogsquared/services/archivebox: add jobset option and add it
to custom homepage
This commit is contained in:
parent
a8c6c9d7f9
commit
ea03a97fb8
@ -5,11 +5,79 @@ let
|
|||||||
cfg = hostCfg.services.archivebox;
|
cfg = hostCfg.services.archivebox;
|
||||||
|
|
||||||
inherit (config.home) homeDirectory;
|
inherit (config.home) homeDirectory;
|
||||||
port = config.state.ports.archivebox.value;
|
port = builtins.toString config.state.ports.archivebox.value;
|
||||||
|
url = "localhost:${port}";
|
||||||
|
archiveboxDir = "${config.xdg.userDirs.documents}/ArchiveBox";
|
||||||
|
|
||||||
|
jobUnitName = name: "archivebox-job-${name}";
|
||||||
|
jobType = { name, options, ... }: {
|
||||||
|
options = {
|
||||||
|
links = lib.mkOption {
|
||||||
|
type = with lib.types; listOf str;
|
||||||
|
description = "List of links to archive.";
|
||||||
|
example = lib.literalExpression ''
|
||||||
|
[
|
||||||
|
"https://guix.gnu.org/feeds/blog.atom"
|
||||||
|
"https://nixos.org/blog/announcements-rss.xml"
|
||||||
|
]
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
extraArgs = lib.mkOption {
|
||||||
|
type = with lib.types; listOf str;
|
||||||
|
description = ''
|
||||||
|
Additional arguments for adding links (i.e., {command}`archivebox add
|
||||||
|
$LINK`) from {option}`links`.
|
||||||
|
'';
|
||||||
|
default = [ ];
|
||||||
|
example = lib.literalExpression ''
|
||||||
|
[ "--depth" "1" ]
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
startAt = lib.mkOption {
|
||||||
|
type = with lib.types; str;
|
||||||
|
description = ''
|
||||||
|
Indicates how frequent the scheduled archiving will occur. Should be
|
||||||
|
a valid string format as described from {manpage}`systemd.time(5)`.
|
||||||
|
'';
|
||||||
|
default = "daily";
|
||||||
|
defaultText = "daily";
|
||||||
|
example = "*-*-01/2";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options.users.foo-dogsquared.services.archivebox.enable =
|
options.users.foo-dogsquared.services.archivebox = {
|
||||||
lib.mkEnableOption "ArchiveBox web UI server (through Podman)";
|
enable = lib.mkEnableOption "ArchiveBox web UI server (through Podman)";
|
||||||
|
|
||||||
|
jobs = lib.mkOption {
|
||||||
|
type = with lib.types; attrsOf (submodule jobType);
|
||||||
|
default = { };
|
||||||
|
defaultText = lib.literalExpression "{}";
|
||||||
|
example = lib.literalExpression ''
|
||||||
|
{
|
||||||
|
illustration = {
|
||||||
|
links = [
|
||||||
|
"https://www.davidrevoy.com/"
|
||||||
|
"https://www.youtube.com/c/ronillust"
|
||||||
|
];
|
||||||
|
startAt = "weekly";
|
||||||
|
};
|
||||||
|
|
||||||
|
research = {
|
||||||
|
links = [
|
||||||
|
"https://arxiv.org/rss/cs"
|
||||||
|
"https://distill.pub/"
|
||||||
|
];
|
||||||
|
extraArgs = [ "--depth" "1" ];
|
||||||
|
startAt = "daily";
|
||||||
|
};
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
config = lib.mkIf cfg.enable {
|
config = lib.mkIf cfg.enable {
|
||||||
state.ports = {
|
state.ports = {
|
||||||
@ -17,41 +85,72 @@ in
|
|||||||
sonic.value = 9141;
|
sonic.value = 9141;
|
||||||
};
|
};
|
||||||
|
|
||||||
sops.secrets = foodogsquaredLib.sops.getSecrets ./secrets.yaml {
|
home.packages = [
|
||||||
|
(pkgs.writeShellScriptBin "archivebox" ''
|
||||||
|
podman run --interactive --tty --volume ${archiveboxDir}:/data docker.io/archivebox/archivebox:latest
|
||||||
|
'')
|
||||||
|
];
|
||||||
|
|
||||||
|
sops.secrets = foodogsquaredLib.sops-nix.getSecrets ./secrets.yaml {
|
||||||
"archivebox/env" = { };
|
"archivebox/env" = { };
|
||||||
"sonic/env" = { };
|
"sonic/env" = { };
|
||||||
};
|
};
|
||||||
|
|
||||||
services.podman.containers.archivebox-webui = {
|
services.podman.containers = lib.mkMerge [
|
||||||
image = "archivebox/archivebox:latest";
|
(lib.mapAttrs' (name: value: lib.nameValuePair (jobUnitName name) {
|
||||||
description = "ArchiveBox web server";
|
image = "docker.io/archivebox/archivebox:latest";
|
||||||
ports = [ "${port}:${port}" ];
|
description = "ArchiveBox job '${name}'";
|
||||||
volumes = [
|
volumes = [ "${archiveboxDir}:/data" ];
|
||||||
"${config.xdg.userDirs.documents}/ArchiveBox:/data"
|
autoUpdate = "registry";
|
||||||
];
|
exec = ''echo "${lib.concatStringsSep "\n" value.links}" | archivebox add ${lib.concatStringsSep " " value.extraArgs}'';
|
||||||
autoUpdate = "registry";
|
environmentFile = config.services.podman.containers.archivebox-webui.environmentFile;
|
||||||
exec = "archivebox server localhost:${port}";
|
environment = config.services.podman.containers.archivebox-webui.environment;
|
||||||
environmentFile = [ "${config.sops.secrets."archivebox/env".path}" ];
|
}) cfg.jobs)
|
||||||
environment = {
|
|
||||||
SEARCH_BACKEND_ENGINE = "sonic";
|
|
||||||
SEARCH_BACKEND_HOST_NAME = "sonic";
|
|
||||||
PUBLIC_SNAPSHOTS = false;
|
|
||||||
PUBLIC_INDEX = false;
|
|
||||||
PUBLIC_ADD_VIEW = false;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
services.podman.containers.archivebox-sonic-search = {
|
{
|
||||||
image = "archivebox/sonic:latest";
|
archivebox-webui = {
|
||||||
description = "Sonic search instance for ArchiveBox";
|
image = "docker.io/archivebox/archivebox:latest";
|
||||||
ports = let
|
description = "ArchiveBox web server";
|
||||||
port = config.state.ports.sonic.value;
|
ports = [ "${port}:${port}" ];
|
||||||
in [ "${port}:${port}" ];
|
volumes = [
|
||||||
environmentFile = [ "${config.sops.secrets."sonic/env".path}" ];
|
"${archiveboxDir}:/data"
|
||||||
volumes = [
|
];
|
||||||
"${config.xdg.userDirs.documents}/ArchiveBox/Sonic:/var/lib/sonic/store"
|
autoUpdate = "registry";
|
||||||
"${./config/sonic/sonic.cfg}:/etc/sonic.cfg:ro"
|
exec = "archivebox server ${url}";
|
||||||
];
|
environmentFile = [ "${config.sops.secrets."archivebox/env".path}" ];
|
||||||
|
environment = {
|
||||||
|
SEARCH_BACKEND_ENGINE = "sonic";
|
||||||
|
SEARCH_BACKEND_HOST_NAME = "sonic";
|
||||||
|
PUBLIC_SNAPSHOTS = "True";
|
||||||
|
PUBLIC_INDEX = "True";
|
||||||
|
PUBLIC_ADD_VIEW = "False";
|
||||||
|
|
||||||
|
SAVE_ARCHIVE_DOT_ORG = "False";
|
||||||
|
SAVE_GIT = "False";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
archivebox-sonic-search = {
|
||||||
|
image = "docker.io/archivebox/sonic:latest";
|
||||||
|
description = "Sonic search instance for ArchiveBox";
|
||||||
|
ports = let
|
||||||
|
port = builtins.toString config.state.ports.sonic.value;
|
||||||
|
in [ "${port}:${port}" ];
|
||||||
|
environmentFile = [ "${config.sops.secrets."sonic/env".path}" ];
|
||||||
|
volumes = [
|
||||||
|
"${config.xdg.userDirs.documents}/ArchiveBox/Sonic:/var/lib/sonic/store"
|
||||||
|
"${./config/sonic/sonic.cfg}:/etc/sonic.cfg:ro"
|
||||||
|
];
|
||||||
|
extraConfig.Unit.After = [ "podman-archivebox-webui.service" ];
|
||||||
|
};
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
|
users.foo-dogsquared.programs.custom-homepage.sections.services.links = lib.singleton {
|
||||||
|
url = "${url}/public";
|
||||||
|
text = "Link archive";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user