78 lines
1.7 KiB
Nix
78 lines
1.7 KiB
Nix
|
|
{
|
||
|
|
pkgs,
|
||
|
|
lib,
|
||
|
|
config,
|
||
|
|
bun2nix,
|
||
|
|
...
|
||
|
|
}: let
|
||
|
|
# This code, when _compiled/minified_, seems to break.
|
||
|
|
# I'm not debugging this right now.
|
||
|
|
server = pkgs.stdenv.mkDerivation {
|
||
|
|
pname = "trmnlc";
|
||
|
|
version = "1.0.0";
|
||
|
|
src = ./.;
|
||
|
|
nativeBuildInputs = [ bun2nix.hook ];
|
||
|
|
|
||
|
|
bunDeps = bun2nix.fetchBunDeps {
|
||
|
|
bunNix = ./bun.nix;
|
||
|
|
};
|
||
|
|
|
||
|
|
buildPhase = "true";
|
||
|
|
installPhase = ''
|
||
|
|
cp -rf . $out
|
||
|
|
'';
|
||
|
|
};
|
||
|
|
|
||
|
|
cfg = config.services.trmnlc;
|
||
|
|
json = pkgs.formats.json {};
|
||
|
|
configFile = json.generate "config.json" cfg.settings;
|
||
|
|
in
|
||
|
|
{
|
||
|
|
options.services.trmnlc = {
|
||
|
|
enable = lib.mkEnableOption "TRMNLc server software";
|
||
|
|
settings = lib.mkOption {
|
||
|
|
default = {};
|
||
|
|
type = json.type;
|
||
|
|
example = lib.literalExpression ''
|
||
|
|
{
|
||
|
|
unknown = {
|
||
|
|
urls = ["https://user.fm/calendar/....ics"];
|
||
|
|
refresh = 60;
|
||
|
|
model = "inkplate_10";
|
||
|
|
};
|
||
|
|
}
|
||
|
|
'';
|
||
|
|
|
||
|
|
description = "The TRMNLc configuration.";
|
||
|
|
};
|
||
|
|
};
|
||
|
|
|
||
|
|
config = lib.mkIf cfg.enable {
|
||
|
|
systemd.services.trmnl = {
|
||
|
|
wantedBy = [ "multi-user.target" ];
|
||
|
|
path = [ pkgs.imagemagick ];
|
||
|
|
|
||
|
|
environment = {
|
||
|
|
FIREFOX = "${pkgs.firefox}/bin/firefox";
|
||
|
|
CONFIG_FILE = configFile;
|
||
|
|
HOME = "/tmp";
|
||
|
|
TZ = "Europe/Amsterdam";
|
||
|
|
FONTCONFIG_FILE = ./fonts.conf;
|
||
|
|
COLORMAP = ./colormap.png;
|
||
|
|
BUN_PORT = "2300";
|
||
|
|
};
|
||
|
|
|
||
|
|
serviceConfig = {
|
||
|
|
ExecStart = "${pkgs.bun}/bin/bun run ${server}/src/web.ts";
|
||
|
|
KillMode = "mixed";
|
||
|
|
KillSignal = "SIGKILL";
|
||
|
|
Restart = "on-failure";
|
||
|
|
RestartSec = 5;
|
||
|
|
RestartPreventExitStatus = "SIGKILL";
|
||
|
|
|
||
|
|
DynamicUser = true;
|
||
|
|
};
|
||
|
|
};
|
||
|
|
};
|
||
|
|
}
|