flake update

This commit is contained in:
Robin Appelman 2026-03-26 22:54:55 +01:00
commit 5a6d7006e0
5 changed files with 24 additions and 24 deletions

70
nix/module.nix Normal file
View file

@ -0,0 +1,70 @@
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.ugc-api-server;
in {
options.services.ugc-api-server = {
enable = mkEnableOption "ugc api server";
logLevel = mkOption {
type = types.str;
default = "INFO";
description = "log level";
};
port = mkOption {
type = types.port;
default = 10333;
description = "port to listen to";
};
package = mkOption {
type = types.package;
description = "package to use";
};
};
config = mkIf cfg.enable {
systemd.services."ugc-api-server" = {
wantedBy = ["multi-user.target"];
after = ["network-online.target"];
wants = ["network-online.target"];
environment = {
RUST_LOG = cfg.logLevel;
PORT = toString cfg.port;
};
serviceConfig = {
ExecStart = "${cfg.package}/bin/ugc-api-server";
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"];
PrivateUsers = true;
ProcSubset = "pid";
};
};
};
}

4
nix/overlay.nix Normal file
View file

@ -0,0 +1,4 @@
final: prev: {
ugc-api-server = final.callPackage ./package.nix {};
ugc-api-archiver = final.callPackage ./archiver.nix {};
}

33
nix/package.nix Normal file
View file

@ -0,0 +1,33 @@
{
rustPlatform,
openssl,
pkg-config,
lib,
}: let
inherit (lib.sources) sourceByRegex;
inherit (builtins) fromTOML readFile;
src = sourceByRegex ../. ["Cargo.*" "((types|api-server|)/?(src)?)(/.*)?" "README.md"];
version = (fromTOML (readFile ../api-server/Cargo.toml)).package.version;
in
rustPlatform.buildRustPackage rec {
pname = "ugc-api-server";
sourceRoot = "${src.name}/api-server";
inherit src version;
buildInputs = [
openssl
];
nativeBuildInputs = [
pkg-config
];
OPENSSL_NO_VENDOR = 1;
doCheck = false;
cargoLock = {
lockFile = ../api-server/Cargo.lock;
};
}