mirror of
https://codeberg.org/leana8959/.files.git
synced 2025-12-06 14:49:14 +00:00
make package set self referential collapse redundant files for package plumbing rework packages overlay and simplify scope update altiosevka font make altiosevka an overlay instead note invert package logic scope overlay unify package overlay logic fix overlay reference
66 lines
1.5 KiB
Nix
66 lines
1.5 KiB
Nix
{
|
|
pkgs,
|
|
config,
|
|
lib,
|
|
...
|
|
}: let
|
|
cfg = config.services.typst-bot;
|
|
t = lib.types;
|
|
in {
|
|
options = {
|
|
services.typst-bot = {
|
|
enable = lib.mkEnableOption "typst-bot";
|
|
|
|
dataDir = lib.mkOption {
|
|
description = "Cache directory";
|
|
type = t.path;
|
|
default = "/var/typst-bot";
|
|
};
|
|
|
|
environmentFile = lib.mkOption {
|
|
description = "Path to an environment file, you can set the token there";
|
|
type = t.path;
|
|
};
|
|
};
|
|
};
|
|
|
|
config = lib.mkIf cfg.enable {
|
|
users.users."typst-bot" = {
|
|
group = "typst-bot";
|
|
isSystemUser = true;
|
|
};
|
|
users.groups."typst-bot" = {};
|
|
|
|
systemd.tmpfiles.rules = [
|
|
"d ${cfg.dataDir}/cache 700 typst-bot typst-bot - -"
|
|
"d ${cfg.dataDir}/sqlite 700 typst-bot typst-bot - -"
|
|
];
|
|
|
|
systemd.services."typst-bot" = {
|
|
description = "A discord bot to render Typst code";
|
|
after = ["network.target"];
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
preStart = ''
|
|
touch ${cfg.dataDir}/sqlite/db.sqlite
|
|
'';
|
|
|
|
# Don't pollute the global path
|
|
path = [pkgs.typst-bot];
|
|
script = "typst-bot";
|
|
|
|
serviceConfig = {
|
|
User = "typst-bot";
|
|
Group = "typst-bot";
|
|
|
|
EnvironmentFile = [
|
|
"${pkgs.writeText "typst-bot-env" ''
|
|
DB_PATH=${cfg.dataDir}/sqlite/db.sqlite
|
|
CACHE_DIRECTORY=${cfg.dataDir}/cache
|
|
''}"
|
|
cfg.environmentFile
|
|
];
|
|
};
|
|
};
|
|
};
|
|
}
|