mirror of
https://codeberg.org/icewind/palantir.git
synced 2026-06-03 10:14:09 +02:00
flake reorg
This commit is contained in:
parent
898737eea8
commit
bc6b1b1c8f
4 changed files with 177 additions and 125 deletions
114
module.nix
Normal file
114
module.nix
Normal file
|
|
@ -0,0 +1,114 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.palantir.services.palantir;
|
||||
in {
|
||||
options.palantir.services.palantir = {
|
||||
enable = mkEnableOption "Enables the palantir service";
|
||||
|
||||
port = mkOption rec {
|
||||
type = types.int;
|
||||
default = 5665;
|
||||
example = default;
|
||||
description = "The port to listen on";
|
||||
};
|
||||
|
||||
zfs = mkOption rec {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "enable zfs integration";
|
||||
};
|
||||
|
||||
docker = mkOption rec {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "enable docker integration";
|
||||
};
|
||||
|
||||
mdns = mkOption rec {
|
||||
type = types.bool;
|
||||
default = true;
|
||||
example = true;
|
||||
description = "enable mdns discovery";
|
||||
};
|
||||
|
||||
openPort = mkOption rec {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "open port";
|
||||
};
|
||||
|
||||
openMDNSPort = mkOption rec {
|
||||
type = types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "open mdns port";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
description = "package to use";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
networking.firewall.allowedTCPPorts = lib.optional cfg.openPort cfg.port;
|
||||
networking.firewall.allowedUDPPorts = lib.optional cfg.openMDNSPort 5353;
|
||||
|
||||
users.groups.powermonitoring = {};
|
||||
|
||||
services.udev.packages = [cfg.package];
|
||||
|
||||
systemd.services."palantir" = {
|
||||
wantedBy = ["multi-user.target"];
|
||||
path = lib.optional cfg.zfs pkgs.zfs;
|
||||
environment =
|
||||
{
|
||||
PORT = "${toString cfg.port}";
|
||||
LD_LIBRARY_PATH = "/run/opengl-driver/lib/"; # needed for nvidia
|
||||
}
|
||||
// (
|
||||
if (cfg.mdns == false)
|
||||
then {
|
||||
DISABLE_MDNS = "true";
|
||||
}
|
||||
else {}
|
||||
);
|
||||
|
||||
serviceConfig = {
|
||||
Restart = "on-failure";
|
||||
ExecStart = "${cfg.package}/bin/palantir";
|
||||
DynamicUser = true;
|
||||
PrivateTmp = true;
|
||||
PrivateUsers = true;
|
||||
ProtectSystem = "strict";
|
||||
ProtectHome = true;
|
||||
NoNewPrivileges = true;
|
||||
ProtectClock = !cfg.zfs; # Enabling this breaks libzfs
|
||||
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" "AF_NETLINK"] ++ lib.optional cfg.docker "AF_UNIX"; # netlink is required to make `getifaddrs` not err
|
||||
RestrictRealtime = true;
|
||||
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
|
||||
IPAddressAllow = ["localhost"] ++ lib.optional cfg.mdns "multicast";
|
||||
UMask = "0077";
|
||||
SupplementaryGroups = ["powermonitoring"] ++ lib.optional cfg.docker "docker";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue