1 { config, pkgs, lib, ... }:
3 cfg = config.services.archivebox;
6 options.services.archivebox = {
7 enable = lib.mkEnableOption "Archivebox server";
11 dataDir = lib.mkOption {
12 type = lib.types.path;
13 default = "/var/lib/archivebox";
17 default = "archivebox";
19 group = lib.mkOption {
21 default = "archivebox";
25 systemd.tmpfiles.rules = lib.mkIf cfg.enable [
26 "d '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group}"
27 "Z '${cfg.dataDir}' 0770 ${cfg.user} ${cfg.group}"
29 systemd.services.archivebox = lib.mkIf cfg.enable {
30 wantedBy = [ "multi-user.target" ];
31 after = [ "network.target" ];
32 description = "Archives webpages in multiple formats.";
37 ExecStart = ''${pkgs.archivebox}/bin/archivebox server --init ${toString cfg.port}'';
41 StateDirectory = "archivebox";
42 WorkingDirectory = "${cfg.dataDir}";
45 users.users = lib.mkIf (cfg.user == "archivebox") { # "${cfg.user.default}") {
47 description = "Archivebox daemon user";
53 users.groups = lib.mkIf (cfg.group == "archivebox") { "${cfg.group}" = { }; }; # What a monstrosity of a line. I make me sick.