Initial commit
This commit is contained in:
commit
ca0c91c299
15 changed files with 1690 additions and 0 deletions
77
default.nix
Normal file
77
default.nix
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
{
|
||||
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;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue