82 lines
2.0 KiB
Nix
82 lines
2.0 KiB
Nix
|
{ lib, config, pkgs, satnogsDemoDisplayPkgs, ... }:
|
||
|
with lib;
|
||
|
let
|
||
|
# Shorter name to access final settings a
|
||
|
# user of hello.nix module HAS ACTUALLY SET.
|
||
|
# cfg is a typical convention.
|
||
|
cfg = config.services.satnogsDemoDisplay;
|
||
|
in
|
||
|
{
|
||
|
|
||
|
options.services.satnogsDemoDisplay = {
|
||
|
enable = mkEnableOption "satnogs-demo-display service";
|
||
|
|
||
|
package = mkOption {
|
||
|
default = satnogsDemoDisplayPkgs.x86_64-linux.cross-armv6l-linux;
|
||
|
type = types.package;
|
||
|
description = "satnogsDemoDisplay packages to use. Needed to fix crosscompilation issues.";
|
||
|
};
|
||
|
|
||
|
user = mkOption {
|
||
|
type = types.str;
|
||
|
default = "satnogs-demo";
|
||
|
description = mdDoc "User to run the desktop environment and display script.";
|
||
|
};
|
||
|
|
||
|
group = mkOption {
|
||
|
type = types.str;
|
||
|
default = "satnogs-demo";
|
||
|
description = mdDoc "Group for the user.";
|
||
|
};
|
||
|
|
||
|
|
||
|
stateDir = mkOption {
|
||
|
default = "/var/lib/satnogs-demo-display";
|
||
|
type = types.str;
|
||
|
description = mdDoc "Demo display data directory.";
|
||
|
};
|
||
|
};
|
||
|
|
||
|
config = mkIf cfg.enable {
|
||
|
environment.systemPackages = [
|
||
|
cfg.package
|
||
|
];
|
||
|
|
||
|
users.users = mkIf (cfg.user == "satnogs-demo") {
|
||
|
satnogs-demo = {
|
||
|
home = cfg.stateDir;
|
||
|
useDefaultShell = true;
|
||
|
group = cfg.group;
|
||
|
isSystemUser = true;
|
||
|
};
|
||
|
};
|
||
|
|
||
|
systemd.tmpfiles.rules = [
|
||
|
"d '${cfg.stateDir}' 0750 ${cfg.user} ${cfg.group} - -"
|
||
|
];
|
||
|
|
||
|
systemd.services.satnogsDemoDisplay = {
|
||
|
wantedBy = [ "multi-user.target" ];
|
||
|
description = "satnogsDemoDisplay service";
|
||
|
serviceConfig = {
|
||
|
Type = "exec";
|
||
|
User = cfg.user;
|
||
|
Group = cfg.group;
|
||
|
Restart = "always";
|
||
|
RestartSec = "1s";
|
||
|
StartLimitIntervalSec = "0";
|
||
|
WorkingDirectory = cfg.stateDir;
|
||
|
};
|
||
|
script = ''
|
||
|
ln -s ${cfg.package}/satnogs-logo.png ./
|
||
|
ln -s ${cfg.package}/Montserrat-Regular.otf ./
|
||
|
|
||
|
while true; do
|
||
|
${cfg.package}/bin/update.py
|
||
|
sleep 60
|
||
|
done
|
||
|
'';
|
||
|
};
|
||
|
};
|
||
|
}
|