Skip to content

Commit

Permalink
feat(flake): support explicit sensor lists
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkw committed Jun 28, 2024
1 parent 84bd698 commit 88c3b35
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@
services.eclssd = {
enable = mkEnableOption name;


i2cdev = mkOption {
type = path;
default = "/dev/i2c-1";
Expand All @@ -134,6 +133,26 @@
description = "Whether to open firewall ports for eclssd";
};

sensors = {
type = nullOr (listOf (enum [
"BME680"
"ENS160"
"PMSA003I"
"SCD30"
"SCD40"
"SCD41"
"SHT41"
"SGP30"
"SEN55"
]));
default = null;
description = ''
A list of sensors to explicitly enable, or null.
If this is null, the ECLSS daemon will attempt to use all supported sensors.
'';
};

# Currently this doesn't do anything but I intend to use it for my
# Prometheus scrape config...
location = mkOption {
Expand Down Expand Up @@ -205,6 +224,12 @@
'';

systemd.services.${name} =
let
sensorArgs =
if cfg.sensors == null
then ""
else strings.concatMapStrings (sensor: " --sensor ${sensor}") cfg.sensors;
in
{
inherit description;
wantedBy = [ "multi-user.target" ];
Expand All @@ -219,7 +244,8 @@
Group = name;
ExecStart = ''${self.packages.${pkgs.system}.default}/bin/${name} \
--i2cdev '${cfg.i2cdev}' \
--listen-addr '${cfg.server.addr}:${toString cfg.server.port}'
--listen-addr '${cfg.server.addr}:${toString cfg.server.port}'\
${sensorArgs}
'';
Restart = "on-failure";
RestartSec = "5s";
Expand Down

0 comments on commit 88c3b35

Please sign in to comment.