flake reorg

This commit is contained in:
Robin Appelman 2024-01-14 17:56:33 +01:00
commit 7ec17d75ad
9 changed files with 200 additions and 202 deletions

77
module.nix Normal file
View file

@ -0,0 +1,77 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.taspromto;
in {
options.services.taspromto = {
enable = mkEnableOption "taspromto";
mitempNames = mkOption {
type = types.attrs;
default = {};
description = "Names for mitemp sensors";
};
port = mkOption {
type = types.int;
default = 3030;
description = "port to listen to";
};
mqttCredentailsFile = mkOption {
type = types.str;
description = "path containing MQTT_HOSTNAME, MQTT_USERNAME and MQTT_PASSWORD environment variables";
};
package = mkOption {
type = types.package;
defaultText = literalExpression "pkgs.shelve";
description = "package to use";
};
};
config = mkIf cfg.enable {
systemd.services."taspromto" = {
wantedBy = ["multi-user.target"];
environment = {
PORT = toString cfg.port;
MITEMP_NAMES = concatStringsSep "," (map (k: k + "=" + cfg.mitempNames."${k}") (attrNames cfg.mitempNames));
};
serviceConfig = {
ExecStart = "${config.package}/bin/taspromto";
EnvironmentFile = cfg.mqttCredentailsFile;
Restart = "on-failure";
DynamicUser = true;
PrivateTmp = true;
ProtectSystem = "strict";
ProtectHome = true;
NoNewPrivileges = true;
PrivateDevices = true;
ProtectClock = true;
CapabilityBoundingSet = true;
ProtectKernelLogs = true;
ProtectControlGroups = true;
SystemCallArchitectures = "native";
ProtectKernelModules = true;
RestrictNamespaces = true;
MemoryDenyWriteExecute = true;
ProtectHostname = true;
LockPersonality = true;
ProtectKernelTunables = true;
RestrictAddressFamilies = "AF_INET AF_INET6";
RestrictRealtime = true;
ProtectProc = "noaccess";
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
IPAddressDeny = "any";
IPAddressAllow = ["localhost"];
PrivateUsers = true;
ProcSubset = "pid";
};
};
};
}