nixos-config/modules/home-manager/services/archivebox.nix
Gabriel Arazas 6b481a163a Restructure the modules
While it is easier to maintain the modules by prefixing them all with
`modules`, it is not easy when used from other flakes and/or modules.
This is my attempt on making it easier with appropriate namespaces.

Update home-manager user from the restructure
2022-01-09 19:44:09 +08:00

42 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 {
home.packages = [ pkgs.archivebox ];
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";
};
};
};
}