mirror of
https://github.com/foo-dogsquared/nixos-config.git
synced 2025-01-31 16:57:55 +00:00
41 lines
1.1 KiB
Nix
41 lines
1.1 KiB
Nix
|
{ config, options, lib, pkgs, ... }:
|
||
|
|
||
|
let
|
||
|
cfg = config.services.archivebox;
|
||
|
in {
|
||
|
options.services.archivebox = {
|
||
|
enable = lib.mkEnableOption "Archivebox service";
|
||
|
|
||
|
port = lib.mkOption {
|
||
|
type = lib.types.port;
|
||
|
description = "The port number to be used for the server at localhost.";
|
||
|
default = 8000;
|
||
|
example = 8888;
|
||
|
};
|
||
|
|
||
|
archivePath = lib.mkOption {
|
||
|
type = with lib.types; either path str;
|
||
|
description = "The path of the Archivebox archive.";
|
||
|
example = "\${config.xdg.dataHome}/archivebox";
|
||
|
};
|
||
|
};
|
||
|
|
||
|
config = lib.mkIf cfg.enable {
|
||
|
systemd.user.services.archivebox-server = {
|
||
|
Unit = {
|
||
|
Description = "Archivebox server for ${cfg.archivePath}";
|
||
|
After = "network.target";
|
||
|
Documentation = [ "https://docs.archivebox.io/" ];
|
||
|
};
|
||
|
|
||
|
Install.WantedBy = [ "graphical-session.target" ];
|
||
|
|
||
|
Service = {
|
||
|
ExecStart = "${pkgs.archivebox}/bin/archivebox server localhost:${toString cfg.port}";
|
||
|
WorkingDirectory = cfg.archivePath;
|
||
|
Restart = "on-failure";
|
||
|
};
|
||
|
};
|
||
|
};
|
||
|
}
|