This commit is contained in:
Robin Appelman 2025-06-02 22:29:46 +02:00
commit 95b0cb6c38
3 changed files with 43 additions and 42 deletions

View file

@ -51,7 +51,8 @@ sensor_humidity{name="Sensor 2", mac="58:2d:34:39:1a:02"} 55.9
Licensed under either of
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
- Apache License, Version 2.0 ([LICENSE-APACHE](LICENSE-APACHE) or
http://www.apache.org/licenses/LICENSE-2.0)
- MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
at your option.

View file

@ -1,25 +1,25 @@
{ config
, lib
, pkgs
, ...
{
config,
lib,
pkgs,
...
}:
with lib; let
cfg = config.services.mitemp;
format = pkgs.formats.toml { };
format = pkgs.formats.toml {};
configFile = format.generate "mitemp-config.toml" {
inherit (cfg) names;
listen = {
inherit (cfg) socket;
};
};
in
{
in {
options.services.mitemp = {
enable = mkEnableOption "mitemp";
names = mkOption {
type = types.attrs;
default = { };
default = {};
description = "Names for mitemp sensors";
};
@ -45,8 +45,8 @@ in
services.dbus.packages = [cfg.package];
systemd.services."mitemp" = {
wantedBy = [ "multi-user.target" ];
after = [ "dbus.service" ];
wantedBy = ["multi-user.target"];
after = ["dbus.service"];
serviceConfig = {
ExecStart = "${cfg.package}/bin/mitemp-prometheus ${configFile}";
@ -68,18 +68,18 @@ in
ProtectHostname = true;
LockPersonality = true;
ProtectKernelTunables = true;
RestrictAddressFamilies = [ "AF_UNIX" ];
RestrictAddressFamilies = ["AF_UNIX"];
RuntimeDirectory = "mitemp";
RestrictRealtime = true;
ProtectProc = "invisible";
SystemCallFilter = [ "@system-service" "~@resources" "~@privileged" ];
SystemCallFilter = ["@system-service" "~@resources" "~@privileged"];
IPAddressDeny = "any";
PrivateUsers = true;
ProcSubset = "pid";
RemoveIPC = true;
PrivateDevices = true;
RestrictSUIDSGID = true;
BindPaths = [ "/run/dbus" ];
BindPaths = ["/run/dbus"];
};
confinement = {

View file

@ -1,38 +1,38 @@
{ stdenv
, rustPlatform
, lib
, pkg-config
, dbus
}:
let
{
stdenv,
rustPlatform,
lib,
pkg-config,
dbus,
}: let
inherit (lib.sources) sourceByRegex;
inherit (builtins) fromTOML readFile;
src = sourceByRegex ./. [ "Cargo.*" "(src)(/.*)?" ];
src = sourceByRegex ./. ["Cargo.*" "(src)(/.*)?"];
cargoToml = (fromTOML (readFile ./Cargo.toml)).package;
in
rustPlatform.buildRustPackage rec {
pname = cargoToml.name;
rustPlatform.buildRustPackage rec {
pname = cargoToml.name;
inherit src;
inherit (cargoToml) version;
inherit src;
inherit (cargoToml) version;
buildInputs = [
dbus
];
buildInputs = [
dbus
];
nativeBuildInputs = [
pkg-config
];
nativeBuildInputs = [
pkg-config
];
preInstall = ''
mkdir -p $out/share/dbus-1/system.d
cp ${./dbus-bluetooth.xml} $out/share/dbus-1/system.d/dbus-bluetooth.conf
'';
preInstall = ''
mkdir -p $out/share/dbus-1/system.d
cp ${./dbus-bluetooth.xml} $out/share/dbus-1/system.d/dbus-bluetooth.conf
'';
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"btleplug-0.11.6" = "sha256-Y9QZ6er/zaXALiQUUw8mMvzg15Dhz9NsWQ2WAM/ouh0=";
cargoLock = {
lockFile = ./Cargo.lock;
outputHashes = {
"btleplug-0.11.6" = "sha256-Y9QZ6er/zaXALiQUUw8mMvzg15Dhz9NsWQ2WAM/ouh0=";
};
};
};
}
}