mirror of
https://codeberg.org/icewind/ptouch-api.git
synced 2026-06-03 10:54:07 +02:00
initial version
This commit is contained in:
parent
ddc5849ed6
commit
e37160b717
11 changed files with 2800 additions and 3 deletions
85
nix/module.nix
Normal file
85
nix/module.nix
Normal file
|
|
@ -0,0 +1,85 @@
|
|||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
with lib; let
|
||||
cfg = config.services.ptouch-api;
|
||||
in {
|
||||
options.services.ptouch-api = {
|
||||
enable = mkEnableOption "Enables the ptouch-api service";
|
||||
|
||||
socket = mkOption rec {
|
||||
type = types.str;
|
||||
default = "/run/ptouch-api/ptouch-api.sock";
|
||||
description = "The socket to listen on";
|
||||
};
|
||||
|
||||
package = mkOption {
|
||||
type = types.package;
|
||||
description = "package to use";
|
||||
};
|
||||
|
||||
logLevel = mkOption {
|
||||
type = types.str;
|
||||
default = "info";
|
||||
description = "Log level";
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
users.users.ptouch-api = {
|
||||
isSystemUser = true;
|
||||
group = "ptouch-api";
|
||||
};
|
||||
users.groups.ptouch-api = {};
|
||||
|
||||
services.udev.packages = [cfg.package];
|
||||
|
||||
systemd.services.ptouch-api = {
|
||||
wants = ["ptouch-api.socket"];
|
||||
after = ["ptouch-api.socket"];
|
||||
environment = {
|
||||
RUST_LOG = cfg.logLevel;
|
||||
};
|
||||
|
||||
serviceConfig = {
|
||||
Restart = "on-failure";
|
||||
ExecStart = getExe cfg.package;
|
||||
User = "ptouch-api";
|
||||
PrivateUsers = true;
|
||||
PrivateTmp = true;
|
||||
ProtectSystem = "strict";
|
||||
ProtectHome = true;
|
||||
NoNewPrivileges = true;
|
||||
ProtectClock = true;
|
||||
CapabilityBoundingSet = true;
|
||||
ProtectControlGroups = true;
|
||||
SystemCallArchitectures = "native";
|
||||
ProtectKernelModules = true;
|
||||
ProtectKernelLogs = true;
|
||||
ProtectKernelTunables = true;
|
||||
ProtectHostname = true;
|
||||
LockPersonality = true;
|
||||
ProtectProc = "invisible";
|
||||
RestrictAddressFamilies = ["AF_LOCAL"];
|
||||
RestrictRealtime = true;
|
||||
SystemCallFilter = ["~@reboot" "~@cpu-emulation" "~@obsolete" "~@debug" "~@swap" "~@clock" "~@module"];
|
||||
RestrictNamespaces = ["~cgroup"];
|
||||
RuntimeDirectory = "ptouch-api";
|
||||
UMask = "0007";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.sockets.ptouch-api = {
|
||||
enable = true;
|
||||
wantedBy = ["sockets.target"];
|
||||
|
||||
socketConfig = {
|
||||
ListenStream = cfg.socket;
|
||||
SocketMode = "0666";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
3
nix/overlay.nix
Normal file
3
nix/overlay.nix
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
final: prev: {
|
||||
ptouch-api = final.callPackage ./package.nix {};
|
||||
}
|
||||
26
nix/package.nix
Normal file
26
nix/package.nix
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
rustPlatform,
|
||||
pkg-config,
|
||||
lib,
|
||||
}: let
|
||||
inherit (lib.sources) sourceByRegex;
|
||||
inherit (builtins) fromTOML readFile;
|
||||
src = sourceByRegex ../. ["Cargo.*" "(src)(/.*)?" ".*\.rules"];
|
||||
version = (fromTOML (readFile ../Cargo.toml)).package.version;
|
||||
in
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "ptouch-api";
|
||||
|
||||
inherit src version;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = ../Cargo.lock;
|
||||
};
|
||||
|
||||
postInstall = ''
|
||||
mkdir -p $out/lib/udev/rules.d/
|
||||
cp ./51-ptouch-api.rules $out/lib/udev/rules.d/
|
||||
'';
|
||||
|
||||
meta.mainProgram = "ptouch-api";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue